Emacs: define target window for command output

蹲街弑〆低调 提交于 2020-01-03 10:46:25

问题


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.



来源:https://stackoverflow.com/questions/19458957/emacs-define-target-window-for-command-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!