[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14
From: |
Stefan Monnier |
Subject: |
bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14 |
Date: |
Fri, 10 Jun 2016 13:05:22 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
>> The old code seemed "simple" enough that the problem was probably
>> simple to fix (once identified).
> Well, most problems are simple to fix once you actually know what they
> are.
The problem seems to be the following: when you hit ESC, Viper will remove
boundaries from the undo-list, without making any changes to the buffer,
so the top-level loop won't add a boundary before the next command and
ends up hence "amalgamating" the next command with the previous one.
In the old code, we just always blindly added a boundary to
current-buffer before running a command, whereas now we only do so if
the buffer has been modified since the last time we pushed a boundary.
I think the patch below fixes the original problem.
Another way to fix it would be to change undo-auto--add-boundary so it
always considers (current-buffer) regardless of
undo-auto--undoably-changed-buffers.
Stefan
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 93cf3b0..ca52f98 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -1715,7 +1715,8 @@ viper-adjust-undo
(let ((inhibit-quit t)
tmp tmp2)
(setq viper-undo-needs-adjustment nil)
- (if (listp buffer-undo-list)
+ (when (listp buffer-undo-list)
+ (let ((had-boundary (null (car buffer-undo-list))))
(if (setq tmp (memq viper-buffer-undo-list-mark buffer-undo-list))
(progn
(setq tmp2 (cdr tmp)) ; the part after mark
@@ -1729,8 +1730,11 @@ viper-adjust-undo
(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 buffer-undo-list (delq nil buffer-undo-list)))
+ ;; The top-level loop only adds boundaries if there has been
+ ;; modifications in the buffer, so make sure we don't accidentally
+ ;; drop the "final" boundary (bug#22295).
+ (if had-boundary (undo-boundary)))))))
(defun viper-set-complex-command-for-undo ()
- bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14, Stefan Monnier, 2016/06/01
- bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14,
Stefan Monnier <=
- bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14, Eli Zaretskii, 2016/06/11
- bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14, Phillip Lord, 2016/06/13
- bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14, Stefan Monnier, 2016/06/14
- bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14, Jim Meyering, 2016/06/15
- bug#22295: viper-mode undo bug introduced between Nov 10 and Nov 14, Michael Kifer, 2016/06/15