GNU bug report logs - #8447
Undoing M-x revert-buffer

Previous Next

Package: emacs;

Reported by: Hrvoje Nikšić <hniksic <at> gmail.com>

Date: Fri, 8 Apr 2011 16:17:02 UTC

Severity: wishlist

Merged with 10776

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8447 in the body.
You can then email your comments to 8447 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8447; Package emacs. (Fri, 08 Apr 2011 16:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Hrvoje Nikšić <hniksic <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 08 Apr 2011 16:17:02 GMT) Full text and rfc822 format available.

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

From: Hrvoje Nikšić <hniksic <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Undoing M-x revert-buffer
Date: Fri, 8 Apr 2011 17:54:21 +0200
It would be nice to be able to undo a revert-buffer operation.

I've just had a situation where I used M-x revert-buffer, and
immediately wanted to see the old version again.  (I wanted to briefly
compare the old and new contents, which only differed in several
characters.)  I routinely pressed C-_, and got a "no undo data" message
in the echo area.  For the shortest instant I was surprised, but I
quickly remembered that M-x revert-buffer clears the undo stack, and
that it has always worked that way.

But I would like to question this design choice.  What I wanted to do
was not really unreasonable.  The buffer held several kilobytes of data,
and my computer has gigabytes of memory at its disposal, enough room to
hold the buffer contents literally a million times over.  If you think
about it, reverting an existing buffer is just another operation on
buffer text, not that different than M-x erase-buffer followed by M-x
insert-file, which would happily remember everything.

If the maintainers agree in principle, I'd like to look into patching
revert-buffer so it records the revert as it would any other change to
the buffer text.

Hrvoje




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8447; Package emacs. (Sat, 09 Apr 2011 01:51:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Hrvoje Nikšić <hniksic <at> gmail.com>
Cc: 8447 <at> debbugs.gnu.org
Subject: Re: bug#8447: Undoing M-x revert-buffer
Date: Fri, 08 Apr 2011 22:49:54 -0300
> It would be nice to be able to undo a revert-buffer operation.

So do I.  I've been using a local patch to do that, actually.  IIRC back
when I wrote it, RMS opposed the change.  I think my change only
affected the "revert while keeping the same major-mode" such as the
revert performed silently by auto-revert-mode and VC operations.  It has
bit-rotted somewhat, but I remember that the current code works hard at
forgetting the undo data (it does it once at the Lisp level and another
time inside insert-file-contents).


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8447; Package emacs. (Tue, 12 Apr 2011 04:26:01 GMT) Full text and rfc822 format available.

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

From: Kevin Rodgers <kevin.d.rodgers <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#8447: Undoing M-x revert-buffer
Date: Mon, 11 Apr 2011 22:25:39 -0600
On 4/8/11 9:54 AM, Hrvoje Nikšić wrote:
> It would be nice to be able to undo a revert-buffer operation.
>
> I've just had a situation where I used M-x revert-buffer, and
> immediately wanted to see the old version again.  (I wanted to briefly
> compare the old and new contents, which only differed in several
> characters.)  I routinely pressed C-_, and got a "no undo data" message
> in the echo area.  For the shortest instant I was surprised, but I
> quickly remembered that M-x revert-buffer clears the undo stack, and
> that it has always worked that way.
>
> But I would like to question this design choice.  What I wanted to do
> was not really unreasonable.  The buffer held several kilobytes of data,
> and my computer has gigabytes of memory at its disposal, enough room to
> hold the buffer contents literally a million times over.  If you think
> about it, reverting an existing buffer is just another operation on
> buffer text, not that different than M-x erase-buffer followed by M-x
> insert-file, which would happily remember everything.
>
> If the maintainers agree in principle, I'd like to look into patching
> revert-buffer so it records the revert as it would any other change to
> the buffer text.

In the short term, or if the maintainers do not agree to Hrvoje's proposal,
how about adding a warning to the "Revert buffer from file FILE? " yes-or-no-p
prompt?

-- 
Kevin Rodgers
Denver, Colorado, USA





Merged 8447 10776. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 10 Feb 2012 03:08:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8447; Package emacs. (Wed, 29 May 2013 01:11:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 8447 <at> debbugs.gnu.org
Subject: Re: Undoing M-x revert-buffer
Date: Tue, 28 May 2013 21:08:47 -0400
I just installed into the trunk a patch which should make
revert-buffer undoable.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8447; Package emacs. (Wed, 29 May 2013 03:18:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>, 8447 <at> debbugs.gnu.org
Subject: RE: bug#8447: Undoing M-x revert-buffer
Date: Tue, 28 May 2013 20:15:49 -0700 (PDT)
> I just installed into the trunk a patch which should make
> revert-buffer undoable.

FWIW, see my comment on this in the help list:
http://lists.gnu.org/archive/html/help-gnu-emacs/2013-05/msg00671.html

In sum, why?  And why no discussion?  Where was the "bug"?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8447; Package emacs. (Wed, 29 May 2013 06:17:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Cc: Stefan Monnier <monnier <at> IRO.UMontreal.CA>,
	Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#8447: Undoing M-x revert-buffer
Date: Wed, 29 May 2013 08:17:27 +0200
Am 29.05.2013 05:15, schrieb Drew Adams:
>> I just installed into the trunk a patch which should make
>> revert-buffer undoable.
>
> FWIW, see my comment on this in the help list:
> http://lists.gnu.org/archive/html/help-gnu-emacs/2013-05/msg00671.html
>
> In sum, why?  And why no discussion?  Where was the "bug"?
>
>
>
>

Hi Drew,

as it happened, run sometimes into this:
reverting the buffer, which turned out not the right thing - but undo-history was lost.
Consider it a useful change, thanks.

Andreas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8447; Package emacs. (Wed, 29 May 2013 13:30:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
	bug-gnu-emacs <at> gnu.org
Cc: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: RE: bug#8447: Undoing M-x revert-buffer
Date: Wed, 29 May 2013 06:27:40 -0700 (PDT)
> >> I just installed into the trunk a patch which should make
> >> revert-buffer undoable.
> >
> > FWIW, see my comment on this in the help list:
> > http://lists.gnu.org/archive/html/help-gnu-emacs/2013-05/msg00671.html
> >
> > In sum, why?  And why no discussion?  Where was the "bug"?

> as it happened, run sometimes into this:
> reverting the buffer, which turned out not the right thing - but undo-
> history was lost. Consider it a useful change, thanks.

By "turned out not the right thing" I guess you mean that someone used `revert-buffer' interactively and by mistake.  And by mistake also _confirmed_ reverting.  Yes, it can happen (to anyone).

So define a command `revert-buffer-keeping-undo', and use that interactively instead of `revert-buffer'.  Or define a variable (option or internal) `revert-buffer-keeps-undo'.

What you cite is a user-interface issue - i.e., only for interactive use of the command.  Such a change, to safeguard against mistaken reverting, is akin to removing files to a trash bin instead of deleting them.  But we did not just willy nilly change the behavior of the basic function (command) `delete-file' when we added support for a recycle/trash bin.  That's not the right approach.

With extra interactive protection as the only reason, this is also akin to some users (me, for instance) wanting `C-w' to prompt for confirmation if the region is over a certain size (as in wimpy-del.el).  Certainly such safeguard features can be useful.

But this change goes way beyond offering users optional extra protection.  `revert-buffer' is also used in basic code.

The right way to add such protection against mistaken reversion is to create a separate command or option, letting users choose to use it or not.  And leave the basic `revert-buffer' alone.

FWIW, I agree that such a feature can be useful for reverting interactively.

And why no discussion before making such a change?




bug marked as fixed in version 24.4, send any further explanations to 8447 <at> debbugs.gnu.org and Hrvoje Nikšić <hniksic <at> gmail.com> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 29 May 2013 15:23:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8447; Package emacs. (Thu, 30 May 2013 16:57:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: bug-gnu-emacs <at> gnu.org, Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: Re: bug#8447: Undoing M-x revert-buffer
Date: Thu, 30 May 2013 18:57:33 +0200
Am 29.05.2013 15:27, schrieb Drew Adams:
>>>> I just installed into the trunk a patch which should make
>>>> revert-buffer undoable.
>>>
>>> FWIW, see my comment on this in the help list:
>>> http://lists.gnu.org/archive/html/help-gnu-emacs/2013-05/msg00671.html
>>>
>>> In sum, why?  And why no discussion?  Where was the "bug"?
>
>> as it happened, run sometimes into this:
>> reverting the buffer, which turned out not the right thing - but undo-
>> history was lost. Consider it a useful change, thanks.
>
> By "turned out not the right thing" I guess you mean that someone used `revert-buffer' interactively and by mistake.  And by mistake also _confirmed_ reverting.  Yes, it can happen (to anyone).
>
> So define a command `revert-buffer-keeping-undo', and use that interactively instead of `revert-buffer'.  Or define a variable (option or internal) `revert-buffer-keeps-undo'.
>
> What you cite is a user-interface issue - i.e., only for interactive use of the command.  Such a change, to safeguard against mistaken reverting, is akin to removing files to a trash bin instead of deleting them.  But we did not just willy nilly change the behavior of the basic function (command) `delete-file' when we added support for a recycle/trash bin.  That's not the right approach.
>
> With extra interactive protection as the only reason, this is also akin to some users (me, for instance) wanting `C-w' to prompt for confirmation if the region is over a certain size (as in wimpy-del.el).  Certainly such safeguard features can be useful.
>
> But this change goes way beyond offering users optional extra protection.  `revert-buffer' is also used in basic code.
>
> The right way to add such protection against mistaken reversion is to create a separate command or option, letting users choose to use it or not.  And leave the basic `revert-buffer' alone.
>
> FWIW, I agree that such a feature can be useful for reverting interactively.
>
> And why no discussion before making such a change?
>

Hi Drew,

thanks, okay, you are right opposing it then. Mistook the matter so far.

Cheers,

Andreas





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 28 Jun 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 326 days ago.

Previous Next


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