3

I use sr-speedbar in emacs. On loading, it starts in file mode. I then manually change it to buffers mode. Since I almost always use buffers mode, I would prefer to start it in that. However, I cannot find any way after googling and wondering if someone with Lisp expertise has inputs on how to resolve this

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
doon
  • 2,311
  • 7
  • 31
  • 52
  • There is no such thing as `buffers-mode`. If you would like help from anyone who is not necessarily familiar with `speedbar`, then consider adding to your question exactly what command you use to enable what you call buffers mode. – lawlist Jun 03 '15 at 16:43
  • @lawlist : if you right click on speedbar - you will see options of files/quick buffers and buffers. That is what I was referring to – doon Jun 04 '15 at 05:29
  • How about?: `(setq speedbar-initial-expansion-list-name "quick buffers")` or `(setq speedbar-initial-expansion-list-name "buffers")`, whichever you prefer. The default is `files`. No need to use any hooks in this circumstance. – lawlist Jun 04 '15 at 06:18
  • That works. Thanks. If you can post this as an answer, I will mark it as accepted. Thanks a lot !! – doon Jun 08 '15 at 13:05

2 Answers2

4

The variable speedbar-initial-expansion-list-name controls the initial view of speedbar. The default value is "files". The other two possibilities are "quick buffers" or "buffers" -- either of the following could be placed in the .emacs file after a (require 'speedbar) statement:

(setq speedbar-initial-expansion-list-name "quick buffers")

or

(setq speedbar-initial-expansion-list-name "buffers")
lawlist
  • 13,099
  • 3
  • 49
  • 158
1

The sr-speedbar is a package built on speedbar, so you need to consider customizing speedbar itself as well. There is no existing customization option for what you want but you can implement youself by using Hook, in your case, speedbar-mode-hook.

The following should do what you want

(add-hook 'speedbar-mode-hook
          (lambda ()
            (speedbar-change-initial-expansion-list "quick buffers")))

I copy it from https://stackoverflow.com/a/24291661/2999892 and I've test it by using both speedbar and sr-speedbar.

Community
  • 1
  • 1
xuchunyang
  • 919
  • 7
  • 12
  • Sorry this is not working for me. I am using emacs 24 on ubuntu 14.04. I added the hook, reloaded .emacs. I still see speedbar in file mode. Then I restarted emacs - same result. Thanks for the answer. I at least understand the speedbar-mode-hook – doon Jun 04 '15 at 05:23
  • I should mention that when I M-x speedbar-change-initial-expansion-list quick buffers , the buffers list does change. However, the setting is not stored somehow. I do see the same code at http://www.emacswiki.org/emacs/speedbar-extension.el also. So the question now is how to make this persistent across emacs sessions. – doon Jun 04 '15 at 05:28
  • According to lawlist's comment, you just need to add `(setq speedbar-initial-expansion-list-name "quick buffers")` to your .emacs. – xuchunyang Jun 04 '15 at 07:05