Emacs: define target window for command output

2019-06-19 00:33发布

问题:

I'm tired of emacs clobbering my windows with its output, and unpredictably at that. I'd like to have several windows in emacs frame and have each window dedicated for a certain purpose only. For example,

ECB panels |  Editor 1 | Editor 2 |  Bookmarks+
------------------------------------------------
"Messages" (output buffer)

So, when I run M-x compile, I want the output to always go into Messages. Similarily, when I run M-x magit-status, I want results in Messages, as well. Clicking on a bookmark or pressing C-x r b should open the file and position the cursor in Editor 1.

I've tried some lisp snippets to "lock" the windows to prevent the changes but the emacs goes nuts when all windows are "locked", cause it can't find an available window to put new output into. This nasty buffer-swap feature that emacs has must be going back to the 80x25 character terminal days.

I've never seen ECB windows get clobbered, so it must be doable somehow.

回答1:

You are explicitly asking for dedicated windows. Well, Emacs has exactly that feature: dedicated windows. C-h r g dedicated windows tells you pretty much everything you need to know.

But see also special-display-buffer-names and special-display-regexps --- or if you are a masochist, fiddle with display-buffer-alist to do the same thing.

With display-buffer-alist you can in principle do anything you might imagine, including tie your underwear in knots and set it on fire.

(Me, I just set special-display-regexps to ("[ ]?[*][^*]+[*]").)



回答2:

Call lockon-window before you open a thing. Call again to undedicate all windows. It is easy to setup sending everything to window:Message; however, to show a buffer to window:Editor-1 from window:Bookmarks+ without calling lockon-window, is too hard with my power. I hope slide-window helps.



标签: emacs elisp