7

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.

Nate W.
  • 9,141
  • 6
  • 43
  • 65
jilen
  • 5,633
  • 3
  • 35
  • 84

3 Answers3

8

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.

PascalVKooten
  • 20,643
  • 17
  • 103
  • 160
  • Thanks turned to sr-speedbar now – jilen Feb 26 '13 at 01:41
  • 2
    Even if you have sr-speedbar installed but still used plain old speedbar, this is still the correct answer. Even if you `M-x speedbar` (instead of `M-x sr-speedbar-open`, running `M-x sr-speedbar-refresh-turn-off` will work either way. – Mason Stewart Feb 03 '15 at 20:01
8

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
bwroga
  • 5,379
  • 2
  • 23
  • 25
0

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.

campisano
  • 229
  • 2
  • 10