27

I work with two monitors, and often use emacs with two frames open; one for each monitor. each frame is split into two side-by-side windows, like so:

 a | b   <-- frame 1 in monitor 1
-------
 c | d   <-- frame 2 in monitor 2

When I hit my 'compile' button while in window a, the compilation buffer opens in the buffer next to it. So far so good:

 a | compilation
-----------------
 c |     d

However, if I then move to window c to edit some stuff, then hit compile again, window d visits the compilation buffer as well:

 a | compilation
------------------
 c | compilation

So now I have half of my screen real-estate taken up by two copies of the same compilation buffer, wondering why I have two monitors :)

I can prevent this by conscientiously only hitting the compile key when my cursor is in the buffer next to the currently open compile buffer, but I hit 'compile' so early and often that I usually don't have the presence of mind to do so. I feel like there must be something I can tweak in .emacs so I shouldn't have to.

Any suggestions? Ideally, when I hit 'compile', the currently open compilation buffer should move from its previous window to the one next to the currently used window. If that's too complicated, I'd easily settle for having emacs not visit the compilation buffer in the neighboring window, if it's already open in another window.

1
  • 1
    Brilliant question - never considered using emacs with that setup before! Jul 22, 2010 at 22:31

1 Answer 1

29
(setq-default display-buffer-reuse-frames t)

From the documentation:

Non-nil means `display-buffer' should reuse frames. If the buffer in question is already displayed in a frame, raise that frame.

1
  • 4
    This variable is obsolete since 24.3; use a 'reusable-frames' alist entry in 'display-buffer-alist'.
    – cYrus
    Jan 3, 2015 at 13:02

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.