master 7e0a4494646: vc-dir-mode: Delay call to vc-dir-refresh until after mode hooks

Sean Whitton <[email protected]> Thu, 23 Jul 2026 12:35:20 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: master
commit 7e0a44946469539eb5bb6b342b452c323d6c4a19
Author: Sean Whitton <[email protected]>
Commit: Sean Whitton <[email protected]>

    vc-dir-mode: Delay call to vc-dir-refresh until after mode hooks
    
    * lisp/vc/vc-dir.el (vc-dir-mode): Delay call to vc-dir-refresh
    until after mode hooks, using :after-hook.
---
 lisp/vc/vc-dir.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index b95e613ec2d..deac4cde4a9 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -1475,6 +1475,11 @@ commands act on the child files of that directory that are displayed in
 the *vc-dir* buffer.
 
 \\{vc-dir-mode-map}"
+  ;; Delay the initial refresh until after mode hooks so that any minor
+  ;; modes are activated before the calls to `substitute-command-keys'
+  ;; in `vc-dir-headers'.  Then any bindings shadowed by minor modes
+  ;; won't be included in the key binding hints.
+  :after-hook (let (buffer-read-only) (vc-dir-refresh))
   (setq-local vc-dir-backend use-vc-backend)
   (setq-local desktop-save-buffer 'vc-dir-desktop-buffer-misc-data)
   (setq-local bookmark-make-record-function #'vc-dir-bookmark-make-record)
@@ -1482,7 +1487,7 @@ the *vc-dir* buffer.
   (setq buffer-read-only t)
   (when (boundp 'tool-bar-map)
     (setq-local tool-bar-map vc-dir-tool-bar-map))
-  (let ((buffer-read-only nil))
+  (let (buffer-read-only)
     (erase-buffer)
     (setq-local vc-dir-process-buffer nil)
     (setq-local vc-ewoc (ewoc-create #'vc-dir-printer))
@@ -1492,8 +1497,7 @@ the *vc-dir* buffer.
     ;; Make sure that if the directory buffer is killed, the update
     ;; process running in the background is also killed.
     (add-hook 'kill-buffer-query-functions #'vc-dir-kill-query nil t)
-    (hack-dir-local-variables-non-file-buffer)
-    (vc-dir-refresh)))
+    (hack-dir-local-variables-non-file-buffer)))
 
 (defvar-keymap vc-dir-outgoing-revisions-map
   :doc "Local keymap for viewing outgoing revisions."