5

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.

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?

enter image description here

4

2 回答 2

2

编辑:所以像这样?

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

原答案:

如果您有一个大于其内容的窗口,并且您想将其缩小以适应,则有一个绑定。

C-x-运行shrink-window-if-larger-than-buffer

我个人怀疑如果它自动发生,这会很烦人,但你可以试试这个:

(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)
于 2013-05-14T00:32:20.930 回答
0

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...

于 2013-05-13T19:40:29.697 回答