unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: 49869@debbugs.gnu.org
Subject: bug#49869: Revert buffer?  Yes/No/Maybe
Date: Fri, 06 Aug 2021 09:20:03 +0300	[thread overview]
Message-ID: <83tuk3hz70.fsf@gnu.org> (raw)
In-Reply-To: <87bl6bcw6s.fsf@mail.linkov.net> (message from Juri Linkov on Fri, 06 Aug 2021 02:33:55 +0300)

> From: Juri Linkov <juri@linkov.net>
> Cc: 49869@debbugs.gnu.org
> Date: Fri, 06 Aug 2021 02:33:55 +0300
> 
> > And second, are you talking only about reverting when there are no
> > unsaved changes?  If so, what are the use cases when you need to do
> > such a thing, and why?  Perhaps such use cases justify a separate
> > command and key binding, like "C-x RET r" does for one such use case.
> 
> I discovered this problem while editing source code in one
> Emacs instance, and updating the source file in `emacs -Q`.
> To get an updated version of the file in `emacs -Q` required
> typing 4 more keys after every revert.

If this is a frequent use case, we could have a separate command for
it.

> >> But when the user decided to revert the buffer explicitly,
> >> why require to type more keys?
> >
> > In general, when there are unsaved changes?  To let the user think one
> > last time before doing something potentially very destructive.
> 
> The question was why require typing more keys
> when there are no unsaved changes.

In the use case you described, depending on the situation, you could
still be in danger of losing important parts of the buffer text, even
though you have no unsaved changes.  E.g., imagine that for some
reason the file on disk is empty or omits most of your current buffer
contents.  Wouldn't you in general want at least the check for size
differences between the two, with a request for confirmation if the
sizes differ too much?  And maybe also time stamp differences?

IOW, this use case seems to really call for a separate command with a
separate logic.  If we provide such a command, then perhaps we could
make it omit the confirmation prompt when invoked with C-u, for those
cases where you know in advance you want to revert unconditionally,
for example if it was you who made the external changes just now.

But I don't think it makes sense to tweak the general-purpose
revert-buffer command in this direction, as revert-buffer supports
many other use cases, where this kind of shortcut could produce
disastrous results.





      reply	other threads:[~2021-08-06  6:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04  8:45 bug#49869: Revert buffer? Yes/No/Maybe Juri Linkov
2021-08-04  9:02 ` Lars Ingebrigtsen
2021-08-04 10:06   ` Gregory Heytings
2021-08-04  9:03 ` Andreas Schwab
2021-08-04 12:05 ` Eli Zaretskii
2021-08-04 12:22   ` Gregory Heytings
2021-08-04 12:23     ` Eli Zaretskii
2021-08-04 12:37       ` Gregory Heytings
2021-08-04 12:53         ` Eli Zaretskii
2021-08-04 13:30           ` Gregory Heytings
2021-08-05 10:43           ` Lars Ingebrigtsen
2021-08-05 11:08             ` Gregory Heytings
2021-08-06  9:21               ` Lars Ingebrigtsen
2021-08-10  7:12                 ` Juri Linkov
2021-08-10 14:40                   ` bug#49869: [External] : " Drew Adams
2021-08-10 14:41                   ` Lars Ingebrigtsen
2021-08-04 20:43   ` Juri Linkov
2021-08-05  5:48     ` Eli Zaretskii
2021-08-05 23:33       ` Juri Linkov
2021-08-06  6:20         ` Eli Zaretskii [this message]

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=83tuk3hz70.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=49869@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /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).