1

I work with different Emacs frames on the same desktop. When I run compile Emacs splits the current frame and creates a clone of the buffer *compilation*, although the compilation buffer is already visible, but just in another frame. After that I see the same compilation buffer in both frames. I am wondering, why this is the default, because it does not seem to make any sense.

The following video shows this: https://youtu.be/hvziEkfmb_c

I have read that display-buffer-alist is the right place to customize this feature, but I do not understand the condition and action arguments.

I would like to give each frame a meaning: for example compile frame and edit frame. When I run compile from the edit frame, Emacs should use the compile frame for the compilation buffer. And when I click on a source line in the compilation buffer in the compile frame, it should use the edit frame to show either the buffer of the already opened file or it should use the edit frame to open the new file.

I general Emacs should never split a frame for a buffer, which is already visible in another frame.

I not sure how this logic fits into the display-buffer-alist.

3
  • 1
    A few suggestions: (1) Edit the question to use the correct terminology of window versus frame emacs.stackexchange.com/q/13583/2287 (2) In the question, create a minimal working example without any user configuration, step by step, so that other forum participants can duplicate the issue. (3) In the question, state what version of Emacs and operating system was used to create the minimal working example. In Emacs, the the word "clone" as to a buffer has special meaning ... If the buffer is the same buffer displayed in multiple windows, then that is not a "cloned" buffer per se.
    – lawlist
    Jan 25 at 0:30
  • Without any user configuration, Emacs should reuse the *compilation* window. STEP #1 Start a vanilla Emacs without any user configuration, aka emacs -Q. STEP #2 We are now at a welcome screen with a buffer named *GNU Emacs*. STEP #3 Type M-x compile and delete the sample compile command make -k and replace that with the word date and press RET. The window containing *GNU Emacs* is split horizontally in two and the bottom window now contains the *compilation* buffer, and focus remains in the *GNU Emacs* window. STEP #4: Repeat STEP #3 above.
    – lawlist
    Jan 25 at 0:49
  • @lawlist No it does not reuse the window, if the window is in another frame. Instead Emacs creates a new window in the same frame. You end up with the same buffer in two windows in two frames.
    – ceving
    Jan 25 at 7:58

1 Answer 1

2
(add-to-list 'display-buffer-alist
             (cons (rx string-start "*compilation*" string-end)
                   (cons 'display-buffer-reuse-window
                         '((reusable-frames . visible)
                           (inhibit-switch-frames . nil)))))

Start with C-h f display-buffer RET and peruse the documentation for other options.

1
  • Thanks. This will help to dive deeper into it.
    – ceving
    Jan 25 at 10:32

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.