本文介绍了用于显示缓冲区的Emacs中的split-height-threshold和split-width-threshold的反向评估顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

display-buffer 必须在现有窗格中创建一个新窗口时,指出, split-height-threshold 首先查看确定新窗口是否可以低于当前窗口,然后 split-width-threshold 以相同的方式并行计算窗口。

When display-buffer has to create a new window in an existing pane, the Emacs manual states that split-height-threshold is looked at first to determine if the new window can be below the current one, then split-width-threshold is evaluated in the same way for side-by-side windows.

如果宽度足够高,Emacs是否首先尝试将窗口并排放在一起?我可以将 split-height-threshold 设置为 nil 以禁止垂直分割,但这会使Emacs窃取另一个窗口

Is there a way to make Emacs try first to put the windows side by side first if the width is high enough? I can set split-height-threshold to nil to inhibit vertical split altogether, but that makes Emacs steal another window if the current one is not wide enough.

推荐答案

您可以通过自定义变量拆分Emacs来做到这一点-window-preferred-function

You can make Emacs do this by customizing the variable split-window-preferred-function:

(defun my-split-window-sensibly (&optional window)
  (let ((window (or window (selected-window))))
    (or (and (window-splittable-p window t)
             ;; Split window horizontally.
             (with-selected-window window
               (split-window-right)))
        (and (window-splittable-p window)
             ;; Split window vertically.
             (with-selected-window window
               (split-window-below)))
        (and (eq window (frame-root-window (window-frame window)))
             (not (window-minibuffer-p window))
             ;; If WINDOW is the only window on its frame and is not the
             ;; minibuffer window, try to split it horizontally disregarding
             ;; the value of `split-width-threshold'.
             (let ((split-width-threshold 0))
               (when (window-splittable-p window t)
                 (with-selected-window window
                   (split-window-right))))))))

(setq split-window-preferred-function 'my-split-window-sensibly)

变量 split-window-preferred-function

指定一个分割窗口的功能,以便创建一个用于显示缓冲区的新窗口。它被 display-buffer-pop-up-window action函数用于实际拆分窗口。

默认情况下,它设置为 split-window-sensably 。我上面提供的功能是修改版本的 split-window-sensably (在),简单地逆转了原来功能的步骤,导致Emacs倾向于并排窗口分开堆叠的窗口。

By default, it is set to split-window-sensibly. The function I am providing above is a modified version of split-window-sensibly (defined in window.el) that simply reverses the steps of the original function, causing Emacs to "prefer" side-by-side window splits over stacked ones.

这篇关于用于显示缓冲区的Emacs中的split-height-threshold和split-width-threshold的反向评估顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 02:14