Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make the compilation log create a new window in Emacs?

If I only have one window showing in emacs and use M-x compile, the window splits in two and I can watch the compile buffer easily. However, if I have more windows showing, the compilation log takes over one of the others, which I find irritating. How can I make emacs always split a new window to show the compilation log?

Edit: A bit more information from my reading that I've been doing. It looks like compile.el calls display-buffer, which only splits a window if it is current full width. Is there some way to avoid this behaviour?

like image 959
Josh Matthews Avatar asked Jan 24 '23 17:01

Josh Matthews


2 Answers

You may modify the solution provided by Trey Jackson to fit your needs.

The following snippet marks buffer *compilation* as special, and sets a customized function as its display function to split current window even if already in a split window.

(setq special-display-buffer-names
      '("*compilation*"))

(setq special-display-function
      (lambda (buffer &optional args)
        (split-window)
        (switch-to-buffer buffer)
        (get-buffer-window buffer 0)))
like image 182
viam0Zah Avatar answered Jan 26 '23 05:01

viam0Zah


If what you're wanting is a dedicated top-level window (Emacs calls these frames), then this will do the trick for you. This snippet includes placement directives, but customizing the 'special-display-buffer-names variable will get you what you want.

(setq special-display-buffer-names
      `(("*compilation*" . ((name . "*compilation*")
                            ,@default-frame-alist
                            (left . (- 1))
                            (top . 0)))))
like image 31
Trey Jackson Avatar answered Jan 26 '23 06:01

Trey Jackson