diff --git a/evil-commands.el b/evil-commands.el index 3a0b3b35..e9317117 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -4247,10 +4247,12 @@ Use `evil-flush-lines' if INVERT is nil, or `evil-keep-lines' if not." (setq markers (nreverse markers)) (unwind-protect (evil-with-single-undo - (let ((evil--ex-global-active-p t)) - (dolist (marker markers) - (goto-char marker) - (eval command-form t)))) + (combine-change-calls (point-min) (point-max) + (let ((evil--ex-global-active-p t) + pre-command-hook post-command-hook) + (dolist (marker markers) + (goto-char marker) + (eval command-form t))))) ;; ensure that all markers are deleted afterwards, ;; even in the event of failure (dolist (marker markers) @@ -4287,11 +4289,13 @@ range. The given argument is passed straight to (deactivate-mark) (evil-force-normal-state) (evil-with-single-undo - (dolist (marker markers) - (goto-char marker) - (ignore-errors (execute-kbd-macro commands)) - (evil-force-normal-state) - (set-marker marker nil))))) + (combine-change-calls beg end + (let (pre-command-hook post-command-hook) + (dolist (marker markers) + (goto-char marker) + (ignore-errors (execute-kbd-macro commands)) + (evil-force-normal-state) + (set-marker marker nil))))))) (evil-define-motion evil-goto-char (position) "Go to POSITION in the buffer. diff --git a/evil-common.el b/evil-common.el index 7f60bdfb..fac0f9af 100644 --- a/evil-common.el +++ b/evil-common.el @@ -79,6 +79,12 @@ the buffer-local value of HOOK is modified." (declare (obsolete evil-with-delay "1.15.0") (indent 2)) (eval `(evil-with-delay ,condition (,hook ,append ,local ,name) ,form) t)) +;; Used to improve performance in macros, :global, and other batch edits +;; TODO remove this once support for emacs 26 is dropped +(eval-when-compile + (unless (fboundp 'combine-change-calls) + (defmacro combine-change-calls (_beg _end &rest body) `(progn ,@body)))) + ;;; List functions (defmacro evil--add-to-alist (alist &rest elements) diff --git a/evil-states.el b/evil-states.el index 62a612a9..f5696caf 100644 --- a/evil-states.el +++ b/evil-states.el @@ -138,10 +138,6 @@ commands opening a new line." (remove-hook 'pre-command-hook #'evil-insert-repeat-hook)) (put 'evil-insert-repeat-hook 'permanent-local-hook t) -(eval-when-compile - ;; TODO remove this once support for emacs 26 is dropped - (unless (fboundp 'combine-change-calls) - (defmacro combine-change-calls (_beg _end &rest body) `(progn ,@body)))) (declare-function evil-execute-repeat-info "evil-repeat") (defun evil-cleanup-insert-state () "Called when Insert or Replace state is about to be exited.