From: wgreenhouse-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org (W. Greenhouse)
To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org
Subject: Re: Reverting but keeping undo
Date: Thu, 16 May 2013 05:29:38 +0000 [thread overview]
Message-ID: <87sj1neblp.fsf@riseup.net> (raw)
In-Reply-To: 87mwrwede7.fsf@wanadoo.es
Óscar Fuentes <ofv-39ZsbGIQGT7e5aOfsHch1g@public.gmane.org> writes:
> `revert-buffer' discards undo history. I can understand that undo
> history might be in conflict with the new contents of the buffer. How
> dangerous is that? Apart from that, what could be wrong with using the
> recipe published in
>
> http://www.emacswiki.org/emacs/RevertBuffer#toc4
>
> ?
>
> For your convenience, this is the recipe:
>
> (defun revert-buffer-keep-undo (&rest -)
> "Revert buffer but keep undo history."
> (interactive)
> (let ((inhibit-read-only t))
> (erase-buffer)
> (insert-file-contents (buffer-file-name))
> (set-visited-file-modtime (visited-file-modtime))
> (set-buffer-modified-p nil)))
>
> Install in command ‘revert-buffer’ with
>
> (setq revert-buffer-function 'revert-buffer-keep-undo)
This looks like a nice simple hack, but it doesn't do half of the things
that revert-buffer does, such as resetting local variables and possibly
picking a different major mode and file encoding if the change in file
contents warrants it. From looking at the code of `revert-buffer', this
problem could be solved without getting rid of all those nice features
if you put an advice around revert-buffer that stashed
`buffer-undo-list' away inside a let-bound variable before revertying,
and then reset `buffer-undo-list' from that variable afterwards.
--
BOFH excuse #453:
Spider infestation in warm case parts
next prev parent reply other threads:[~2013-05-16 5:29 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 10:38 Reverting but keeping undo Óscar Fuentes
2013-05-16 5:29 ` W. Greenhouse [this message]
2013-05-16 15:10 ` Óscar Fuentes
2013-05-29 1:52 ` Stefan Monnier
2013-05-29 3:09 ` Drew Adams
2013-05-29 3:27 ` Dmitry Gutov
2013-05-29 5:13 ` Drew Adams
2013-05-29 12:26 ` Dmitry Gutov
2013-05-29 13:55 ` Drew Adams
2013-05-29 15:21 ` Dmitry Gutov
2013-05-29 16:33 ` Drew Adams
2013-05-29 17:51 ` Dmitry Gutov
[not found] ` <mailman.605.1369845207.22516.help-gnu-emacs@gnu.org>
2013-05-29 18:42 ` Dan Espen
2013-05-29 13:48 ` Stefan Monnier
[not found] ` <mailman.562.1369804408.22516.help-gnu-emacs@gnu.org>
2013-05-29 13:25 ` Dan Espen
2013-05-29 16:26 ` Drew Adams
2013-05-30 18:48 ` Michael Heerdegen
2013-05-30 18:41 ` Michael Heerdegen
2013-05-30 19:19 ` Óscar Fuentes
2013-05-30 21:26 ` Stefan Monnier
2013-05-30 22:05 ` Michael Heerdegen
[not found] ` <mailman.728.1369951538.22516.help-gnu-emacs@gnu.org>
2013-05-30 23:59 ` Dan Espen
2013-05-31 0:58 ` Stefan Monnier
[not found] ` <mailman.738.1369961954.22516.help-gnu-emacs@gnu.org>
2013-05-31 1:21 ` Dan Espen
2013-05-31 2:28 ` Drew Adams
2013-05-31 16:05 ` Michael Heerdegen
2013-05-31 18:29 ` Óscar Fuentes
[not found] ` <mailman.767.1370016367.22516.help-gnu-emacs@gnu.org>
2013-05-31 17:22 ` Dan Espen
2013-05-31 18:08 ` Barry Margolin
[not found] ` <mailman.699.1369939338.22516.help-gnu-emacs@gnu.org>
2013-05-30 18:45 ` Barry Margolin
-- strict thread matches above, loose matches on Subject: below --
2013-05-31 16:49 Barry OReilly
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sj1neblp.fsf@riseup.net \
--to=wgreenhouse-sgozh3hwpm2stnjn9+bgxg@public.gmane.org \
--cc=help-gnu-emacs-mXXj517/zsQ@public.gmane.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.