toggle-scroll-bar to show scrollbar on my frame. But is there a way to show scrollbar only on the selected buffer?
I think I can use
focus-in-hook to detect when a buffer is active, but I don't know how to show scrollbar on it.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
This works for me on Emacs 27.0.50:
(defun update-scroll-bars () (interactive) (mapc (lambda (win) (set-window-scroll-bars win nil)) (window-list)) (set-window-scroll-bars (selected-window) 10 'right)) (add-hook 'window-configuration-change-hook 'update-scroll-bars) (add-hook 'buffer-list-update-hook 'update-scroll-bars)
window-configuration-change-hook runs whenever you add or remove windows (i.e.,
C-x k) and
buffer-list-update-hook runs when you select a different window among the ones already present (i.e.,
C-x b). Using both seems to get the scroll bar changing consistently when I expect it to.
I don't actually use the scroll bar myself, but this provides a nice visual cue as to which window is selected.