1

So it occurs offen that the full path always exceeds sr-speedbar window width. Is there a way to hack sr-speedbar to display the fully path seperately in a sufficient long bar or wrap the path if it exceeds the window width?

enter image description here

Done by adding the following to my init file:

(add-hook 'speedbar-mode-hook (lambda () (setq truncate-lines nil)))

Was having a hard time to make it also happen in spacemacs, but in case someone has the same issue, note the wrapping will become ineffective when other setttings are present, so better add all the sr-speedbar settings in hooks altogether:

(defun startup_layout ()
        (setq sr-speedbar-right-side nil sr-speedbar-width 50)
        (sr-speedbar-toggle)
        (with-current-buffer sr-speedbar-buffer-name (setq window-size-fixed 'width))
    (other-window 1)
)
(add-hook 'emacs-startup-hook 'startup_layout)
(add-hook 'speedbar-mode-hook (lambda () (setq truncate-lines nil)))

And also put in user-init instead of user config.

Knowing Problem:

When sr-speedbar-width is set less than 50, the name of path cannot be wrapped.

1
  • BTW, Emacs code usually follows the GNU convention to keep the name "path" for a list of directories (as in $PATH, load-path, ...) and use "file name" for what you called "path".
    – Stefan
    Dec 17, 2016 at 15:56

1 Answer 1

1

This has nothing to do with sr-speedbar.el, but rather speedbar.el. The former is a hack/modification of the latter. Try (add-hook 'speedbar-mode-hook (lambda () (setq truncate-lines nil))) and see if that has the desired effect. If we type M-x find-function RET speedbar-mode RET and examine the code, we will see that it expressly states (setq truncate-lines t) -- this is the behavior that needs modification using something akin to the above-mentioned code. However, long directory/filenames underneath will also be wrapped at the window edge with this new setting. [A visual cue as to what is happening is the right arrow in the full path in the screen-shot -- this is a bitmap indicating this is a continuation line made possible by virtue of the variable truncate-lines being set to t. That bitmap image can be changed or eliminated, but it is beyond the scope of the question.]

The screenshot provided by the original poster shows two distinct windows within one frame. The answer to the question of whether the directory name at the top of the speedbar window can span across the screen to occupy the position of the second window on the right, is "no" (sorry).


One idea, if the original poster is so inclined, would be to spend time modifying the speedbar.el library to force the frame-title to update with the full path and eliminate the full path from the speedbar window. However, the user would lose functionality of having that full path within the window itself -- e.g., to jump to a specific previous parent directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.