views:

246

answers:

2

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?

+1  A: 

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)))))
Trey Jackson
I know the terminology, and I'm actually looking for a logical emacs window, as opposed to a physical one.
Josh Matthews
+2  A: 

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)))
Török Gábor