Emacs: Set Default Path for speedbar
speedbar uses the folder of the file that is associated with the current buffer
as the default path. For example, if I open speedbar when
editing ~/.emacs.d/dotEmacs/init.el , it will display files
under ~/.emacs.d/dotEmacs/ . However, I use dired-jump to achieve a similar
functionality, and for me speedbar is a simple project explorer, so I hope it
could open a certain folder once activated.
The solution is simply appending a cd expression to the speedbar-mode-hook:
1: (add-hook 'speedbar-mode-hook 2: (lambda () 3: (cd "~/code/openerp/")))
Note : Please replace ~/code/openerp/ with the path you wanted to
set. Also, if you have (speedbar-disable-update)
(it disables auto refreshing
for speedbar) in the speedbar-mode-hook, you’ll need to place the cd
expression before it, otherwise speedbar will switch to correct folder but
display the wrong content.
Thanks for the help from jrx on #emacs.
Happy Hacking!