X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/0bf5739b77c75f13d46fc49d5e3c098fe49a5070..99fe98d37a39d26f5dea424926d0e0a082655fe5:/lisp/emulation/viper-cmd.el diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 72fc89817a..3ce1b4d6a7 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -631,7 +631,7 @@ (viper-over-whitespace-line)) (indent-to-left-margin)) (viper-add-newline-at-eob-if-necessary) - (viper-complete-complex-command-for-undo) + (viper-adjust-undo) (if (eq viper-current-state 'emacs-state) (viper-restore-cursor-color 'after-emacs-mode) @@ -1570,7 +1570,7 @@ If the prefix argument ARG is non-nil, it is used instead of `val'." (if (and (eolp) (not (bolp))) (backward-char 1)) )) - (viper-complete-complex-command-for-undo) ; take care of undo + (viper-adjust-undo) ; take care of undo ;; If the prev cmd was rotating the command ring, this means that `.' has ;; just executed a command from that ring. So, push it on the ring again. ;; If we are just executing previous command , then don't push viper-d-com @@ -1670,7 +1670,6 @@ invokes the command before that, etc." (undo-start) (undo-more 2) - (viper-complete-complex-command-for-undo) ;;(setq undo-beg-posn (or undo-beg-posn (point)) ;; undo-end-posn (or undo-end-posn (point))) ;;(setq undo-beg-posn (or undo-beg-posn before-undo-pt) @@ -1710,17 +1709,21 @@ invokes the command before that, etc." ;; The following two functions are used to set up undo properly. ;; In VI, unlike Emacs, if you open a line, say, and add a bunch of lines, ;; they are undone all at once. -(defun viper-complete-complex-command-for-undo () - (setq undo-auto-disable-boundaries nil) - (setq viper-undo-in-complex-command nil) - (undo-boundary)) +(viper-deflocalvar viper--undo-change-group-handle nil) +(put 'viper--undo-change-group-handle 'permanent-local t) +(defun viper-adjust-undo () + (when viper--undo-change-group-handle + (undo-amalgamate-change-group + (prog1 viper--undo-change-group-handle + (setq viper--undo-change-group-handle nil))))) (defun viper-set-complex-command-for-undo () - (when (not viper-undo-in-complex-command) - (setq undo-auto-disable-boundaries t) - (setq viper-undo-in-complex-command t) - (undo-boundary))) + (and (listp buffer-undo-list) + (not viper--undo-change-group-handle) + (setq viper--undo-change-group-handle + (prepare-change-group)))) + ;;; Viper's destructive Command ring utilities @@ -2588,7 +2591,7 @@ These keys are ESC, RET, and LineFeed." (delete-char 1 t) (insert char)) - (viper-complete-complex-command-for-undo) + (viper-adjust-undo) (backward-char arg) ))