+evil:apply-macro: fix operator & fail gracefully

Formly, this would fail silently. This has been rewritten to let you
know if no macro is available at a register. It will also inform you how
many times the macro was executed.

Also fixes g@ not invoking the operator state.
This commit is contained in:
Henrik Lissner 2018-10-18 19:41:29 -04:00
parent 97f8594a71
commit 005a07b416
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -122,7 +122,6 @@ integration."
;;;###autoload (autoload '+evil:apply-macro "feature/evil/autoload/evil" nil t)
(evil-define-operator +evil:apply-macro (beg end)
"Apply macro to each line."
:motion nil
:move-point nil
(interactive "<r>")
(let ((register (or evil-this-register (read-char)))
@ -137,9 +136,14 @@ integration."
(setq macro (evil-get-register evil-last-register t)))
((setq macro (evil-get-register register t)
evil-last-register register)))
(unless macro
(user-error "No macro recorded in %c register" register))
(evil-change-state 'normal)
(evil-with-single-undo
(apply-macro-to-region-lines beg end macro))))
(let ((lines (count-lines beg end)))
(message "Applied macro in %c register %d times" register lines)
(apply-macro-to-region-lines beg end macro)
(message "Applied macro in %c register %d times...DONE" register lines)))))
;;;###autoload (autoload '+evil:retab "feature/evil/autoload/evil" nil t)
(evil-define-operator +evil:retab (&optional beg end)