aboutsummaryrefslogtreecommitdiff
path: root/evil-commands.el
diff options
context:
space:
mode:
authorAxel Forsman <axelsfor@gmail.com>2023-01-07 10:44:05 +0100
committerAxel Forsman <axelsfor@gmail.com>2023-01-12 11:56:28 +0100
commit30e819dcf47294a758a47a362d2f61fc19aefcf0 (patch)
treef4ce55350bc937152814ca0ad0289f171a3cf34c /evil-commands.el
parent9daad9cca5e44887c5408b3cbbeb437b8fb80fa8 (diff)
Fix executing macro infinite times
This commit fixes a regression caused by #1549 where you could no longer give a prefix argument to execute the macro in an infinite loop.
Diffstat (limited to 'evil-commands.el')
-rw-r--r--evil-commands.el27
1 files changed, 12 insertions, 15 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 3f9b5ab..5816d8a 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2390,7 +2390,7 @@ will be opened instead."
(evil-set-register evil-this-macro nil)
(kmacro-start-macro nil)
(setq evil-macro-buffer (current-buffer)))
- (t (error "Invalid register")))))
+ (t (error "Invalid register `%s'" register)))))
(evil-define-command evil-execute-macro (count macro)
"Execute keyboard macro MACRO, COUNT times.
@@ -2402,15 +2402,14 @@ when called interactively."
:suppress-operator t
(interactive
(let (count macro register)
- (setq count (if current-prefix-arg
- (if (numberp current-prefix-arg)
- current-prefix-arg
- 0) 1)
+ (setq count (cond ((null current-prefix-arg) 1)
+ ((numberp current-prefix-arg) current-prefix-arg)
+ (t 0))
register (or evil-this-register (read-char)))
(cond
- ((or (and (eq register ?@) (eq evil-last-register ?:))
- (eq register ?:))
- (setq macro (lambda () (evil-ex-repeat nil))
+ ((or (eq register ?:)
+ (and (eq register ?@) (eq evil-last-register ?:)))
+ (setq macro #'evil-ex-repeat
evil-last-register ?:))
((eq register ?@)
(unless evil-last-register
@@ -2423,24 +2422,22 @@ when called interactively."
(cond
((functionp macro)
(evil-repeat-abort)
- (dotimes (_ (or count 1))
- (funcall macro)))
+ (if (zerop count)
+ (while t (funcall macro))
+ (dotimes (_ (or count 1)) (funcall macro))))
((or (and (not (stringp macro))
(not (vectorp macro)))
(member macro '("" [])))
;; allow references to currently empty registers
;; when defining macro
- (unless evil-this-macro
- (user-error "No previous macro")))
+ (unless evil-this-macro (user-error "No previous macro")))
(t
(condition-case err
(evil-with-single-undo
- (dotimes (_ (or count 1))
- (execute-kbd-macro macro)))
+ (execute-kbd-macro macro count))
;; enter Normal state if the macro fails
(error
(evil-normal-state)
- (evil-normalize-keymaps)
(signal (car err) (cdr err)))))))
(evil-define-command evil-execute-last-recorded-macro (count)