My Current Compilation Window Display Settings in Emacs via display-buffer-alist
For the longest time, I had my compilation buffers split to the right in a rather large window.
Until I started programming in Emacs.
Previously, I looked at LaTeX build outputs, or the static site generator’s progress. That was it. Lots of logged text, so I wanted the space.
But compiling C++ or Swift code compulsively, as I do, this got on my nerves really quick. So here’s a more normal configuration, showing compilation-mode
buffers in a 25% bottom split “side window” (essentially a sidebar, but anywhere).
(defun ct/display-buffer-compilation-mode-p (buffer-name action)
"Determine whether BUFFER-NAME is a compilation buffer."
(with-current-buffer buffer-name
(or
(eq 'compilation-mode (buffer-local-value 'major-mode (current-buffer)))
(string-match (rx "*[Cc]ompilation*")
buffer-name))))
(add-to-list 'display-buffer-alist
'(ct/display-buffer-compilation-mode-p
(display-buffer-at-bottom
display-buffer-in-side-window)
(window-height . 0.25)
(side . bottom)
(slot . -6)))
I’m not matching for (derived-mode-p 'compilation-mode)
because that also catches rg.el
and ag.el
buffers. (I used to auto-hide compilation buffers and got terribly confused and annoyed that my search results wouldn’t show anymore.)
I still make Emacs Lisp compile warning windows not show at all, via https://protesilaos.com/codelog/2024-11-28-basic-emacs-configuration/:
(add-to-list 'display-buffer-alist
'("\\`\\*\\(Warnings\\|Compile-Log\\)\\*\\'"
(display-buffer-no-window)
(allow-no-window . t)))
Ah, and as of today, I’ve tagged all my posts including display-buffer-alist
because I’ll definitely tweak these again and again.