简体   繁体   English

尽可能多地在窗口中显示缓冲区,而不是在缓冲区后显示空白区域

[英]Make as much as possible of buffer visible in window instead of showing empty space after buffer

It is possible to "scroll past the end of the buffer" in a window. 可以在窗口中“滚动缓冲区的末尾”。 This is useful because Emacs has to somehow use the extra space when the buffer does not fill the whole area available to the window used to display it. 这很有用,因为当缓冲区没有填充用于显示它的窗口的整个区域时,Emacs必须以某种方式使用额外的空间。

However sometimes when the whole buffer would fit completely into the window the top part still isn't displayed and more space than necessary is wasted below the buffer content to fill the available space. 然而,有时当整个缓冲区完全适合窗口时,顶部仍未显示,并且在缓冲区内容下面浪费了超过必要的空间以填充可用空间。 It would be better if the window were automatically scrolled to show the complete buffer or if it is bigger than the window as much as possible. 如果窗口被自动滚动以显示完整的缓冲区或者它是否尽可能大于窗口,那会更好。

In other words the only time when a window displays something "below the buffer end" is when the window is to big. 换句话说,窗口显示“缓冲区末端下方”的唯一时间是窗口大的时候。

Is there a mode or option to do that? 有这样的模式或选项吗?

在此输入图像描述

Edit: So something like this? 编辑:这样的事情?

(add-hook 'post-command-hook 'my-eob-recenter)
(defun my-eob-recenter ()
  (when (pos-visible-in-window-p (point-max))
    (save-excursion
      (goto-char (point-max))
      (recenter -1))))

Original answer: 原始答案:

If you have a window which is larger than its contents and you want to shrink it to fit, there's a binding for that. 如果你有一个大于其内容的窗口,并且你想缩小它以适应它,那么就有一个绑定。

Cx - runs shrink-window-if-larger-than-buffer Cx -运行shrink-window-if-larger-than-buffer

Personally I suspect this would be annoying if it happened automatically, but you might try this: 我个人怀疑如果它自动发生会很烦人,但你可以试试这个:

(defadvice split-window (after my-split-window-shrink)
  "Shrink the selected window after a window split
if it is larger than its contents."
  (shrink-window-if-larger-than-buffer))
(ad-activate 'split-window)

The second buffers space looks little big, agreed. 同意,第二个缓冲空间看起来不大。 However, basically the behaviour is reasonably as it makes you grasp being at-the-end at once. 但是,基本上这种行为是合理的,因为它会让你立刻抓住这种行为。

A filled buffer doesn't tell about the end. 填充缓冲区不会告诉结束。 In most cases you will go on at the end, or take profit from that info signaled. 在大多数情况下,您将在最后继续,或从信号中获取利润。

Just as I conceive it... 正如我设想的那样......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM