【问题标题】:Too many split screens opening in Emacs!Emacs 中打开的分屏太多!
【发布时间】:2011-03-07 19:36:17
【问题描述】:

自从我在新机器上安装 emacs 以来,我就看到了一个丑陋的行为。不幸的是,我的旧 .emacs 文件相当零碎,我无法确定我以前是否有 elisp 来处理这个问题。

问题是这样的:以前当我执行会打开新缓冲区的命令(例如 grep'ing 或单击搜索结果中的文件名时,会发生以下两种情况之一:

  1. 如果只显示一个缓冲区,屏幕将分割一次
  2. 如果显示多个缓冲区,则当前缓冲区窗口之后的缓冲区窗口将打开所需的文件

我希望恢复这种行为。我现在得到的是以下内容:

Emacs 会一直拆分窗口,直到打开四个缓冲区窗口。如果我连续单击多个 grep 结果,它们打开的缓冲区窗口将循环通过其他三个(非 grep 结果)缓冲区窗口。如果他们只是在同一个位置打开,我会喜欢它:结果旁边/下方的“下一个”缓冲区窗口 - 每次都相同的缓冲区窗口。

关于如何实现这种行为的任何想法?

【问题讨论】:

  • 我也想要这个,新行为让我抓狂。

标签: emacs split grep buffer


【解决方案1】:

考虑将split-height-threshold 设置为大于框架高度的值;这将防止不必要的垂直分割。

(setq split-height-threshold 999)

如果您更喜欢垂直拆分而不是水平拆分,请改为自定义 split-width-threshold

要更精细地控制新缓冲区的显示方式,请自定义display-buffer-function;这将允许您完全替换规定缓冲区显示策略的默认 display-buffer 函数。

【讨论】:

  • 其实设置为nil是规定的禁用垂直分割的方式... "如果这个为nil, `split-window-sensibly' 是不允许垂直分割窗口的。" 谢谢指针!
  • +1 表示 blalor 对此答案的重大改进。
【解决方案2】:

这是我已经使用了一段时间的:

;;;---------------------------------------------------------------------
;;; display-buffer

;; The default behaviour of `display-buffer' is to always create a new
;; window. As I normally use a large display sporting a number of
;; side-by-side windows, this is a bit obnoxious.
;;
;; The code below will make Emacs reuse existing windows, with the
;; exception that if have a single window open in a large display, it
;; will be split horisontally.

(setq pop-up-windows nil)

(defun my-display-buffer-function (buf not-this-window)
  (if (and (not pop-up-frames)
           (one-window-p)
           (or not-this-window
               (not (eq (window-buffer (selected-window)) buf)))
           (> (frame-width) 162))
      (split-window-horizontally))
  ;; Note: Some modules sets `pop-up-windows' to t before calling
  ;; `display-buffer' -- Why, oh, why!
  (let ((display-buffer-function nil)
        (pop-up-windows nil))
    (display-buffer buf not-this-window)))

(setq display-buffer-function 'my-display-buffer-function)

【讨论】:

  • 为我工作。一个警告是,它不关注编译模式框架并在关闭其他更重要的框架时保持它们打开。
【解决方案3】:

我在从 emacs 22 切换到 23 时遇到了这个问题。

如果您已经在缓冲区中打开了一个文件,我发现将 display-buffer-reuse-frames 设置为非 nil(如 display-buffer 的帮助所建议的那样)会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-22
    • 1970-01-01
    • 2022-07-08
    • 2013-04-02
    相关资源
    最近更新 更多