1

I want the *compilation* buffer to not pop up in my main frame when I have it in another frame already open. However if the buffer is not shown anywhere, I do want it to pop up in a new window of the main frame.

I have set special-display-regexps:

(setq special-display-regexps (list "\\*compilation\\*.*"))

And this somewhat works: The compilation buffer does not open in a new window when it's displayed in another frame, so far so good, but, if it is not displayed anywhere it is opened in a brand new frame - and I do not want this.

Any idea how I can tweak this?

halloleo
  • 1,215
  • 9
  • 23
  • Here is a link to a semi-related thread where I target a specific frame for buffers matching a particular criteria, creating the frame if it does not already exist. https://stackoverflow.com/questions/18346785/how-to-intercept-a-file-before-it-opens-and-decide-which-frame You would need a custom function to meet your specified criteria outlined in the question above. Here is a link to a custom `my-display-buffer` function to target a specific window within a frame or create a new window (there are 3 built-in conditions).... https://emacs.stackexchange.com/a/15118/2287 – lawlist Jun 24 '19 at 21:13

2 Answers2

1

Not a real answer, but some info that might help.

You will likely need to fiddle with display-buffer-alist (good luck!). Someone here will no doubt help with that.

You cannot use special-display-regexps or special-display-buffer-names alone to do what you want - they're designed for the simple behavior you described: use (and reuse) an existing window, and if there is none then use a new frame.

A poor man's workaround would be to first create a *compilation* window on your "main" frame, and then do the special-display-* thing. If a window showing the buffer already exists somewhere (anywhere) then it will be reused. If such a window does not exist then the buffer will be displayed in a new frame.

Drew
  • 75,699
  • 9
  • 109
  • 225
0

Try this:

;; Prefer existing frames already displaying *compilation*.
(add-to-list 'display-buffer-alist
             (cons "\\`\\*compilation\\*\\'"
                   (cons 'display-buffer-reuse-window
                         '((reusable-frames . visible)
                           (inhibit-switch-frame . nil)))))

For more information, refer to:

  • C-hf display-buffer-reuse-window
  • C-hv display-buffer-alist
  • C-hig (elisp)Displaying Buffers
phils
  • 48,657
  • 3
  • 76
  • 115