mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Update VC-Dir contents upon revert-buffer
* lisp/vc/vc-hooks.el (vc-after-revert): New function. (after-revert-hook): Add it.
This commit is contained in:
parent
d0d6e5ce65
commit
208241aa83
2 changed files with 17 additions and 9 deletions
|
|
@ -7212,23 +7212,24 @@ preserve markers and overlays, at the price of being slower."
|
|||
The arguments IGNORE-AUTO and NOCONFIRM are as described for `revert-buffer'.
|
||||
Runs the hooks `before-revert-hook' and `after-revert-hook' at the
|
||||
start and end.
|
||||
The function returns non-nil if it reverts the buffer; signals
|
||||
an error if the buffer is not associated with a file.
|
||||
The function returns non-nil if it reverts the buffer, and signals an
|
||||
error if the buffer is not associated with a file.
|
||||
|
||||
Calls `revert-buffer-insert-file-contents-function' to reread the
|
||||
contents of the visited file, with two arguments: the first is the file
|
||||
name, the second is non-nil if reading an auto-save file.
|
||||
|
||||
This function handles only buffers that are visiting files.
|
||||
Non-file buffers need a custom function."
|
||||
Non-file buffers need a custom `revert-buffer-function'; see
|
||||
`revert-buffer'."
|
||||
(with-current-buffer (or (buffer-base-buffer (current-buffer))
|
||||
(current-buffer))
|
||||
(let* ((auto-save-p (and (not ignore-auto)
|
||||
(recent-auto-save-p)
|
||||
buffer-auto-save-file-name
|
||||
(file-readable-p buffer-auto-save-file-name)
|
||||
(y-or-n-p
|
||||
"Buffer has been auto-saved recently. Revert from auto-save file? ")))
|
||||
(y-or-n-p "Buffer has been auto-saved recently. \
|
||||
Revert from auto-save file? ")))
|
||||
(file-name (if auto-save-p
|
||||
buffer-auto-save-file-name
|
||||
buffer-file-name)))
|
||||
|
|
@ -7254,8 +7255,8 @@ Non-file buffers need a custom function."
|
|||
;; Effectively copy the after-revert-hook status,
|
||||
;; since after-find-file will clobber it.
|
||||
(let ((global-hook (default-value 'after-revert-hook))
|
||||
(local-hook (when (local-variable-p 'after-revert-hook)
|
||||
after-revert-hook))
|
||||
(local-hook (and (local-variable-p 'after-revert-hook)
|
||||
after-revert-hook))
|
||||
(inhibit-read-only t))
|
||||
;; FIXME: Throw away undo-log when preserve-modes is nil?
|
||||
(funcall
|
||||
|
|
@ -7270,8 +7271,7 @@ Non-file buffers need a custom function."
|
|||
;; Run after-revert-hook as it was before we reverted.
|
||||
(setq-default revert-buffer-internal-hook global-hook)
|
||||
(if local-hook
|
||||
(setq-local revert-buffer-internal-hook
|
||||
local-hook)
|
||||
(setq-local revert-buffer-internal-hook local-hook)
|
||||
(kill-local-variable 'revert-buffer-internal-hook))
|
||||
(run-hooks 'revert-buffer-internal-hook))
|
||||
t)))))
|
||||
|
|
|
|||
|
|
@ -751,6 +751,14 @@ Before doing that, check if there are any old backups and get rid of them."
|
|||
(when vc-dir-buffers
|
||||
(vc-dir-resynch-file file))))
|
||||
|
||||
(defun vc-after-revert ()
|
||||
"Update VC-Dir contents after reverting a buffer from disk."
|
||||
(when-let* (vc-dir-buffers
|
||||
(backend (vc-backend buffer-file-name)))
|
||||
(vc-dir-resynch-file buffer-file-name)))
|
||||
|
||||
(add-hook 'after-revert-hook #'vc-after-revert)
|
||||
|
||||
(defvar vc-menu-entry
|
||||
'(menu-item "Version Control" vc-menu-map
|
||||
:filter vc-menu-map-filter))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue