Commit ba5c8c93 authored by Karl Heuer's avatar Karl Heuer
Browse files

(revert-buffer): Save after-revert-hook (both local and

global values) before reverting, and run the saved values at the end.
parent b7d19f4a
......@@ -2005,7 +2005,13 @@ beginning and `after-revert-hook' at the end."
;; Get rid of all undo records for this buffer.
(or (eq buffer-undo-list t)
(setq buffer-undo-list nil))
(let ((buffer-read-only nil)
;; Effectively copy the after-revert-hook status,
;; since after-find-file will clobber it.
(let ((global-hook (default-value 'after-revert-hook))
(local-hook-p (local-variable-p 'after-revert-hook))
(local-hook (and (local-variable-p 'after-revert-hook)
(let (buffer-read-only
;; Don't make undo records for the reversion.
(buffer-undo-list t))
(if revert-buffer-insert-file-contents-function
......@@ -2027,7 +2033,14 @@ beginning and `after-revert-hook' at the end."
(setq buffer-file-truename
(abbreviate-file-name (file-truename buffer-file-name)))
(after-find-file nil nil t t)
(run-hooks 'after-revert-hook)
;; Run after-revert-hook as it was before we reverted.
(setq-default revert-buffer-internal-hook global-hook)
(if local-hook-p
(make-local-variable 'revert-buffer-internal-hook)
(setq revert-buffer-internal-hook local-hook))
(kill-local-variable 'revert-buffer-internal-hook))
(run-hooks 'revert-buffer-internal-hook))
(defun recover-file (file)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment