From: Sam Steingold <sds@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 57837@debbugs.gnu.org
Subject: bug#57837: 29.0.50; fit-window-to-buffer should reposition the buffer
Date: Thu, 15 Sep 2022 14:30:36 -0400 [thread overview]
Message-ID: <lzillopk1f.fsf@3c22fb11fdab.ant.amazon.com> (raw)
In-Reply-To: <838rmkzf9m.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 15 Sep 2022 21:03:33 +0300")
> * Eli Zaretskii <ryvm@tah.bet> [2022-09-15 21:03:33 +0300]:
>
>> From: Sam Steingold <sds@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.
Yes, this is a corner case.
> 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.
Indeed, this function mostly works.
>> 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.
As I said, if `fit-window-to-buffer' has a "contract", it's the invariant
above. Violating it, albeit in a corner case, is, IMO, a bug.
I am not sure how this should be fixed - either by allowing the point to
be outside of the window (if that is possible) or extending the window
by 1 extra line in this corner case - but it _should_ be possible to fix
it.
Thank you.
--
Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113
https://lastingimpactpsychology.com https://steingoldpsychology.com
https://www.peaceandtolerance.org/ https://jihadwatch.org https://camera.org
I haven't lost my mind -- it's backed up on tape somewhere.
next prev parent reply other threads:[~2022-09-15 18:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 17:31 bug#57837: 29.0.50; fit-window-to-buffer should reposition the buffer Sam Steingold
2022-09-15 18:03 ` Eli Zaretskii
2022-09-15 18:30 ` Sam Steingold [this message]
2022-09-15 18:55 ` Sam Steingold
2022-09-15 19:07 ` Eli Zaretskii
2022-09-15 22:52 ` Sam Steingold
2022-09-16 5:53 ` Eli Zaretskii
2022-09-15 19:00 ` Eli Zaretskii
2022-09-15 19:34 ` Gregory Heytings
2022-09-15 22:45 ` Sam Steingold
2022-09-15 22:59 ` Gregory Heytings
2022-09-16 18:52 ` Sam Steingold
2022-09-16 19:34 ` Gregory Heytings
2022-09-16 21:25 ` Sam Steingold
2022-09-16 21:34 ` Gregory Heytings
2022-09-17 6:48 ` Eli Zaretskii
2022-09-17 7:10 ` Gregory Heytings
2022-09-17 7:25 ` Eli Zaretskii
2022-09-18 8:34 ` Gregory Heytings
2022-09-16 5:45 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lzillopk1f.fsf@3c22fb11fdab.ant.amazon.com \
--to=sds@gnu.org \
--cc=57837@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.