bug#81613: [PATCH] Make vc-dir use display-buffer instead of pop-to-buffer

Protesilaos <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Dear maintainers,

I was trying to control the placement of "*vc-dir*" buffers via the
'display-buffer-alist' but I could not get the expected results. Then
I looked at the source code to find that 'M-x vc-dir' relies on
'pop-to-buffer'. The attached patch includes the small change we need
to get 'vc-dir' to conform with 'display-buffer-alist'.

All the best,
Protesilaos (or simply "Prot")
0001-Make-vc-dir-use-display-buffer-instead-of-pop-to-buf.patch (text/x-diff, 2.7 KB)
From 588a5fee1c6004c0bab5d58668ee8bc69c25d1f7 Mon Sep 17 00:00:00 2001
Message-ID: <588a5fee1c6004c0bab5d58668ee8bc69c25d1f7.1786618343.git.info@protesilaos.com>
From: Protesilaos <[email protected]>
Date: Thu, 13 Aug 2026 13:52:04 +0300
Subject: [PATCH] Make vc-dir use display-buffer instead of pop-to-buffer

* etc/NEWS: Announce the change.
* lisp/vc/vc-dir.el (vc-dir): Use 'display-buffer' and make the
necessary changes.
---
 etc/NEWS          |  3 +++
 lisp/vc/vc-dir.el | 26 ++++++++++++++------------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 43c667647e1..08ce410be5e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -197,6 +197,9 @@ has a VC backend.  If it doesn't, but the directory's truename does
 have a backend, and 'vc-follow-symlinks' is non-nil, the truename is
 used instead.  Previously, the truename was used unconditionally.
 
+---
+*** VC-Dir buffer conforms with 'display-buffer-alist'
+
 +++
 *** Improved creation of commit log entry from ChangeLog.
 When VC detects that all log entries for the current changeset come from
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index d75dce77493..8c95135773b 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -2027,18 +2027,20 @@ (defun vc-dir (dir &optional backend)
 	  nil t nil nil)))))
   (unless backend
     (setq backend (vc-responsible-backend dir)))
-  (let (pop-up-windows)		      ; based on cvs-examine; bug#6204
-    (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend)))
-  (if (derived-mode-p 'vc-dir-mode)
-      (vc-dir-refresh)
-    ;; FIXME: find a better way to pass the backend to `vc-dir-mode'.
-    (let ((use-vc-backend backend))
-      (vc-dir-mode)
-      ;; Activate the backend-specific minor mode, if any.
-      (when-let* ((minor-mode
-                   (intern-soft (format "vc-dir-%s-mode"
-                                        (downcase (symbol-name backend))))))
-        (funcall minor-mode 1)))))
+  (let ((pop-up-windows)		      ; based on cvs-examine; bug#6204
+        (buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend)))
+    (with-current-buffer buffer
+      (if (derived-mode-p 'vc-dir-mode)
+          (vc-dir-refresh)
+        ;; FIXME: find a better way to pass the backend to `vc-dir-mode'.
+        (let ((use-vc-backend backend))
+          (vc-dir-mode)
+          ;; Activate the backend-specific minor mode, if any.
+          (when-let* ((minor-mode
+                       (intern-soft (format "vc-dir-%s-mode"
+                                            (downcase (symbol-name backend))))))
+            (funcall minor-mode 1)))))
+    (display-buffer buffer)))
 
 (defun vc-default-dir-extra-headers (_backend _dir)
   ;; Be loud by default to remind people to add code to display
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.