Now showing

Emacs: control where buffers are displayed (the 'display-buffer-alist')

Documentaries & Learning2024Creative Commons
Poster for Emacs: control where buffers are displayed (the 'display-buffer-alist')

About this film

In this ~30 minute video I show how to tell Emacs where to place specific buffers. The idea is to have a set of rules that specify how you want Emacs to make use of the available space in the frame and which windows to use. Below I show some basic code samples. For more advanced uses, refer to my relevant section in Emacs configuration: https://protesilaos.com/emacs/dotemacs#h:50f8b1e4-b14e-453f-a37e-1c0e495ab80f . Sample code with basic rules (setq display-buffer-alist '( ;; The added space is for didactic purposes ;; Each entry in this list has this anatomy: ;; ( BUFFER-MATCHING-RULE ;; LIST-OF-DISPLAY-BUFFER-FUNCTIONS ;; OPTIONAL-PARAMETERS) ;; Match a buffer whose name is "*Occur*". We have to escape ;; the asterisks to match them literally and not as a special ;; regular expression character. ("\\*Occur\\*" ;; If a buffer with the matching major-mode exists in some ;; window, then use that one. Otherwise, display the buffer ;; below the current window. (display-buffer-reuse-mode-window display-buffer-below-selected) ;; Then we have the parameters... (dedicated . t) (window-height . fit-window-to-buffer)) )) ;; If you want `switch-to-buffer' and related to respect those rules ;…

Directors & creators

Protesilaos Stavrou

View on archive.org ↗

More from this pool

Documentaries & Learning

See all →