18

我的 Windows 配置如下所示:

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

我将右下角的窗口用于特殊显示(如帮助、完成等),但当我调用使用的命令(find-file-other-window等)时,emacs 坚持使用该窗口display-buffer,并调整该窗口的大小。这很烦人......有没有办法让emacs不使用那个窗口?我正在考虑提供建议display-buffer,但它是 c 中的一个函数。对此有什么想法吗?

编辑:

很大程度上基于 Trey 的回答,到目前为止,这对我有用:

(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))))))
4

4 回答 4

18

好吧,有人已经问过同样的问题了。我写了一个似乎效果很好的答案。

看起来您可以使用相同的解决方案,除了添加 to 之外special-display-buffer-names,您可以使用变量special-display-regexps。所以类似于:

(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)))))

显然,您必须修改正则表达式,使其与*Help*右下方窗口中实际需要的缓冲区和其他缓冲区不匹配。

关于建议display-buffer,那会起作用。您可以建议用 c 编写的函数,建议几乎适用于您想要的所有情况,除非从 c调用函数或建议宏(这不起作用 b/c 宏通常已经在使用它们的任何地方展开)。

于 2009-06-16T15:16:20.793 回答
3

也许这样的事情可以工作:

(defun display-buffer-avoiding-lr-corner (buffer &optional not-this-window)
  (save-selected-window
    (when (buffer-file-name buffer)
      (select-window (window-at (- (frame-width) 1)
                                (- (frame-height) 2))))
    (let ((display-buffer-function nil))
      (display-buffer buffer not-this-window))))

(setq display-buffer-function 'display-buffer-avoiding-lr-corner)
于 2009-06-16T16:35:21.177 回答
2

我正在考虑建议显示缓冲区,但它是 c 中的一个函数。

"display-buffer is an interactive Lisp function in `window.el'."

此外,无论如何,您都可以建议 C 函数。

于 2009-06-16T21:58:30.700 回答
2

也许让这个右下角的窗口专门由set-window-dedicated-p. 然后这个窗口将在find-file-other-window你想要的操作中被忽略。

于 2012-04-24T15:19:43.733 回答