unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Phillip Lord" <phillip.lord@russet.org.uk>
To: "Stefan Monnier" <monnier@iro.umontreal.ca>
Cc: acm@muc.de, 23785@debbugs.gnu.org, phillip.lord@russet.org.uk
Subject: bug#23785: Emacs 25: 'Undo' overdoes things.
Date: Sun, 19 Jun 2016 23:45:44 +0100	[thread overview]
Message-ID: <adeb26a2b322f2e73c614048f518ab98.squirrel@cloud103.planethippo.com> (raw)
In-Reply-To: <jwv7fdm5l8g.fsf-monnier+emacsbugs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1230 bytes --]

On Sat, June 18, 2016 8:52 pm, Stefan Monnier wrote:
>> My concern is not with the behavior the proposed change intends to get
>> us, the concern is with the unintended consequences of the change.  At
>> this late stage, I'd like to keep the risk of unintended consequences to
>> the minimum, unless we want this change so badly we agree to extend the
>> pretesting by another month or two.
>
> Yes, that's the other side of the coin, indeed.


Attached are another two patches which also solve the issue.

One adds an undo boundary specifically in revert-buffer. Works but is
questionable in that revert-buffer is pluggable -- it can call any
function, other than the default.

The other fiddles with insert-file-contents and adds an undo. It is this
function that has specialized handling for the undo list that is causing
the problem. My patch in this case is questionable in that I have randomly
pushed a call to undo-boundary near the end. It should probably be
somewere better.

Another possibility would be to have insert-file-contents call
"undo-auto--undoable-change" -- this is the root cause of the problem.
Changes are happening.

Also attached is a test case which demonstrates the problem.

So many possibilities!



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-missing-undo-boundary-after-revert-buffer.patch --]
[-- Type: text/x-patch; name="0001-Fix-missing-undo-boundary-after-revert-buffer.patch", Size: 1006 bytes --]

From 4250d150cfce6cd461dc6475bac08d7587842e84 Mon Sep 17 00:00:00 2001
From: Phillip Lord <phillip.lord@russet.org.uk>
Date: Sun, 19 Jun 2016 21:34:58 +0100
Subject: [PATCH] Fix missing undo-boundary after revert-buffer

 - lisp/files.el (revert-buffer): Ensure an undo-boundary after
   completion.

Addresses Bug#23785
---
 lisp/files.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index 1f97fa5..c5d2bab 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5533,7 +5533,10 @@ revert-buffer
   (let ((revert-buffer-in-progress-p t)
         (revert-buffer-preserve-modes preserve-modes))
     (funcall (or revert-buffer-function #'revert-buffer--default)
-             ignore-auto noconfirm)))
+             ignore-auto noconfirm)
+    ;; Ensure that we have a undo-boundary after reversion (see Bug
+    ;; #23785)
+    (undo-boundary)))
 
 (defun revert-buffer--default (ignore-auto noconfirm)
   "Default function for `revert-buffer'.
-- 
2.9.0

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-Fix-missing-undo-boundary-on-revert.patch --]
[-- Type: text/x-patch; name="0001-Fix-missing-undo-boundary-on-revert.patch", Size: 858 bytes --]

From 1b2cd06f4b6f993052632e24c50209816314c004 Mon Sep 17 00:00:00 2001
From: Phillip Lord <phillip.lord@russet.org.uk>
Date: Sun, 19 Jun 2016 23:33:22 +0100
Subject: [PATCH] Fix missing undo-boundary on revert

But badly, because I have pushed the undo_boundary call into a fairly
random place in a very long function.
---
 src/fileio.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/fileio.c b/src/fileio.c
index b11f923..e01045e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4500,6 +4500,10 @@ by calling `format-decode', which see.  */)
                              current_buffer->newline_cache,
                              PT - BEG, Z - PT - inserted);
 
+  /* Random push an undo boundary here because I don't know where else
+     to put this call */
+  Fundo_boundary();
+
   if (read_quit)
     Fsignal (Qquit, Qnil);
 
-- 
2.9.0

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: revert-buffer-tests.el --]
[-- Type: text/x-emacs-lisp; name="revert-buffer-tests.el", Size: 338 bytes --]

(require 'ert)

(ert-deftest undo-after-revert-buffer ()
  (should-not
   (unwind-protect
       (progn
         (find-file "simple-file.txt")
         (goto-char (point-min))
         (insert "\n")
         (revert-buffer t t)
         (undo-auto--needs-boundary-p))
     (kill-buffer
      (get-file-buffer
       "simple-file.txt")))))

[-- Attachment #5: simple-file.txt --]
[-- Type: text/plain, Size: 9 bytes --]

line one

  reply	other threads:[~2016-06-19 22:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 15:02 bug#23785: Emacs 25: "Undo" overdoes things Alan Mackenzie
2016-06-17 17:15 ` Eli Zaretskii
2016-06-17 17:45   ` Alan Mackenzie
2016-06-17 20:07     ` Eli Zaretskii
2016-06-17 21:47       ` Phillip Lord
2016-06-18  4:46         ` Stefan Monnier
2016-06-18  7:54         ` Eli Zaretskii
2016-06-18 18:42           ` Stefan Monnier
2016-06-18 19:02             ` Eli Zaretskii
2016-06-18 19:52               ` Stefan Monnier
2016-06-19 22:45                 ` Phillip Lord [this message]
2016-06-20  0:59                   ` bug#23785: Emacs 25: 'Undo' " Stefan Monnier
2016-06-20 12:47                     ` Phillip Lord
2016-06-20 14:04                       ` Stefan Monnier
2016-06-20 15:03                   ` Phillip Lord
2016-06-20 15:34                     ` Eli Zaretskii
2016-06-20 17:12                       ` Phillip Lord
2016-06-21 13:17                         ` Eli Zaretskii
2016-06-21 14:30                           ` Phillip Lord
2016-06-21 21:25                         ` Stefan Monnier
2016-06-21 22:08                           ` Phillip Lord
2020-09-04 14:03                             ` Lars Ingebrigtsen
2020-09-05 13:15                               ` Alan Mackenzie
2016-06-21 13:18                     ` Eli Zaretskii
2016-06-21 14:29                       ` Phillip Lord
2016-06-21 16:13                         ` Eli Zaretskii
2016-06-17 21:23     ` bug#23785: Emacs 25: "Undo" " Phillip Lord
2016-06-18 17:41       ` Alan Mackenzie
2016-06-17 21:49     ` Óscar Fuentes
2016-06-20 12:33       ` Phillip Lord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adeb26a2b322f2e73c614048f518ab98.squirrel@cloud103.planethippo.com \
    --to=phillip.lord@russet.org.uk \
    --cc=23785@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).