SrSpeedbar

SrSpeedbar is a mode that makes SpeedBar show in the Current Frame, by SebastianRose.

Install

Put Lisp:sr-speedbar.el in your load-path, and add
        (require 'sr-speedbar)
in ~/.emacs

Usage

sr-speedbar-openOpen sr-speedbar window.
sr-speedbar-closeClose sr-speedbar window.
sr-speedbar-toggleToggle sr-speedbar window.
sr-speedbar-select-windowselect sr-speedbar window.
sr-speedbar-refresh-turn-onTurn on refresh speedbar content.
sr-speedbar-refresh-turn-offTurn off refresh speedbar content.
sr-speedbar-refresh-toggleToggle refresh speedbar content.

(If it simply duplicates the current buffer the first time you open it, make sure you’ve closed normal SpeedBar’s frame first.)

Customize

All below setup can customize by: M-x customize-group RET sr-speedbar RET

sr-speedbar-width-xThe sr-speedbar window width under WINDOW system.
sr-speedbar-width-consoleThe sr-speedbar window width under CONSOLE.
sr-speedbar-max-widthThe max window width allowed remember.
sr-speedbar-delete-windowsWhether delete other window before showing up.
sr-speedbar-skip-other-window-pWhether skip sr-speedbar window when use command other-window select window in cyclic ordering of windows.
sr-speedbar-auto-refreshControl status of refresh speedbar content.

Screenshot

This is screenshot by SebastianRose:

SrSpeedbarInXterm

This is screenshot by AndyStewart:

MultiTermDedicatedShotPage

Discussion

How can I disable the icons? I only want ASCII, even in GUI Emacs.

Answer:

(setq speedbar-use-images nil)

– Charles Strahan


Can I set the default font size for just the sr-speedbar buffer to something other than my other buffers/windows? I tried setting default-frame-alist as suggested by the speedbar-article, but that just caused all my frames to change font size whenever speedbar spawns. It wold be nice if sr-speedbar could default to a small font so that I can get a better overview over large code bases easily.

To answer my own question, I read the wikipage on FacesPerBuffer and came up with this:

(make-face 'speedbar-face)
(set-face-font 'speedbar-face "Inconsolata-12")
(setq speedbar-mode-hook '(lambda () (buffer-face-set 'speedbar-face)))

which solved my problem.

– Jeff


Even with (setq sr-speedbar-skip-other-window-p t) in .emacs file, the behavior of delete-other-windows is still weird in current version of sr-speedbar.el. In detail, suppose 2 windows opened, in either of them ^ X 1, there is still chance to select the SPEEDBAR window to be active, which is not usually the user want – the user want the original window be selected. After some experiment, I come up with following elisp code to further advice delete-other-windows not to select the SPEEDBAR window.

(defadvice delete-other-windows (after my-sr-speedbar-delete-other-window-advice activate)
  "Check whether we are in speedbar, if it is, jump to next window."
  (let ()
	(when (and (sr-speedbar-window-exist-p sr-speedbar-window)
               (eq sr-speedbar-window (selected-window)))
      (other-window 1)
	)))
(ad-enable-advice 'delete-other-windows 'after 'my-sr-speedbar-delete-other-window-advice)
(ad-activate 'delete-other-windows)

just place them after the elisp lines you use to load sr-speedbar.

– liyu1981


How to keep speed bar window width after resizing?

add

(with-current-buffer sr-speedbar-buffer-name
  (setq window-size-fixed 'width))

to your .emacs after calling

sr-speedbar-open

— Chen Xian’an


How to integrate sr-speedbar with ERC’s erc-speedbar-browser?


There is a bug when using multiple frames

C-x 5 2

C-x 5 o (I’m in origial frame with speedbar)

C-x 5 o (I’m in 2nd frame without speedbar)

Now when I page up and page down it also moves the first frame.

I don’t get this when using regular speedbar. It seems like multiple sr-speedbars would be desired (one for each window).


With emacs 24.4+, ad-advised-definition-p function has been removed. You can add it back to fix the problem:

(defun ad-advised-definition-p (definition)
  "Return non-nil if DEFINITION was generated from advice information."
  (if (or (ad-lambda-p definition)
	  (macrop definition)
	  (ad-compiled-p definition))
      (let ((docstring (ad-docstring definition)))
	(and (stringp docstring)
	     (get-text-property 0 'dynamic-docstring-function docstring)))))

I’m not versed enough in emacs lisp to modify the sr-speedbar code to use some other function.

Hope it helps.


Make Sr-speedbar open files in the next window, instead of in the previous window:

(defun select-next-window ()
  (other-window 1))

(defun my-sr-speedbar-open-hook ()
  (add-hook 'speedbar-before-visiting-file-hook 'select-next-window t)
  (add-hook 'speedbar-before-visiting-tag-hook 'select-next-window t)
  )

(advice-add 'sr-speedbar-open :after #'my-sr-speedbar-open-hook)

Sr-speedbar doesn't appear to control Speedbar:

I had this problem using Emacs on OSX (25.1) and found the solution here: http://emacs-leuven.readthedocs.io/en/stable/#speedbar-frames

With a little modification from their code, put this in your init.el:

(require 'sr-speedbar)
;; fix so speedbar is in same window
(with-eval-after-load "speedbar"
  (autoload 'sr-speedbar-toggle "sr-speedbar" nil t)
  (global-set-key (kbd "s-s") 'sr-speedbar-toggle)
  )

CategoryNavigation