Skip to content

Instantly share code, notes, and snippets.

@ffevotte
Last active August 24, 2017 03:15
Show Gist options
  • Save ffevotte/d7e69cf147c014381003 to your computer and use it in GitHub Desktop.
Save ffevotte/d7e69cf147c014381003 to your computer and use it in GitHub Desktop.
Complement to SO answer: "How do I make the compilation window in Emacs to always be a certain size?" (http://stackoverflow.com/a/9728357/1225607)
(defun my-select-bottom-window ()
(let ((bottom-window (selected-window))
window-below)
(while (setq window-below (window-in-direction 'below bottom-window))
(setq bottom-window window-below))
(select-window bottom-window)))
(defun my-compilation-hook ()
(when (not (get-buffer-window "*compilation*"))
(save-selected-window
(save-excursion
(my-select-bottom-window)
(let* ((w (split-window-vertically))
(h (window-height w)))
(select-window w)
(switch-to-buffer "*compile5*")
(shrink-window (- h compilation-window-height)))))))
(add-hook 'compilation-mode-hook 'my-compilation-hook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment