From 1278a9a907e59b22d8e20a806055c7cb92959017 Mon Sep 17 00:00:00 2001 From: Mauro Aranda Date: Sun, 20 Sep 2020 01:04:39 +0200 Subject: New command: revert-buffer-with-fine-grain * doc/emacs/files.texi (Reverting): Document the new command and the new variable. * etc/NEWS: Mention the new command and the new variable. * lisp/files.el (revert-buffer-with-fine-grain): New command. Revert a buffer trying to be non-destructive, by using replace-buffer-contents. (revert-buffer-insert-file-contents-delicately): New function, alternative to revert-buffer-insert-file-contents-function--default-function. (revert-buffer-with-fine-grain-max-seconds): New variable. Passed as argument MAX-SECS of replace-buffer-contents. * test/lisp/files-tests.el (files-tests-lao files-tests-tzu): Helper variables, taken from diffutils manual, to test reverting a buffer. (files-tests-revert-buffer) (files-tests-revert-buffer-with-fine-grain): New tests (bug#18). --- doc/emacs/files.texi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'doc/emacs/files.texi') diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 2fa1ecc003d..51e8bd1382f 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -921,6 +921,7 @@ Manual}). For customizations, see the Custom group @code{time-stamp}. @node Reverting @section Reverting a Buffer @findex revert-buffer +@findex revert-buffer-with-fine-grain @cindex drastic changes @cindex reread a file @@ -941,6 +942,19 @@ reverted changes as a single modification to the buffer's undo history aliases to bring the reverted changes back, if you happen to change your mind. +@vindex revert-buffer-with-fine-grain-max-seconds + To revert a buffer more conservatively, you can use the command +@code{revert-buffer-with-fine-grain}. This command acts like +@code{revert-buffer}, but it tries to be as non-destructive as +possible, making an effort to preserve all markers, properties and +overlays in the buffer. Since reverting this way can be very slow +when you have made a large number of changes, you can modify the +variable @code{revert-buffer-with-fine-grain-max-seconds} to +specify a maximum amount of seconds that replacing the buffer +contents this way should take. Note that it is not ensured that the +whole execution of @code{revert-buffer-with-fine-grain} won't take +longer than this. + Some kinds of buffers that are not associated with files, such as Dired buffers, can also be reverted. For them, reverting means recalculating their contents. Buffers created explicitly with -- cgit v1.2.3