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?

1
  • 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. stackoverflow.com/questions/18346785/… 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).... emacs.stackexchange.com/a/15118/2287
    – lawlist
    Jun 24, 2019 at 21:13

2 Answers 2

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.

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
2
  • Wow, this looks proomising! Will try it out and report back. Thanks heaps!
    – halloleo
    Jul 15, 2021 at 7:58
  • How did you get on, @halloleo ?
    – phils
    Apr 10, 2022 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.