diff options
| author | Stefan Monnier <monnier@iro.umontreal.ca> | 2023-07-01 16:05:34 -0400 |
|---|---|---|
| committer | Axel Forsman <axel@axelf.se> | 2023-08-12 10:47:11 +0200 |
| commit | 3d7faadf30016a8c20699a5fb1b5731b8a49dcd2 (patch) | |
| tree | fba9d494396f727f0bb8607253aee7a31768870a /evil-commands.el | |
| parent | 5e72cf5b6d57b785ea229236bb5c4638db2c9a05 (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.el | 68 |
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)) |
