[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] fix/viper-undo 841dd0e: First attempt to fix viper undo bu
From: |
Phillip Lord |
Subject: |
[Emacs-diffs] fix/viper-undo 841dd0e: First attempt to fix viper undo bug #22295 |
Date: |
Mon, 16 May 2016 09:33:56 +0000 (UTC) |
branch: fix/viper-undo
commit 841dd0e6abb8c1f10b3461532b6f7b6223032f1e
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>
First attempt to fix viper undo bug #22295
---
lisp/emulation/viper-cmd.el | 39 ++++++++++++---------------------------
lisp/simple.el | 13 ++++++++-----
2 files changed, 20 insertions(+), 32 deletions(-)
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 93cf3b0..39819a8 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -293,6 +293,10 @@
;; Change state to NEW-STATE---either emacs-state, vi-state, or insert-state.
(defun viper-change-state (new-state)
+ (if (eq new-state 'emacs-state)
+ (setq undo-auto-disable-boundaries nil)
+ (setq undo-auto-disable-boundaries t))
+
;; Keep viper-post/pre-command-hooks fresh.
;; We remove then add viper-post/pre-command-sentinel since it is very
;; desirable that viper-pre-command-sentinel is the last hook and
@@ -1671,6 +1675,7 @@ invokes the command before that, etc."
(undo-start)
(undo-more 2)
+ (viper-adjust-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)
@@ -1711,36 +1716,16 @@ invokes the command before that, etc."
;; In VI, unlike Emacs, if you open a line, say, and add a bunch of lines,
;; they are undone all at once.
(defun viper-adjust-undo ()
- (if viper-undo-needs-adjustment
- (let ((inhibit-quit t)
- tmp tmp2)
- (setq viper-undo-needs-adjustment nil)
- (if (listp buffer-undo-list)
- (if (setq tmp (memq viper-buffer-undo-list-mark buffer-undo-list))
- (progn
- (setq tmp2 (cdr tmp)) ; the part after mark
-
- ;; cut tail from buffer-undo-list temporarily by direct
- ;; manipulation with pointers in buffer-undo-list
- (setcdr tmp nil)
-
- (setq buffer-undo-list (delq nil buffer-undo-list))
- (setq buffer-undo-list
- (delq viper-buffer-undo-list-mark buffer-undo-list))
- ;; restore tail of buffer-undo-list
- (setq buffer-undo-list (nconc buffer-undo-list tmp2)))
- (setq buffer-undo-list (delq nil buffer-undo-list)))))
- ))
+ (setq viper-undo-needs-adjustment nil)
+ (setq buffer-undo-list
+ (cons nil buffer-undo-list)))
(defun viper-set-complex-command-for-undo ()
- (if (listp buffer-undo-list)
- (if (not viper-undo-needs-adjustment)
- (let ((inhibit-quit t))
- (setq buffer-undo-list
- (cons viper-buffer-undo-list-mark buffer-undo-list))
- (setq viper-undo-needs-adjustment t)))))
-
+ (if (not viper-undo-needs-adjustment)
+ (setq viper-undo-needs-adjustment t)
+ (setq buffer-undo-list
+ (cons nil buffer-undo-list))))
;;; Viper's destructive Command ring utilities
diff --git a/lisp/simple.el b/lisp/simple.el
index 97b40bd..bf3c4d4 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2839,6 +2839,8 @@ buffers that were changed during the last command.")
If set to non-nil, this will effectively disable the timer.")
+(defvar-local undo-auto-disable-boundaries nil)
+
(defvar undo-auto--this-command-amalgamating nil
"Non-nil if `this-command' should be amalgamated.
This variable is set to nil by `undo-auto--boundaries' and is set
@@ -2878,7 +2880,8 @@ REASON describes the reason that the boundary is being
added; see
(dolist (b undo-auto--undoably-changed-buffers)
(when (buffer-live-p b)
(with-current-buffer b
- (undo-auto--ensure-boundary cause))))
+ (unless undo-auto-disable-boundaries
+ (undo-auto--ensure-boundary cause)))))
(setq undo-auto--undoably-changed-buffers nil))
(defun undo-auto--boundary-timer ()
@@ -2905,10 +2908,10 @@ See also `undo-auto--buffer-undoably-changed'.")
"Add an `undo-boundary' in appropriate buffers."
(undo-auto--boundaries
(let ((amal undo-auto--this-command-amalgamating))
- (setq undo-auto--this-command-amalgamating nil)
- (if amal
- 'amalgamate
- 'command))))
+ (setq undo-auto--this-command-amalgamating nil)
+ (if amal
+ 'amalgamate
+ 'command))))
(defun undo-auto-amalgamate ()
"Amalgamate undo if necessary.