如何强制Emacs在特定窗口中不显示缓冲区? [英] How to force Emacs not to display buffer in a specific window?

查看:161
本文介绍了如何强制Emacs在特定窗口中不显示缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows配置如下所示:

My windows configuration looks like this:

          +----------+-----------+
      |          |           |
      |          |           |
      |          |           |
      |          |           |
      |          |           |
      |          +-----------+
      |          |           |
      +----------+-----------+

我使用右下角的窗口进行特殊显示(如帮助,完成等),但emacs在调用命令时坚持使用该窗口( find-file-other-窗口等),使用 display-buffer ,并调整该窗口的大小。这是烦人的...有没有办法,我可以强制emacs不使用该窗口?我正在考虑建议 display-buffer ,但它是c中的一个功能。有什么想法吗?

And I use the lower right window for special displays (like help, completion etc.), but emacs insists on using that window when I call commands (find-file-other-window, etc.) that use display-buffer, and resize that window as well. It's annoying... Is there a way that I can force emacs NOT to use that windows? I was thinking of advising display-buffer, but it's a function in c. Any thoughts on this?

编辑:

极大地依赖Trey的答案,我到目前为止:

Based heavily on Trey's answer, this is what works for me so far:

(setq special-display-function 'my-display-buffer)
(setq special-display-regexps '(".*"))

(defun display-special-buffer (buf)
  "put the special buffers in the right spot (bottom rigt)"
    (let ((target-window (window-at (- (frame-width) 4) (- (frame-height) 4)))
          (pop-up-windows t))
      (set-window-buffer target-window buf)
      target-window))

(defun my-display-buffer (buf)
  "put all buffers in a window other than the one in the bottom right"
  (message (buffer-name  buf))
  (if (member (buffer-name buf) special-display-buffer-names)
      (display-special-buffer buf)
      (progn
        (let ((pop-up-windows t)
              (windows (delete (window-at (- (frame-width) 4) (- (frame-height) 4))
                         (delete (minibuffer-window) (window-list)))))
          (message (buffer-name (window-buffer (car windows))))
          (set-window-buffer (car (cdr windows)) buf)
          (car (cdr windows))))))


推荐答案

嗯,有人已经问过完成相同的问题。我写了一个答案这似乎工作得很好。

Well, someone already asked the same question for completion. And I wrote up an answer that seemed to work pretty well.

看起来你可以使用相同的解决方案,除了添加到特殊显示-buffer-name ,可以使用变量 special-display-regexps 。所以一些这样的东西:

It looks like you could use that same solution, except instead of adding to special-display-buffer-names, you can use the variable special-display-regexps. So something along the lines of:

(add-to-list 'special-display-regexps '(".*" my-display-buffers))

(defun my-display-buffers (buf)
  "put all buffers in a window other than the one in the bottom right"
  (let ((windows (delete (window-at (- (frame-width) 2) (- (frame-height) 4))
                         (delete (minibuffer-window) (window-list))))
    (if (<= 2 (length windows))
        (progn 
          (select-window (cadr windows))
          (split-window-vertically)))
    (let ((pop-up-windows t))
      (set-window-buffer (car windows) buf)
      (car windows)))))

显然,您必须修改正则表达式,使其不符合 *帮助* 和其他缓冲区

Obviously you'll have to modify the regexp to not match the *Help* and other buffers that you actually want in the lower right window.

关于建议 display-buffer ,这将工作。您可以建议在c中编写的功能,除了函数从c中调用 之外,还可以提供宏(这些宏不适用于宏)已经扩大到任何地方使用)。

Regarding advising display-buffer, that would work. You can advise functions written in c, advice works in pretty much every case you'd want except when functions are called from c, or advising macros (which doesn't work b/c the macros are generally already expanded everywhere they're used).

这篇关于如何强制Emacs在特定窗口中不显示缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆