GNU bug report logs -
#57837
29.0.50; fit-window-to-buffer should reposition the buffer
Previous Next
Reported by: sds <at> gnu.org
Date: Thu, 15 Sep 2022 17:32:01 UTC
Severity: normal
Found in version 29.0.50
Full log
View this message in rfc822 format
> From: Sam Steingold <sds <at> gnu.org>
> Date: Thu, 15 Sep 2022 13:31:48 -0400
>
> When the buffer is smaller than the window, move the point to the end
> and do `C-x w -` (fit-window-to-buffer).
> The window shrinks, but it is empty - the whole buffer is above.
> One has to move the point to the beginning-of-buffer to make the buffer
> visible.
>
> I think this is a bug - the window should show the whole buffer; after
> all this is the raison d'etre of `fit-window-to-buffer', right?
Yes, but by having point at EOB (and assuming the last line ends in a
newline), you've made point be outside of the window's text. Instead
of moving point to the end, move it to last line of the buffer, and
then "C-x w -" will leave the entire buffer text on display.
So I don't think there's a bug here.
> Basically, after `fit-window-to-buffer' is called, the following should
> evaluate to t:
>
> --8<---------------cut here---------------start------------->8---
> (and (pos-visible-in-window-p (point-min))
> (pos-visible-in-window-p (point-max)))
> --8<---------------cut here---------------end--------------->8---
No, because point-max is after the last newline, and thus effectively
one line beyond the window's text.
This bug report was last modified 2 years and 327 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.