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

3

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.

Diffidence answered 25/2, 2013 at 8:45 Comment(0)
B
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.

Bradeord answered 25/2, 2013 at 9:6 Comment(2)
Thanks turned to sr-speedbar nowDiffidence
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.Birth
S
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
Selfsacrifice answered 24/4, 2013 at 18:46 Comment(0)
A
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.

Abisha answered 26/11, 2018 at 3:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.