I love using speedbar (specificall I use sr-speedbar) but I'm having a hard time configuring it to my liking. One thing I'd like to be able to do, is set it so that there's an "anchor" directory, such that even if I open its subdirectories or files, the speedbar should always show me the view from that directory, rather than from the level I'm currently at.

Let me explain: currently if I'm in directory "usr" and (within speedbar) I open the subdirectory "my-name" and then the file "something.txt", the speedbar will update its view so that the top line is "path/to/usr/my-name" and it shows the contents of the "my-name" folder. But what if I want to stay at the top-level view, so that the top line is still just "path/to/usr/" and speedbar just shows me the opened directory "my-name" with its contents, as well as the other contents of "usr"?

I hope my explanation makes sense. I've been having a hard time trying to verbalize this so I haven't had much luck searching for a solution on the web, and I've been poking around at the source code but couldn't clearly figure out what mechanism speedbar uses to update its view.

Please feel free to offer some pointers or full solutions. Ideally I'm looking for some simple elisp code that could do the job, and not a full package to add to my config (as it seems like it'd be a simple enough change). Thanks in advace!

  • How about expanding the folders with the SPC spacebar key, bound to speedbar-toggle-line-expansion?
    – lawlist
    Aug 16, 2022 at 19:25
  • @lawlist that is PRECISELY what I needed. I knew it wasn't as complicated as it seemed. Thank you so much! Aug 16, 2022 at 22:14

1 Answer 1


Expansion/contraction of folders, and also expansion/contraction of imenu entries for certain files (if applicable), may be accomplished by pressing SPC (spacebar key) -- bound by default to speedbar-toggle-line-expansion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.