bug#81559: 31.0.91; speedbar does not follow Dired and shell-dirtrack-mode

Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Eli Zaretskii <[email protected]> writes:

>> From: Daniel Mendler <[email protected]>
>> Cc: [email protected]
>> Date: Wed, 05 Aug 2026 19:26:41 +0200
>> 
>> Eli Zaretskii <[email protected]> writes:
>> 
>> >> Date: Wed, 05 Aug 2026 17:40:01 +0200
>> >> From: Daniel Mendler via "Bug reports for GNU Emacs,
>> >>  the Swiss army knife of text editors" <[email protected]>
>> >> 
>> >> The speedbar does not follow the current shell directory, nor does it
>> >> follow the current directory in Dired. In order to test:
>> >> 
>> >> 1. emacs -Q
>> >> 2. M-x speedbar
>> >> 3. M-x shell and then cd to change directories => speedbar does not follow
>> >> 4. M-x dired, chose various directories => speedbar does not follow
>> >
>> > Did Speedbar ever react to Dired and shell directory changes?  If yes,
>> > in which version of Emacs?  If it never did, this is a request for an
>> > enhancement, right?  And I think the way to add such an enhancement is
>> > described the node "Extending" of the Speedbar manual.
>> 
>> Yes, as far as I can tell, this has never worked. It is a feature
>> request.
>
> Thanks, marked it as such.  Patches welcome.

The following simple patch ensures that Speedbar reacts also on buffers
which are not backed by files (e.g. Shell with dirtrack mode or Dired).
This should go to the master branch and we might want to guard it behind
an option (e.g., speedbar-update-file-buffer). Eli, what do you think?

Daniel
0001-PATCH-speedbar-Also-follow-non-file-buffers-based-on.patch (text/x-diff, 950 B)
From 243b9caa467148fcf565291a4596a87d8892e7e9 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <[email protected]>
Date: Sun, 9 Aug 2026 18:02:58 +0200
Subject: [PATCH] speedbar: Also follow non-file buffers based on
 default-directory

Speedbar updates when invoking cd in shell (dirtrack-mode) and
Dired. bug#81559

* lisp/speedbar.el (speedbar-timer-fn): Check for default-directory
instead of buffer-file-name.
---
 lisp/speedbar.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 3e965d4286c..d9e1acd19f1 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -2789,7 +2789,7 @@ speedbar-timer-fn
 				 (and
 				  (eq af (speedbar-current-frame))
 				  (speedbar-window-current-window))
-				 (not (buffer-file-name)))
+				 (not default-directory))
 			     ;; Always update for GUD.
 			     (not (string-equal "GUD"
 						speedbar-initial-expansion-list-name)))
-- 
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.