GNU bug report logs - #57837
29.0.50; fit-window-to-buffer should reposition the buffer

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: sds@HIDDEN; dated Thu, 15 Sep 2022 17:32:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 16 Sep 2022 18:52:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 16 14:52:22 2022
Received: from localhost ([127.0.0.1]:44358 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oZGRq-0001SI-Ci
	for submit <at> debbugs.gnu.org; Fri, 16 Sep 2022 14:52:22 -0400
Received: from mail-qv1-f44.google.com ([209.85.219.44]:45930)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sam.steingold@HIDDEN>) id 1oZGRo-0001S3-1T
 for 57837 <at> debbugs.gnu.org; Fri, 16 Sep 2022 14:52:20 -0400
Received: by mail-qv1-f44.google.com with SMTP id o13so17313475qvw.12
 for <57837 <at> debbugs.gnu.org>; Fri, 16 Sep 2022 11:52:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:user-agent
 :references:in-reply-to:subject:cc:to:from:sender:from:to:cc:subject
 :date; bh=lWvpWUNKWNaCPrBOFC7gifAKB5XenrK4AXo++U14Nvw=;
 b=k3TN9BYTkat84AcOG6AKKBOeabIV45zTedzNfY83wKi5NOCH4IPqNslR7eOrv2cIPD
 7GF9dNf6EsjJFWGO3Oxs2JAAzdRnN4sBzUrDUz31Ll6IVtDFXYA1Ey2nfMKfKHFBbpMN
 cv18mQESkmICe5ynpoLQT0xkxGP22dwjA1lTXc7+PBr8n3sgwIY5MiO98D+TJDiadZj3
 z7jajt+RtqLlQQ7IqqYS2hKawA2KeSIwH4AX31cfGWwD+6/5FfSsQAKpO+SURPRH1Qkm
 p/Xy9YO/8uak9AD1XGEE9FQ2w0+mHBdXV+D7b+yVo7EW0ZVu9dCU26okch8zxslVgJNL
 jQKw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:user-agent
 :references:in-reply-to:subject:cc:to:from:sender:x-gm-message-state
 :from:to:cc:subject:date;
 bh=lWvpWUNKWNaCPrBOFC7gifAKB5XenrK4AXo++U14Nvw=;
 b=tyO+18vQ4LQycD0WMoLXZdyiT4dwViZcURRrcr0iafgrO0Rh5PFQ1rjCBuyKnJH2gN
 iIRaC062gtnB3ZXPSqI0OiJHp/JoDevSvxmlhJvSq7WAEMSzS1/WXmn+BpdDhOhLipyJ
 X33ttO5th3FO9Xmzjt1YL1JRZcC/5NVA36Qua+uha1cTr7ohowCzwwzlvWcT2SOP73RY
 DPNM6DRs2k0uyysrpXfEjJaa3GI98WgdayZWBr30XlLUBydv8FtPmmhFNCjewSnRZVEy
 VE7AmljlZJyVB+JvEz9InmHIk5NWpA6oA3yu5J5/LKUyZWhxJM9PJasExGl6MKdzbcnG
 xrRg==
X-Gm-Message-State: ACrzQf0ecpaZCpEu5FEOxOWlkfpSTllNkwzul1ACR9A6LeV10xLLnizZ
 WpUaBnFWN88sFwPtJRfJDRUM6mlyzPBI
X-Google-Smtp-Source: AMsMyM5NmVjCggbUmYAg3TZ+u1OVmodqyZjq2hSaQiItcGBsZXQpFyou/VeAtxwXwWAZTuW79b8nEw==
X-Received: by 2002:a05:6214:411a:b0:4ac:9402:e7de with SMTP id
 kc26-20020a056214411a00b004ac9402e7demr5130942qvb.128.1663354334596; 
 Fri, 16 Sep 2022 11:52:14 -0700 (PDT)
Received: from 3c22fb11fdab.ant.amazon.com
 (pool-71-125-32-130.nycmny.fios.verizon.net. [71.125.32.130])
 by smtp.gmail.com with ESMTPSA id
 ck12-20020a05622a230c00b0031eddc83560sm5613218qtb.90.2022.09.16.11.52.13
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 16 Sep 2022 11:52:14 -0700 (PDT)
From: Sam Steingold <sds@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>
Subject: Re: bug#57837: 29.0.50; fit-window-to-buffer should reposition the
 buffer
In-Reply-To: <b24128855b585708dbc5@HIDDEN> (Gregory Heytings's message
 of "Thu, 15 Sep 2022 22:59:57 +0000")
References: <lzmtb0pmrf.fsf@HIDDEN>
 <b24128855b57f8393d5b@HIDDEN>
 <lz5yhop890.fsf@HIDDEN>
 <b24128855b585708dbc5@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)
X-Attribution: Sam
X-Disclaimer: You should not expect anyone to agree with me.
Date: Fri, 16 Sep 2022 14:52:13 -0400
Message-ID: <lz8rmjnode.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: sds@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

> * Gregory Heytings <tertbel@HIDDEN> [2022-09-15 22:59:57 +0000]:
>
>>> (advice-add 'fit-window-to-buffer :after
>>> 	    (lambda () (and (= (count-lines (point-min) (point-max)) (1- (window-height)))
>>> 			    (or (< (point) (point-max)) (forward-line -1) t)
>>> 			    (set-window-start nil (point-min)))))
>>
>> Why shouldn't this be the default behavior?
>
> I think because fit-window-to-buffer isn't supposed to move point, and
> point would become invisible if it is not moved.

Is that a problem?
I mean, is it possible for the point to be invisible?

-- 
Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113
https://lastingimpactpsychology.com https://steingoldpsychology.com
https://www.memritv.org https://memri.org https://ffii.org https://jij.org
If you want your advice to be appreciated, write it on a $100 bill.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 16 Sep 2022 05:53:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 16 01:53:59 2022
Received: from localhost ([127.0.0.1]:41247 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oZ4IY-0000te-NC
	for submit <at> debbugs.gnu.org; Fri, 16 Sep 2022 01:53:59 -0400
Received: from eggs.gnu.org ([209.51.188.92]:46872)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oZ4IW-0000tO-Fv
 for 57837 <at> debbugs.gnu.org; Fri, 16 Sep 2022 01:53:56 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:48196)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oZ4IR-0001tT-2H; Fri, 16 Sep 2022 01:53:51 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=b7ZGKvAzaBqjrqOderOI5dTFGFZza2d1lLtsQ3Ml5q0=; b=kvqX8482slwU
 nhSFV0DpCNO8eizAxwr7z7V4LNAEhIb152lT0U2mCRVSqI2/VE6Z8aDik3/+eKQLgbzxLOr+7IVJF
 InjqZkOaxpAnhl8lvJM2MY1y+8S1L+2uWITTKOpnb6LoE+eSMseJ8NfCxOfmTHy1EV6NviK3a1FXG
 Y8PsaD6brzaNZ8AhR5ZMUn1ybXT92vJLx7kRP5IsBz0S9gS8iDcNwcQBqHBmKaBKSQB+fFHHtiOZx
 O3CaLbnxUco9CyTKzuMI5mkPYQR0erj6M3DXgyvs1zO32Wr7gE65+/l7bQ3kuXsX97/XpM059QcCS
 jetdUp3veM0mPGiXh7accQ==;
Received: from [87.69.77.57] (port=2230 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oZ4IQ-0006pL-HC; Fri, 16 Sep 2022 01:53:50 -0400
Date: Fri, 16 Sep 2022 08:53:44 +0300
Message-Id: <83v8pn50gn.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: sds@HIDDEN
In-Reply-To: <lzy1ukntch.fsf@HIDDEN> (message from Sam
 Steingold on Thu, 15 Sep 2022 18:52:30 -0400)
Subject: Re: bug#57837: 29.0.50; fit-window-to-buffer should reposition the
 buffer
References: <lzmtb0pmrf.fsf@HIDDEN>
 <838rmkzf9m.fsf@HIDDEN> <lzillopk1f.fsf@HIDDEN>
 <CAFsbZ7bCUH-MSV0GojYy0pUCWAfczXLtvfoNdib-RK+rfZZuoA@HIDDEN>
 <835yho5ue4.fsf@HIDDEN> <lzy1ukntch.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Sam Steingold <sds@HIDDEN>
> Cc: 57837 <at> debbugs.gnu.org
> Date: Thu, 15 Sep 2022 18:52:30 -0400
> 
> > * Eli Zaretskii <ryvm@HIDDEN> [2022-09-15 22:07:15 +0300]:
> >
> >> > >> --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---
> >> 
> >> replacing `poing-min` and `point-max` with beginning-of-text and
> >> end-of-text, of course...
> >
> > What are beginning-of-text and end-of-text?  I don't find such
> > functions in Emacs.
> 
> I meant something like this:
> 
> --8<---------------cut here---------------start------------->8---
> (defun beginning-of-text ()
>   (save-excursion
>     (goto-char (point-min))
>     (1- (re-search-forward "[[:graph:]]" nil t))))
> --8<---------------cut here---------------end--------------->8---

Thanks, but your problem wasn't with beginning-of-text, it was with
end-of-text.  And you haven't explained what you consider end-of-text.

Moreover, the assumption that fit-window-to-buffer ignores
non-[:graph:] characters is false.  This function counts everything
that's displayed as some kind of glyph, no matter what kind of
character that is.

What you see in the case you described, when this function is called
with point at EOB, is the normal Emacs display operation: after the
command completes, if point is outside the window, Emacs scrolls the
display to bring point back into view.  The trigger for that scrolling
is the fact that you positioned point at EOB.  So don't.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 16 Sep 2022 05:46:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 16 01:46:12 2022
Received: from localhost ([127.0.0.1]:41232 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oZ4B2-0000g5-2I
	for submit <at> debbugs.gnu.org; Fri, 16 Sep 2022 01:46:12 -0400
Received: from eggs.gnu.org ([209.51.188.92]:35138)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oZ4B1-0000ft-2v
 for 57837 <at> debbugs.gnu.org; Fri, 16 Sep 2022 01:46:11 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:41902)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oZ4Av-0000hY-Mi; Fri, 16 Sep 2022 01:46:05 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=TEZyZAovqS+o/6paOSDFd+YTtYlaYJphYMSRA+s4JXw=; b=e4ncKWdt7cgV
 VuezA2Q7sXmI8Yi2El+2sHAhSgk19EssUmGU9V96wFB8s2hgv/gFMUre3Z8XyGEW17U0OvlVbqKwS
 wKaBZdMvf6FTYTnENZGkgDu1W7fQ3N/wofPjdfAVd5wIBpd/eGHXVKvl0zQ67v0aNAYoNptI7zOKU
 UySFsSo47FMfCLbi7lRBM53b8q0iKBrPPJ1sVxeRxVFJhd0xRrXZwHNM6ia3xwETAILQmX+JsqE7z
 oYg5hzvqy2vYZYpC2MXMwJHJEZttECpGOE2KAcMWlB84JMchW564rCCrfGELAFTVzgwDuqkNGYAUp
 zBvDeYpeVmK/lfvOmgAJBg==;
Received: from [87.69.77.57] (port=1758 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oZ4At-0001qD-IF; Fri, 16 Sep 2022 01:46:05 -0400
Date: Fri, 16 Sep 2022 08:45:57 +0300
Message-Id: <83wna350tm.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: sds@HIDDEN
In-Reply-To: <lz5yhop890.fsf@HIDDEN> (message from Sam
 Steingold on Thu, 15 Sep 2022 18:45:15 -0400)
Subject: Re: bug#57837: 29.0.50;
 fit-window-to-buffer should reposition the buffer
References: <lzmtb0pmrf.fsf@HIDDEN>
 <b24128855b57f8393d5b@HIDDEN>
 <lz5yhop890.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org, gregory@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 57837 <at> debbugs.gnu.org
> From: Sam Steingold <sds@HIDDEN>
> Date: Thu, 15 Sep 2022 18:45:15 -0400
> 
> > * Gregory Heytings <tertbel@HIDDEN> [2022-09-15 19:34:38 +0000]:
> >
> >>
> >> 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.
> >>
> >
> > (advice-add 'fit-window-to-buffer :after
> > 	    (lambda () (and (= (count-lines (point-min) (point-max)) (1- (window-height)))
> > 			    (or (< (point) (point-max)) (forward-line -1) t)
> > 			    (set-window-start nil (point-min)))))
> 
> Thank you.
> 
> Why shouldn't this be the default behavior?

I thought I explained that it wasn't needed?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 23:00:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 19:00:00 2022
Received: from localhost ([127.0.0.1]:59513 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYxpw-00028a-Gm
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 19:00:00 -0400
Received: from heytings.org ([95.142.160.155]:43364)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1oYxpu-00028S-Hq
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 18:59:59 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20220101; t=1663282797;
 bh=+w/GOBgoNX2hs4QjIsbmj7pfw95FKANvSbp9K3Atsuw=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=3ji4JQE7DnsyyL8Z9/IoAhZdXMRlU+PT/6dPSFYWlrUzD7GHqcvPN94eP2zr1kBns
 4uYrNJHAxqI0O9VhIkNmvlYhQRob2AD+wD668covSeFATpEpsBK8U2ymova92B2/yT
 xASjnfwImZnhwEIEsBgZuX5q/oDfT6kpEo7dvbBDGZMOqVMtJjiXTtErxA3TcTQKim
 bUQDTo9QoYh0VbbySPj3TieWKnGz8PZCut+SrF/v7UWv23VRyjbGjzWdFPpETnUbLq
 aml9tAX+pVtUW6SF5bGjgMnGyyQ9B2YAanBtXgBQ2k6zcl7vk3ge7lp8onIwV65Zpk
 IGnWVfZHTEHYw==
Date: Thu, 15 Sep 2022 22:59:57 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Sam Steingold <sds@HIDDEN>
Subject: Re: bug#57837: 29.0.50; fit-window-to-buffer should reposition the
 buffer
In-Reply-To: <lz5yhop890.fsf@HIDDEN>
Message-ID: <b24128855b585708dbc5@HIDDEN>
References: <lzmtb0pmrf.fsf@HIDDEN>
 <b24128855b57f8393d5b@HIDDEN>
 <lz5yhop890.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>> (advice-add 'fit-window-to-buffer :after
>> 	    (lambda () (and (= (count-lines (point-min) (point-max)) (1- (window-height)))
>> 			    (or (< (point) (point-max)) (forward-line -1) t)
>> 			    (set-window-start nil (point-min)))))
>
> Why shouldn't this be the default behavior?
>

I think because fit-window-to-buffer isn't supposed to move point, and 
point would become invisible if it is not moved.  The docstring says: 
"Note that even if this function makes WINDOW large enough to show _all_ 
parts of its buffer you might not see the first part when WINDOW was 
scrolled."




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 22:52:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 18:52:42 2022
Received: from localhost ([127.0.0.1]:59500 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYxis-0001xk-12
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 18:52:42 -0400
Received: from mail-qk1-f181.google.com ([209.85.222.181]:35395)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sam.steingold@HIDDEN>) id 1oYxio-0001xM-TV
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 18:52:39 -0400
Received: by mail-qk1-f181.google.com with SMTP id u28so11567330qku.2
 for <57837 <at> debbugs.gnu.org>; Thu, 15 Sep 2022 15:52:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:user-agent
 :references:in-reply-to:subject:cc:to:from:sender:from:to:cc:subject
 :date; bh=bID4uRap5mkdqk5pGBP/QNNknhmMcCMYgzcqe40bNas=;
 b=oLem9lJd8FtELKMFFi0P/Et8YdjQEH50CgSqy9rV2cndzVIAHlSzKeSqagb5FkrCF/
 NbK0Q5toboXAXHdjmOL2WDEGYiDKKJO0NC5olEZJaBuYACAf2xRoHbqHnX3ojoQDojNa
 Udi7RGZ8/QxgaUaX3zOoMLHLWcUJzt5uvt9uHwLb/qWguCPmmRBX5yZx72WIxLXub7CW
 dSQ4t3i5vAI39w/sSQ+YddR4scUyxHAYwBdJSeYE05BjT0L0CL02kIIFB/wyL96XPK1S
 MZkDAvDxgGt9b55Yl32OhYSeNj6Pt4Ft0kfwLHQw+og+EUT579y+1f34vCtzuyWWFTOq
 iNiA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:user-agent
 :references:in-reply-to:subject:cc:to:from:sender:x-gm-message-state
 :from:to:cc:subject:date;
 bh=bID4uRap5mkdqk5pGBP/QNNknhmMcCMYgzcqe40bNas=;
 b=CjqSRWGjOInGidJ9pKDDSIX5cSK56VuC11F9x0fapyBL6sojr31iLpzXnPCbUIC+iL
 zZTWI0/VWmf8CIyMMNZeiPsdaMEyvKTXvmflcXl8qze+McRbFoctv86gHgPVQz4BTliK
 vhn3+Y+zAxSMTfm/LA1Bb62y5IwkPOFcc3rVC8J6sWiyfuNH4GjaIMTwS66OI40zWlOR
 1rAElMj799M/l41oTShS9O0C0HCmR31+2LgkETbSevHnU6a3yEYbn29t56VdX/m9neJh
 p77Ht7mZnXpIBKdRIYQNYDjgYuC2M5A9Cm9v3lRj/3DrYgiRfOFEkkTghOIYVk3IgEm2
 yaBA==
X-Gm-Message-State: ACrzQf2qDrf/LvtBnsKARN2c4EGiEw/wsXzU2k4mDi+lGnA37Z2pWWA7
 IzlnyUMhJIcxm/SlGqF31l2ZMNv4J4rL
X-Google-Smtp-Source: AMsMyM46X/nbrNdZbAJnva/zPkv9kmZb5+l70cEhFj5jxiAUqaVKLbB0JgJNuqbr6zhqenuv4bCijw==
X-Received: by 2002:a05:620a:4454:b0:6ce:bfbf:7e3f with SMTP id
 w20-20020a05620a445400b006cebfbf7e3fmr285880qkp.748.1663282352395; 
 Thu, 15 Sep 2022 15:52:32 -0700 (PDT)
Received: from 3c22fb11fdab.ant.amazon.com
 (pool-71-125-32-130.nycmny.fios.verizon.net. [71.125.32.130])
 by smtp.gmail.com with ESMTPSA id
 l3-20020ac84a83000000b00342fc6a8e25sm4192235qtq.50.2022.09.15.15.52.31
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 15 Sep 2022 15:52:31 -0700 (PDT)
From: Sam Steingold <sds@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#57837: 29.0.50; fit-window-to-buffer should reposition the
 buffer
In-Reply-To: <835yho5ue4.fsf@HIDDEN> (Eli Zaretskii's message of "Thu, 15 Sep
 2022 22:07:15 +0300")
References: <lzmtb0pmrf.fsf@HIDDEN>
 <838rmkzf9m.fsf@HIDDEN> <lzillopk1f.fsf@HIDDEN>
 <CAFsbZ7bCUH-MSV0GojYy0pUCWAfczXLtvfoNdib-RK+rfZZuoA@HIDDEN>
 <835yho5ue4.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)
X-Attribution: Sam
X-Disclaimer: You should not expect anyone to agree with me.
Date: Thu, 15 Sep 2022 18:52:30 -0400
Message-ID: <lzy1ukntch.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: sds@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

> * Eli Zaretskii <ryvm@HIDDEN> [2022-09-15 22:07:15 +0300]:
>
>> From: Sam Steingold <sds@HIDDEN>
>> Date: Thu, 15 Sep 2022 14:55:16 -0400
>> Cc: 57837 <at> debbugs.gnu.org
>> 
>> > >> --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---
>> 
>> replacing `poing-min` and `point-max` with beginning-of-text and
>> end-of-text, of course...
>
> What are beginning-of-text and end-of-text?  I don't find such
> functions in Emacs.

I meant something like this:

--8<---------------cut here---------------start------------->8---
(defun beginning-of-text ()
  (save-excursion
    (goto-char (point-min))
    (1- (re-search-forward "[[:graph:]]" nil t))))
--8<---------------cut here---------------end--------------->8---


-- 
Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113
https://lastingimpactpsychology.com https://steingoldpsychology.com
https://ij.org/ https://jij.org https://thereligionofpeace.com
What garlic is to food, insanity is to art.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 22:45:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 18:45:40 2022
Received: from localhost ([127.0.0.1]:59488 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYxbw-0001lI-MS
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 18:45:40 -0400
Received: from mail-qv1-f51.google.com ([209.85.219.51]:42835)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sam.steingold@HIDDEN>) id 1oYxbm-0001kv-55
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 18:45:30 -0400
Received: by mail-qv1-f51.google.com with SMTP id z9so3895503qvn.9
 for <57837 <at> debbugs.gnu.org>; Thu, 15 Sep 2022 15:45:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:user-agent
 :references:in-reply-to:subject:cc:to:from:sender:from:to:cc:subject
 :date; bh=AdBCQMzW0icmwL7zIGtHEgcy15u1g9oYv8UL7hGWQWk=;
 b=pRFbeevBkVrsJ4cBWmMyd1OYTHdidWokiZBzGY0TPZdpylidndyCDvk97frCncijnN
 yrhJAFIowRvfYNprp8S+j7MjsNYCfPf89N08nW3UM/PEB+qx8YknezqRT9skekyglTvD
 D7hSNM3XFft4jBnGa2nk+xDzAhbf7HnLuN0/jYwpZTkwCcSwkUDeeWKIYiE8yBOA9lgg
 nJriEcm/LQT5gJ/gzGOJ7RT2toZhC60WrvhC+4Tr7xmMxPwpHMUD5o3//fI5RW7AreLR
 N3UdjbihL8R7qQ5Ykpq8vpN3KR5eAYVIT0Jl1o1AuhGmARketIYb1t5OWpyGUQ7Ef5s3
 39sQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:user-agent
 :references:in-reply-to:subject:cc:to:from:sender:x-gm-message-state
 :from:to:cc:subject:date;
 bh=AdBCQMzW0icmwL7zIGtHEgcy15u1g9oYv8UL7hGWQWk=;
 b=4tKdDgI8fkHYf9YuAA6aSTBJXHwPQH78iBdZ+BO9NJrxNNVkIxi8tbMczkTzxvodXv
 LtWwnR318TRRrD6w+FjRRVgl15qdkXK1hEYIb3Na82MMC+ni69FsHbvC9EnwjglAh4Ip
 0wrF4i0UuqtErb5GNVHW8K4ZrEX32n4BgfrNfMj0yk0BeDdZVuG0RSQ4DGcLSWPrHsn4
 1aoyPPy7ZCGpp8C1qCzO7Rs0RFa4P9Vm6Cqi8gQGqHy9U7YQCpe3UTOZjH4i4m9YXgXR
 Q53kxNGpGXvufY4c81OGRqe1GuZoOVYnnrJgsenn0Dyk/8HJvI9cZ8wbvGgUVm00JeUW
 pgqg==
X-Gm-Message-State: ACrzQf2NUFhVu+BJCrO8Ql+ezlUuZ31eQ1R8uoLCJtGMAG401osvchRZ
 cZGfSVpnM2GrG2DK3wXM8w==
X-Google-Smtp-Source: AMsMyM7Mvg0hnvcTuQa83/zLIp9AlG1WqnEsjCSTOnXgwSlZYFRU5YFgvSiOZjDKjoUJzVa7bBojPA==
X-Received: by 2002:a05:6214:62b:b0:4aa:af9d:df2 with SMTP id
 a11-20020a056214062b00b004aaaf9d0df2mr1698251qvx.123.1663281916733; 
 Thu, 15 Sep 2022 15:45:16 -0700 (PDT)
Received: from 3c22fb11fdab.ant.amazon.com
 (pool-71-125-32-130.nycmny.fios.verizon.net. [71.125.32.130])
 by smtp.gmail.com with ESMTPSA id
 p17-20020a05620a22b100b006cdf38dd3f2sm4530073qkh.16.2022.09.15.15.45.16
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 15 Sep 2022 15:45:16 -0700 (PDT)
From: Sam Steingold <sds@HIDDEN>
To: Gregory Heytings <gregory@HIDDEN>
Subject: Re: bug#57837: 29.0.50; fit-window-to-buffer should reposition the
 buffer
In-Reply-To: <b24128855b57f8393d5b@HIDDEN> (Gregory Heytings's message
 of "Thu, 15 Sep 2022 19:34:38 +0000")
References: <lzmtb0pmrf.fsf@HIDDEN>
 <b24128855b57f8393d5b@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)
X-Attribution: Sam
X-Disclaimer: You should not expect anyone to agree with me.
Date: Thu, 15 Sep 2022 18:45:15 -0400
Message-ID: <lz5yhop890.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: sds@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

> * Gregory Heytings <tertbel@HIDDEN> [2022-09-15 19:34:38 +0000]:
>
>>
>> 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.
>>
>
> (advice-add 'fit-window-to-buffer :after
> 	    (lambda () (and (= (count-lines (point-min) (point-max)) (1- (window-height)))
> 			    (or (< (point) (point-max)) (forward-line -1) t)
> 			    (set-window-start nil (point-min)))))

Thank you.

Why shouldn't this be the default behavior?


-- 
Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113
https://lastingimpactpsychology.com https://steingoldpsychology.com
https://jihadwatch.org https://fairforall.org https://jij.org https://ffii.org
Don't hit a man when he's down -- kick him; it's easier.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 19:34:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 15:34:43 2022
Received: from localhost ([127.0.0.1]:59200 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYudG-0003EA-Qx
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 15:34:43 -0400
Received: from heytings.org ([95.142.160.155]:43022)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gregory@HIDDEN>) id 1oYudE-0003E0-87
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 15:34:41 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org;
 s=20220101; t=1663270478;
 bh=Q6q+MOrTNjV4tStrGHC6FxDqs1iq6GKWJCquPoKEb+A=;
 h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From;
 b=RX2EbKiiYWJhrhr8Obt/sXXV1E7tUHy1MI0/ZIRIQmeR9duAszAmDsb7c+iApP7Qt
 ikg8IyQpVxm/5LCghKmDcWnkCG1UmJ3qPDrsEqzL3BRgatHXxj/aE3xPS3z2Ikx3Ir
 DDbBOIn4iC+mS+THwvfD9Y9wyZuTU8I5Y91axrDd5otyQe/TUovJJBLJIjnTPzI2BH
 i4tFId/8j/0/3T2w/cQLY9/iG73H+NXnD2tzRWpuFt1y2HixzqJb8YV15ZxpulWMLh
 9vMelWimbnhPdAF7oRpmF0nInFOE15Se4alrmqqxduDoev9YGV4vRtcbPatTHP3aDA
 47iDbz6Is/a/w==
Date: Thu, 15 Sep 2022 19:34:38 +0000
From: Gregory Heytings <gregory@HIDDEN>
To: Sam Steingold <sds@HIDDEN>
Subject: Re: bug#57837: 29.0.50; fit-window-to-buffer should reposition the
 buffer
In-Reply-To: <lzmtb0pmrf.fsf@HIDDEN>
Message-ID: <b24128855b57f8393d5b@HIDDEN>
References: <lzmtb0pmrf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


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

Is that with emacs -Q?  With emacs -Q the buffer is recentered after 
fit-window-to-buffer, and half of it (with your example) is visible.  If 
you want to see the whole buffer in that case, you can one of the 
following lines to your init file:

(advice-add 'fit-window-to-buffer :before (lambda () (or (< (point) (point-max)) (previous-line))))

(advice-add 'fit-window-to-buffer :after (lambda () (enlarge-window 1)))

But that still does not guarantee that after fit-window-to-buffer the 
whole buffer will be visible, if you press C-l and repeat 
fit-window-to-buffer only the second half of the buffer is visible.  If 
you want to handle that case as well, you can use this for example:

(advice-add 'fit-window-to-buffer :after
 	    (lambda () (and (= (count-lines (point-min) (point-max)) (1- (window-height)))
 			    (or (< (point) (point-max)) (forward-line -1) t)
 			    (set-window-start nil (point-min)))))

>
> Basically, after `fit-window-to-buffer' is called, the following should 
> evaluate to t:
>
> (and (pos-visible-in-window-p (point-min))
>     (pos-visible-in-window-p (point-max)))
>

That would only be possible under the condition you mention: "when the 
buffer is smaller than the window".




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 19:07:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 15:07:32 2022
Received: from localhost ([127.0.0.1]:59181 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYuCy-0002XY-7f
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 15:07:32 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38556)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oYuCu-0002XJ-KU
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 15:07:30 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:39174)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oYuCp-0002nM-Ev; Thu, 15 Sep 2022 15:07:23 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=EF1suTf/k/BDiN48/FN9jeZ/z6R/g3ZhKcyPYQx2Aao=; b=IlN91Alk4oQ/
 7sW+LgsmFzPbJfvHs4CYlZw9XktKQDWCBz3iKTq8VjBPFIXln855L/0Aj1b6ReeKolmRwCZOn1Q1c
 8690B2ZBmB+xNCxfVmoZRo9WRCpw+U8BRNys77JhUmrDFilTCmm4IpTWTHh818GejGqSXCmUfqWib
 q352i4VP46DDugGffRBS0kPLOvzOIa7uSH6hn8wAZtkREf4XYPe6sFqhLH7DyBpsgFY786n2BjYht
 kZ7fojjhnkCISqL/LkN2IvKu1buiW5AH+KA7EHZ1zy0VOss5p+OIMs8dfzu+R+JZ2yUjxms1z1i8D
 Le54Pc4rrBE9FxaAtbjWmw==;
Received: from [87.69.77.57] (port=2392 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oYuCo-0004Uj-OI; Thu, 15 Sep 2022 15:07:23 -0400
Date: Thu, 15 Sep 2022 22:07:15 +0300
Message-Id: <835yho5ue4.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Sam Steingold <sds@HIDDEN>
In-Reply-To: <CAFsbZ7bCUH-MSV0GojYy0pUCWAfczXLtvfoNdib-RK+rfZZuoA@HIDDEN>
 (message from Sam Steingold on Thu, 15 Sep 2022 14:55:16 -0400)
Subject: Re: bug#57837: 29.0.50;
 fit-window-to-buffer should reposition the buffer
References: <lzmtb0pmrf.fsf@HIDDEN>
 <838rmkzf9m.fsf@HIDDEN>
 <lzillopk1f.fsf@HIDDEN>
 <CAFsbZ7bCUH-MSV0GojYy0pUCWAfczXLtvfoNdib-RK+rfZZuoA@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Sam Steingold <sds@HIDDEN>
> Date: Thu, 15 Sep 2022 14:55:16 -0400
> Cc: 57837 <at> debbugs.gnu.org
> 
> > >> --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---
> 
> replacing `poing-min` and `point-max` with beginning-of-text and
> end-of-text, of course...

What are beginning-of-text and end-of-text?  I don't find such
functions in Emacs.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 19:00:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 15:00:56 2022
Received: from localhost ([127.0.0.1]:59176 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYu6a-0002Nq-6F
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 15:00:56 -0400
Received: from eggs.gnu.org ([209.51.188.92]:52010)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oYu6V-0002NO-6k
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 15:00:54 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:54574)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oYu6Q-0001TP-0R; Thu, 15 Sep 2022 15:00:46 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=uVY1kxwr74ofWsPzMUZP1K6+JosHeXVzOSdJu5kqTgY=; b=TreIv6uPskoz
 wm0ZQRJpmKS0BTrOP5p7lw9WJ93m4HYZlnZlYJry83f+T1Z0XbpjwllV3+hI3c4axle6pPSZDMNI/
 W7J2pNMcIytResf5fYsU9bCn2X/FHqfV9aYvYexfVbNmjEkBERMl8m4kOJjmuXzY1zdtPYSK67SU6
 VlC3rYdW3IDiArnq5JUu0sL1jnIgLRLQJuEYTp2RvHuTWZoWO6Uw9TsQjCJlq+DvaDW9SlETLEdBx
 0mrJydI5o8I/yiPOlqt2KFCT4poA0sCVrIoCnRe23z5HMU6rhO1MJMnPE5rYHgnbYKO/2MxfadKCe
 bKRUO/qzHSVGYW+jEVOcLg==;
Received: from [87.69.77.57] (port=1990 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oYu6O-0005Jh-6p; Thu, 15 Sep 2022 15:00:45 -0400
Date: Thu, 15 Sep 2022 22:00:36 +0300
Message-Id: <838rmk5up7.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: sds@HIDDEN
In-Reply-To: <lzillopk1f.fsf@HIDDEN> (message from Sam
 Steingold on Thu, 15 Sep 2022 14:30:36 -0400)
Subject: Re: bug#57837: 29.0.50; fit-window-to-buffer should reposition the
 buffer
References: <lzmtb0pmrf.fsf@HIDDEN>
 <838rmkzf9m.fsf@HIDDEN> <lzillopk1f.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Sam Steingold <sds@HIDDEN>
> Cc: 57837 <at> debbugs.gnu.org
> Date: Thu, 15 Sep 2022 14:30:36 -0400
> 
> >> 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 think you misunderstand the contract: the function fits the window
to the buffer text, which doesn't include the (imaginary) place beyond
the last character.

When you are are EOB, doesn't "C-x =" say something like

  point=N out of N-1 (EOB)

?  Do you see what I mean by "beyond the last character"?

> I am not sure how this should be fixed

It shouldn't be fixed, because it ain't broken.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 18:55:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 14:55:36 2022
Received: from localhost ([127.0.0.1]:59171 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYu1Q-0002El-9a
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 14:55:36 -0400
Received: from mail-pg1-f182.google.com ([209.85.215.182]:39436)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sam.steingold@HIDDEN>) id 1oYu1O-0002EX-BW
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 14:55:35 -0400
Received: by mail-pg1-f182.google.com with SMTP id r23so9561715pgr.6
 for <57837 <at> debbugs.gnu.org>; Thu, 15 Sep 2022 11:55:34 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date;
 bh=u4eCaneNs7Pak3ctnLt2ZyPDzUSEvASo/MmyEBKprZ4=;
 b=BPQrxW4sjgVP81jPQ2OrvzwUPNhxHWeKHRWWSHodyfoPua0tSRWGj2GpSGzwxI2KBb
 hzhIdJ7ly1YpQqI7Ry0yfBtXR5TctsQGlaXjdBay6YO8iKThFPb5koMZeWkWHPKrRXmg
 W6YvRi5w0o0kZg6M0lzZA5nfjn6Ixxpf3INOPGKpMOqM0h8RoEbQbivDGZsVceiZvR2S
 BPvhkk7UtQzLYaqQ4VI4vedq+vJrAJhJ8Tq/YcsC5OVwOZdHq1LMfDdoh5EIqpHZXUwo
 M10FowdnVmbmwbS2RthDChRpLbjVR+27VecHLXCs/P4WFH3JldGY+EUfSnRUjg7oot5l
 OsMw==
X-Gm-Message-State: ACrzQf2b6Y38Mj4vTWRkw0u82FUryai4YaEhv1jm04Okt/eFmUmfPRmb
 1S/HFnRnABSQ4qVpLxhfAt7Cu6gV0rDYCrvWuI9Nkohqgw==
X-Google-Smtp-Source: AMsMyM7xX6QbGcHY1g55XYzFHJifa+G92tTB0YDmmEh8AgWIRr0iMq1VypwNNgUMmnWQDK08SdSIr1CrF2p2jrqbWfU=
X-Received: by 2002:a05:6a00:e85:b0:52b:5db8:f3df with SMTP id
 bo5-20020a056a000e8500b0052b5db8f3dfmr1258707pfb.14.1663268128393; Thu, 15
 Sep 2022 11:55:28 -0700 (PDT)
MIME-Version: 1.0
References: <lzmtb0pmrf.fsf@HIDDEN>
 <838rmkzf9m.fsf@HIDDEN>
 <lzillopk1f.fsf@HIDDEN>
In-Reply-To: <lzillopk1f.fsf@HIDDEN>
From: Sam Steingold <sds@HIDDEN>
Date: Thu, 15 Sep 2022 14:55:16 -0400
Message-ID: <CAFsbZ7bCUH-MSV0GojYy0pUCWAfczXLtvfoNdib-RK+rfZZuoA@HIDDEN>
Subject: Re: bug#57837: 29.0.50;
 fit-window-to-buffer should reposition the buffer
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

On Thu, 15 Sept 2022 at 14:30, Sam Steingold <sds@HIDDEN> wrote:
>
> >> 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---

replacing `poing-min` and `point-max` with beginning-of-text and
end-of-text, of course...




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 18:30:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 14:30:48 2022
Received: from localhost ([127.0.0.1]:59152 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYtdP-0001cK-NW
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 14:30:48 -0400
Received: from mail-qt1-f176.google.com ([209.85.160.176]:39876)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sam.steingold@HIDDEN>) id 1oYtdM-0001c1-CS
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 14:30:46 -0400
Received: by mail-qt1-f176.google.com with SMTP id s18so11306339qtx.6
 for <57837 <at> debbugs.gnu.org>; Thu, 15 Sep 2022 11:30:44 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:user-agent
 :references:in-reply-to:subject:cc:to:from:sender:from:to:cc:subject
 :date; bh=Olw0NV6u2Jk10w1ZAAzctK10oBlTfeswSdfrS1ALHkU=;
 b=mREveTxrxqgZNmDK+2rYMCPvJyEs+1XVxiNaWX+LkMA3MAfXShWpBHTC6UWAkKpEUj
 0a0xbzsheTeOGaol6iPdMcPgng6h5MFBPfWb9rZhamFxSJQQEDKPsGmMp8HTAdS+3wMW
 DXizyPulVc9O17Gk79YrcMt08dONyXkvdLnyDoN2m0o1UAXqaTkvznSKL/KJtp1eM67z
 WdCfUjXxK50SKJawrjNbxfVeKz4ImbAiAM3Chw0yNgTavhpGnwuUIGOElxYu3cefVGqM
 AEHJ4Flx00wceE4lcgQYzdrF0GyS+Tx39tJnOc6+q23hmzFdjWqks1v7ENl+/5BvcKLn
 cTTg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:user-agent
 :references:in-reply-to:subject:cc:to:from:sender:x-gm-message-state
 :from:to:cc:subject:date;
 bh=Olw0NV6u2Jk10w1ZAAzctK10oBlTfeswSdfrS1ALHkU=;
 b=Q7t58jXVjWXd8aDxKZ8S0t3foLevEEqW4icfG2zeKnGiiahPUHt3EUMbD41+nyv07r
 iidylrgM3edCopNYNh7pBsn7QxwJ4MNiYtoC43p+szMbK+m2dX4wz33P9AMlsjj8YWcA
 MA+Q8bKVNONxoToTpI3HwrPGWori6JAwv03yQkrB/wLwnQQSZyThqKorCSUnSH4qPGRu
 han/hi6YBC03pRfjCklnabQI/rpMKCRt6svXat6kz+W1srhwz7xJ85lrNX8klwhK0Nmn
 j99wLeZDog32VY/JWC/EwqaDZVLJayTPiQpiV4tc7ywc+0IkF/ooj/LAk4482b0sXFqU
 Ec+Q==
X-Gm-Message-State: ACrzQf1eEMAFMqpGrX4MnyLEOyr2GJ8YUC+APCN9y3ettXT+FX/bokck
 CCQpdEnfHvhtRsAL+HVofsuudkvXj4T4
X-Google-Smtp-Source: AMsMyM4BxdUB8yOEUFiujfslspsukX3cOdZ7AsPmZSi3rUOzUf3DDY4saTlfXLExX/sbpexXVdRbnA==
X-Received: by 2002:a05:622a:138b:b0:35b:b619:b87d with SMTP id
 o11-20020a05622a138b00b0035bb619b87dmr1196327qtk.146.1663266638813; 
 Thu, 15 Sep 2022 11:30:38 -0700 (PDT)
Received: from 3c22fb11fdab.ant.amazon.com
 (pool-71-125-32-130.nycmny.fios.verizon.net. [71.125.32.130])
 by smtp.gmail.com with ESMTPSA id
 f8-20020a05620a408800b006bb82221013sm5214409qko.0.2022.09.15.11.30.37
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 15 Sep 2022 11:30:38 -0700 (PDT)
From: Sam Steingold <sds@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#57837: 29.0.50; fit-window-to-buffer should reposition the
 buffer
In-Reply-To: <838rmkzf9m.fsf@HIDDEN> (Eli Zaretskii's message of "Thu, 15 Sep
 2022 21:03:33 +0300")
References: <lzmtb0pmrf.fsf@HIDDEN>
 <838rmkzf9m.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)
X-Attribution: Sam
X-Disclaimer: You should not expect anyone to agree with me.
Date: Thu, 15 Sep 2022 14:30:36 -0400
Message-ID: <lzillopk1f.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: sds@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

> * Eli Zaretskii <ryvm@HIDDEN> [2022-09-15 21:03:33 +0300]:
>
>> From: Sam Steingold <sds@HIDDEN>
>> 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at 57837 <at> debbugs.gnu.org:


Received: (at 57837) by debbugs.gnu.org; 15 Sep 2022 18:03:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 14:03:51 2022
Received: from localhost ([127.0.0.1]:59145 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYtDL-0000wd-91
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 14:03:51 -0400
Received: from eggs.gnu.org ([209.51.188.92]:34030)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oYtDJ-0000wK-E3
 for 57837 <at> debbugs.gnu.org; Thu, 15 Sep 2022 14:03:49 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:60240)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oYtDB-0001lE-VV; Thu, 15 Sep 2022 14:03:41 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ZsHv8dcwlB8mYLi0GvL5CU4hxDOmlEgaPnz9pS0ub14=; b=RyFejmiXY4s+
 kyBOvh5jmjHO4uU0m6C4zdTPYPZn54b6E3eFhasNZ//MQp6z8YIYyyiCbODm5HL/FWvVwfzb8yaHg
 QC1CpzBVIY6cybVoYeiWM9YdZy0zqYTzTHhI66yOxHwEHtFFu+GgfPO44xMRh/SC07ZK8gJwR6QXl
 HGDIaAAreJm7+QtR+yp6sGAhYXuX430VsaS7Hoao2PcMhf403uLyHTkzLJ0dcpkKs2ZSNLdVgctBJ
 tOp+Q4Qu2CVk3WuejINSgGV2tKk40gQLSZAEhtz+tvKMjXQk//OYszn0IYBPY9HneG3+m5gqifIm2
 Uk5F0NGyOOcgF5zUMqKtGg==;
Received: from [87.69.77.57] (port=4121 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oYtDB-0002qN-Bm; Thu, 15 Sep 2022 14:03:41 -0400
Date: Thu, 15 Sep 2022 21:03:33 +0300
Message-Id: <838rmkzf9m.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: sds@HIDDEN
In-Reply-To: <lzmtb0pmrf.fsf@HIDDEN> (message from Sam
 Steingold on Thu, 15 Sep 2022 13:31:48 -0400)
Subject: Re: bug#57837: 29.0.50;
 fit-window-to-buffer should reposition the buffer
References: <lzmtb0pmrf.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 57837
Cc: 57837 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Sam Steingold <sds@HIDDEN>
> 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 Sep 2022 17:31:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 15 13:31:57 2022
Received: from localhost ([127.0.0.1]:59112 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oYsiS-0008Vp-KI
	for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 13:31:57 -0400
Received: from lists.gnu.org ([209.51.188.17]:33432)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sam.steingold@HIDDEN>) id 1oYsiQ-0008Vg-Cu
 for submit <at> debbugs.gnu.org; Thu, 15 Sep 2022 13:31:55 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:34962)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sam.steingold@HIDDEN>)
 id 1oYsiQ-0002QG-7f
 for bug-gnu-emacs@HIDDEN; Thu, 15 Sep 2022 13:31:54 -0400
Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:34575)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <sam.steingold@HIDDEN>)
 id 1oYsiO-0003P0-At; Thu, 15 Sep 2022 13:31:53 -0400
Received: by mail-qt1-x832.google.com with SMTP id g12so13737145qts.1;
 Thu, 15 Sep 2022 10:31:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:subject:to
 :from:sender:from:to:cc:subject:date;
 bh=HPk7vGguGe4D6KC3mb5JgXUslZdEOwIoGDYXh+AIH8w=;
 b=nRh/Y7jEtKd7FvptOZRkjP9Pc5RZa5kmDLQzoMWlsLQs3R6/Ayt1R0rTM7hH0uZ1ty
 1m3C94CIALHfpdunDY3b3h5DEUIES7fMNsRsxW5A1Iu6ftCqjF2d/2a67K50qKmOMYsL
 K4/c7l58mDJbrE4KqJspHpwENlmOU+cz763w+i8A13WoJn3a+oEjIZioCEcBVwoSc2vV
 kc9KGRRSxq/ocVkVN24kRve4RoY6yA3pS/bJe8mlvITMRdyYnK2q5IhJawFZWYWODDw1
 Z9HyDtMTtJfS1w9yQGEr7Q29EY55TrxkCTdAKdV5mM2Sn2aQylCtFC2sFzqKUX4a2NpL
 8X5Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:reply-to:return-receipt-to:subject:to
 :from:sender:x-gm-message-state:from:to:cc:subject:date;
 bh=HPk7vGguGe4D6KC3mb5JgXUslZdEOwIoGDYXh+AIH8w=;
 b=WBM7CqFG0td9+2KPskFHptkaYWy0W8HjQQ/GGC/+hCFNONz4kQfiauTkycbc9rp6BL
 vUCXOWzGTMPnlNW7F9wNj0oAuZdUCLNe4PjrC6Rj7xsS1599iLJGMFG82Pqztapx4Qjm
 klFnhvIfQq3cYnoKkcOPt45qSLlHuDNpVUzzPlxoCFg2tDOUlLcOVdN6yjhPKWQnTIie
 94tlDkhELE9HF5HhQqZTMD1hxTaewyaqGoOvdJ6ERzRGilQukJmvu/N23cqcUrAUUnnx
 leoHD5lkWTrqGE9oJQFX9nldqYzsTFl376P/9NulNsVeQd4TZU4sb4AHEDY/r1x1NpKB
 Znkw==
X-Gm-Message-State: ACrzQf2/s29YGYRV51JTUDKSkcIIE7hn1V8sARb1Yrcv/XMtDXrH0531
 f70JfSuwvzO2jQoEapdKaDMrG1L3c8iv
X-Google-Smtp-Source: AMsMyM6XD0J1W+0m8sNkGTrQbI5dSCW1yDKcxvVbTDrNPznuVOLu+KEtwxgClQAS23elEGi1/ivMrw==
X-Received: by 2002:ac8:5c0e:0:b0:35b:b4d8:bd09 with SMTP id
 i14-20020ac85c0e000000b0035bb4d8bd09mr869720qti.311.1663263110030; 
 Thu, 15 Sep 2022 10:31:50 -0700 (PDT)
Received: from 3c22fb11fdab.ant.amazon.com
 (pool-71-125-32-130.nycmny.fios.verizon.net. [71.125.32.130])
 by smtp.gmail.com with ESMTPSA id
 a12-20020a05620a16cc00b006a5d2eb58b2sm4077223qkn.33.2022.09.15.10.31.49
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 15 Sep 2022 10:31:49 -0700 (PDT)
From: Sam Steingold <sds@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.50; fit-window-to-buffer should reposition the buffer
X-Attribution: Sam
X-Disclaimer: You should not expect anyone to agree with me.
Date: Thu, 15 Sep 2022 13:31:48 -0400
Message-ID: <lzmtb0pmrf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2607:f8b0:4864:20::832;
 envelope-from=sam.steingold@HIDDEN; helo=mail-qt1-x832.google.com
X-Spam_score_int: -14
X-Spam_score: -1.5
X-Spam_bar: -
X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249,
 FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.8 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: sds@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.8 (-)

Hi,

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?

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

Thank you.


In GNU Emacs 29.0.50 (build 1, x86_64-apple-darwin21.6.0, NS
 appkit-2113.60 Version 12.5.1 (Build 21G83)) of 2022-09-13 built on
 3c22fb11fdab.ant.amazon.com
Repository revision: 7df898d532f922ea2a7acce4446bc35eec1da38e
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.5.1

Configured using:
 'configure 'LDFLAGS=-fsanitize=address -fno-omit-frame-pointer'
 'CFLAGS=-g -O0 -fsanitize=address -fno-omit-frame-pointer''

Configured features:
ACL GIF GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
PDUMPER PNG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP ZLIB

Important settings:
  value of $LANG: C
  locale-coding-system: utf-8-unix

Major mode: Help

Minor modes in effect:
  outline-minor-mode: t
  pyvenv-mode: t
  shell-dirtrack-mode: t
  global-edit-server-edit-mode: t
  winner-mode: t
  which-function-mode: t
  url-handler-mode: t
  desktop-save-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  isearch-fold-quotes-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t


-- 
Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113
https://lastingimpactpsychology.com https://steingoldpsychology.com
https://camera.org https://www.dhimmitude.org https://fairforall.org
If you need to keep a secret, keep it a secret that you have a secret to keep.




Acknowledgement sent to sds@HIDDEN:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#57837; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 16 Sep 2022 19:00:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.