aboutsummaryrefslogtreecommitdiff
path: root/evil-commands.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2023-07-01 16:05:34 -0400
committerTom Dalziel <tom_dl@hotmail.com>2023-08-20 23:46:23 +0100
commit44add36e972ed22ded6cb89654986e80d1d8989e (patch)
tree888d946d2dffc9e91ea568ff6e65c17dc8f88a11 /evil-commands.el
parent46ab271a524c9eda90fa2ddd272e0f2232fa1c87 (diff)
(evil-with-delay): New macro, extracted from `evil-delay`
Save some kittens by using a macro instead of using `eval`. This also exposes more code to the compiler, so should result in more efficient code and potentially better compiler warnings. * evil-common.el (evil-unquote): Delete unused function. (evil--with-delay): New function, extracted from `evil-delay`. (evil-with-delay): New macro, extracted from `evil-delay`. (evil-delay): Redefine using `evil-with-delay` and declare obsolete. * evil-states.el (evil-visual-activate-hook): * evil-core.el (evil-define-key): * evil-commands.el (evil-execute-in-normal-state): Use `evil-with-delay`.
Diffstat (limited to 'evil-commands.el')
-rw-r--r--evil-commands.el68
1 files changed, 35 insertions, 33 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 8e4de2b..8d3db3d 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -5116,39 +5116,41 @@ Restore the disabled repeat hooks on insert-state exit."
(defun evil-execute-in-normal-state ()
"Execute the next command in Normal state."
(interactive)
- (evil-delay '(not (memq this-command
- '(nil
- evil-execute-in-normal-state
- evil-replace-state
- evil-use-register
- digit-argument
- negative-argument
- universal-argument
- universal-argument-minus
- universal-argument-more
- universal-argument-other-key)))
- `(with-current-buffer ,(current-buffer)
- ;; If cursor was after EOL before CTRL-O and is now at EOL,
- ;; put it after EOL.
- (and (or (when evil--execute-normal-eol-pos
- (= (1+ (point)) (save-excursion
- (goto-char evil--execute-normal-eol-pos)
- (set-marker evil--execute-normal-eol-pos nil)
- (line-end-position))))
- (and (eq (or goal-column temporary-goal-column) most-positive-fixnum)
- (memq this-command '(next-line previous-line))))
- (not (eolp))
- (not (memq this-command
- '(evil-insert evil-beginning-of-line evil-first-non-blank)))
- (forward-char))
- (unless (memq evil-state '(replace insert))
- (evil-change-state ',evil-state))
- (when (eq 'insert evil-state)
- (remove-hook 'pre-command-hook #'evil-repeat-pre-hook)
- (remove-hook 'post-command-hook #'evil-repeat-post-hook)
- (add-hook 'evil-insert-state-exit-hook #'evil--restore-repeat-hooks))
- (setq evil-execute-normal-keys nil))
- 'post-command-hook)
+ (let ((buf (current-buffer))
+ (state evil-state))
+ (evil-with-delay (not (memq this-command
+ '(nil
+ evil-execute-in-normal-state
+ evil-replace-state
+ evil-use-register
+ digit-argument
+ negative-argument
+ universal-argument
+ universal-argument-minus
+ universal-argument-more
+ universal-argument-other-key)))
+ post-command-hook
+ (with-current-buffer buf
+ ;; If cursor was after EOL before CTRL-O and is now at EOL,
+ ;; put it after EOL.
+ (and (or (when evil--execute-normal-eol-pos
+ (= (1+ (point)) (save-excursion
+ (goto-char evil--execute-normal-eol-pos)
+ (set-marker evil--execute-normal-eol-pos nil)
+ (line-end-position))))
+ (and (eq (or goal-column temporary-goal-column) most-positive-fixnum)
+ (memq this-command '(next-line previous-line))))
+ (not (eolp))
+ (not (memq this-command
+ '(evil-insert evil-beginning-of-line evil-first-non-blank)))
+ (forward-char))
+ (unless (memq evil-state '(replace insert))
+ (evil-change-state state))
+ (when (eq 'insert evil-state)
+ (remove-hook 'pre-command-hook #'evil-repeat-pre-hook)
+ (remove-hook 'post-command-hook #'evil-repeat-post-hook)
+ (add-hook 'evil-insert-state-exit-hook #'evil--restore-repeat-hooks))
+ (setq evil-execute-normal-keys nil))))
(setq evil-insert-count nil
evil--execute-normal-return-state evil-state
evil--execute-normal-eol-pos (when (eolp) (point-marker))