GNU bug report logs - #22295
viper-mode undo bug introduced between Nov 10 and Nov 14

Previous Next

Package: emacs;

Reported by: Jim Meyering <jim <at> meyering.net>

Date: Sun, 3 Jan 2016 04:03:01 UTC

Severity: normal

Fixed in version 25.1

Done: phillip.lord <at> russet.org.uk (Phillip Lord)

Bug is archived. No further changes may be made.

Full log


Message #148 received at 22295 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: phillip.lord <at> russet.org.uk (Phillip Lord)
Cc: Eli Zaretskii <eliz <at> gnu.org>, 22295 <at> debbugs.gnu.org,
 Jim Meyering <jim <at> meyering.net>, Michael Kifer <kifer <at> cs.stonybrook.edu>
Subject: Re: bug#22295: viper-mode undo bug introduced between Nov 10 and Nov
 14
Date: Fri, 10 Jun 2016 13:05:22 -0400
>> 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 ()




This bug report was last modified 8 years and 346 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.