aboutsummaryrefslogtreecommitdiff
path: root/evil-commands.el
diff options
context:
space:
mode:
authorTom Dalziel <33435574+tomdl89@users.noreply.github.com>2021-12-09 21:36:46 +0100
committerGitHub <noreply@github.com>2021-12-09 21:36:46 +0100
commit44080eb3070642cc4f79e483a78712930dbf2797 (patch)
tree7156ce4aede8018f981d5507feed51e40dec6d6f /evil-commands.el
parente4fb2a37c5bd3723c4869d7b6728a43b7321876e (diff)
Allow exit from insert, paste from . without forward-char (#1550)
Diffstat (limited to 'evil-commands.el')
-rw-r--r--evil-commands.el55
1 files changed, 30 insertions, 25 deletions
diff --git a/evil-commands.el b/evil-commands.el
index c036ddd..0dd4ea8 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2343,30 +2343,32 @@ when called interactively."
(setq macro (evil-get-register register t)
evil-last-register register)))
(list count macro)))
- (cond
- ((functionp macro)
- (evil-repeat-abort)
- (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")))
- (t
- (condition-case err
- (evil-with-single-undo
- (dotimes (_ (or count 1))
- (execute-kbd-macro macro)
- (when (eq 'evil-execute-in-normal-state last-command)
- (evil-change-state evil--execute-normal-return-state))))
- ;; enter Normal state if the macro fails
- (error
- (evil-normal-state)
- (evil-normalize-keymaps)
- (signal (car err) (cdr err)))))))
+ (let ((last-insertion-temp evil-last-insertion))
+ (cond
+ ((functionp macro)
+ (evil-repeat-abort)
+ (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")))
+ (t
+ (condition-case err
+ (evil-with-single-undo
+ (dotimes (_ (or count 1))
+ (execute-kbd-macro macro)
+ (when (eq 'evil-execute-in-normal-state last-command)
+ (evil-change-state evil--execute-normal-return-state)))
+ (setq evil-last-insertion last-insertion-temp))
+ ;; enter Normal state if the macro fails
+ (error
+ (evil-normal-state)
+ (evil-normalize-keymaps)
+ (signal (car err) (cdr err))))))))
;;; Visual commands
@@ -4722,7 +4724,10 @@ Restore the disabled repeat hooks on insert-state exit."
(not (memq this-command '(evil-insert
evil-goto-mark))))
(forward-char))
- (unless (eq 'replace evil-state)
+ (when (eq 'evil-paste-from-register this-command)
+ (evil-move-cursor-back t))
+ (unless (or (memq evil-state '(replace insert))
+ (eq 'evil-normal-state this-command))
(evil-change-state ',evil-state))
(when (eq 'insert evil-state)
(remove-hook 'pre-command-hook 'evil-repeat-pre-hook)