问题
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:
(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.
来源:https://stackoverflow.com/questions/3311577/when-using-two-frames-in-emacs-how-do-i-prevent-the-compilation-buffer-from-sho