(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)
(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
(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)
;; 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
(delete-char 1 t)
(insert char))
- (viper-complete-complex-command-for-undo)
+ (viper-adjust-undo)
(backward-char arg)
))