使 *Buffer List* 始终出现在水平分割中 [英] Make *Buffer List* always appear in horizontal split

查看:26
本文介绍了使 *Buffer List* 始终出现在水平分割中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Emacs 试图变得聪明并根据窗口的哪个维度更大来打开它的辅助缓冲区,所以如果当前宽度大于高度,它可能会出现在垂直拆分窗口中,否则会出现在水平拆分窗口中.

I know Emacs tries to be intellectual and opens its helper buffers depending on which dimension of the window is bigger, so it may appear in vertical split window if current width is bigger than height, and in horizontal split otherwise.

但我更喜欢它总是在水平分割中打开那个列表,因为当缓冲区被放置在垂直分割中时,我看不到很长的路径.我该怎么做?

But I’d prefer it to open that list always in horizontal split, because there are long paths I can’t see when the buffer is placed in vertical split. How can I do this?

推荐答案

我相信您已经将水平/垂直拆分术语重新放在了前面(我永远不记得哪个是哪个),但是因为您的目标是保留原始窗口的宽度,我强制垂直拆分.

I believe you've got the horizontal/vertical split terminology back to front (I can never remember which is which either), but as your goal was to retain the original window's width, I'm forcing a vertical split.

C-hf split-window-sensably RET.它会告诉你该怎么做:

See C-hf split-window-sensibly RET. It tells you what to do:

You can enforce this function to not split WINDOW horizontally,
by setting (or binding) the variable `split-width-threshold' to
nil.  If, in addition, you set `split-height-threshold' to zero,
chances increase that this function does split WINDOW vertically.

作为永久设置:

(setq split-width-threshold nil)
(setq split-height-threshold 0)

对于特定功能,您可以建议该功能(但请参阅下面的编辑 2!):

For just a specific function, you can advise that function (but see Edit 2 below!):

(defadvice list-buffers (around list-buffers-split-vertically)
  "Always split vertically when displaying the buffer list.
See `split-window-sensibly'."
  (let ((split-width-threshold nil)
        (split-height-threshold 0))
    ad-do-it))
(ad-activate 'list-buffers)

实际上,在这种情况下,我怀疑您只关心交互式情况,在这种情况下,最好定义一个函数并重新映射绑定:

Actually, in this instance I suspect you're only concerned with the interactive case, in which case it's preferable to define a function and remap the bindings:

(defun my-list-buffers-vertical-split ()
  "`list-buffers', but forcing a vertical split.
    See `split-window-sensibly'."
  (interactive)
  (let ((split-width-threshold nil)
        (split-height-threshold 0))
    (call-interactively 'list-buffers)))

(global-set-key [remap list-buffers] 'my-list-buffers-vertical-split)

编辑 2: Stefan 指出 display-buffer-alist 可以在不建议函数的情况下促进这些事情(当然避免不必要的建议总是一件好事).我相信我们仍然需要自定义操作,因此:

Edit 2: And Stefan points out that display-buffer-alist facilitates such things without advising functions (and of course avoiding unnecessary advice is always a good thing). I believe we still need a custom action, so:

(defun my-display-buffer-pop-up-same-width-window (buffer alist)
  "A `display-buffer' ACTION forcing a vertical window split.
    See `split-window-sensibly' and `display-buffer-pop-up-window'."
  (let ((split-width-threshold nil)
        (split-height-threshold 0))
    (display-buffer-pop-up-window buffer alist)))

(add-to-list 'display-buffer-alist
             '("\*Buffer List\*" my-display-buffer-pop-up-same-width-window))

这篇关于使 *Buffer List* 始终出现在水平分割中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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