speedbar - how to fix the base directory (not change as buffer switched)

2k views Asked by At

After using speedbar for a while, I found it will change the base directory according to currently displayed buffer.

How do I disable it? I just want the speedbar do nothing while I am switching to another buffer.

3

There are 3 answers

2
PascalVKooten On BEST ANSWER

I don't think this behavior is possible in plain Speedbar (After looking at variables, functions and the customization window).

However, if you check out the SrSpeedbar package, I see an option: “sr-speedbar-refresh-turn-off”. Once called, it should disable refreshing; sticking to wherever it is at.

0
campisano On

In addition to the correct @PascalVKooten answer, there is a annoying problem when you navigate in the speedbar tree: you lost the start directory. The follow code helps to go back to the initial directory using the 'h' key in the speedbar frame:

  (setq var_start-path default-directory)

  (define-key speedbar-file-key-map (kbd "h")
                  (lambda() (interactive)
                    (when (and (not (equal var_start-path
                                           sr-speedbar-last-refresh-dictionary))
                               (not (sr-speedbar-window-p)))
                      (setq sr-speedbar-last-refresh-dictionary var_start-path))
                    (setq default-directory var_start-path)
                    (speedbar-refresh))
                  )

This code is extracted from the projectile-speedbar package code. This package is interesting but it is not working for me.

0
bwroga On

This is possible. Add this to your .emacs file:

(set 'speedbar-update-flag nil)

You can also toggle updating with

M-x speedbar-toggle-updates