Function: revert-buffer-with-fine-grain

revert-buffer-with-fine-grain is an interactive and byte-compiled function defined in files.el.gz.

Signature

(revert-buffer-with-fine-grain &optional IGNORE-AUTO NOCONFIRM)

Documentation

Revert buffer preserving markers, overlays, etc.

This command is an alternative to revert-buffer because it tries to be as non-destructive as possible, preserving markers, properties and overlays. Binds revert-buffer-insert-file-contents-function to the function revert-buffer-insert-file-contents-delicately.

With a prefix argument, offer to revert from latest auto-save file. For more details on the arguments, see revert-buffer.

View in manual

Probably introduced at or before Emacs version 28.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun revert-buffer-with-fine-grain (&optional ignore-auto noconfirm)
  "Revert buffer preserving markers, overlays, etc.
This command is an alternative to `revert-buffer' because it tries to be as
non-destructive as possible, preserving markers, properties and overlays.
Binds `revert-buffer-insert-file-contents-function' to the function
`revert-buffer-insert-file-contents-delicately'.

With a prefix argument, offer to revert from latest auto-save file.  For more
details on the arguments, see `revert-buffer'."
  ;; See revert-buffer for an explanation of this.
  (interactive (list (not current-prefix-arg)))
  ;; Simply bind revert-buffer-insert-file-contents-function to the specialized
  ;; function, and call revert-buffer.
  (let ((revert-buffer-insert-file-contents-function
         #'revert-buffer-insert-file-contents-delicately))
    (revert-buffer ignore-auto noconfirm t)
    ;; This closure is defined in revert-buffer-insert-file-contents-function.
    ;; It is needed because revert-buffer--default always returns t after
    ;; reverting, and it might be needed to report the success/failure of
    ;; reverting delicately.
    (when (fboundp 'revert-buffer-with-fine-grain-success-p)
      (prog1
          (revert-buffer-with-fine-grain-success-p)
        (fmakunbound 'revert-buffer-with-fine-grain-success-p)))))