From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#57837: 29.0.50; fit-window-to-buffer should reposition the buffer Date: Fri, 16 Sep 2022 08:53:44 +0300 Message-ID: <83v8pn50gn.fsf@gnu.org> References: <838rmkzf9m.fsf@gnu.org> <835yho5ue4.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32557"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 57837@debbugs.gnu.org To: sds@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 16 07:54:09 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oZ4Ij-0008FZ-Mw for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Sep 2022 07:54:09 +0200 Original-Received: from localhost ([::1]:60440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZ4Ii-0003fL-63 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Sep 2022 01:54:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZ4Ic-0003ey-AE for bug-gnu-emacs@gnu.org; Fri, 16 Sep 2022 01:54:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42169) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oZ4Ic-0001u8-27 for bug-gnu-emacs@gnu.org; Fri, 16 Sep 2022 01:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oZ4Ib-0000tv-OW for bug-gnu-emacs@gnu.org; Fri, 16 Sep 2022 01:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Sep 2022 05:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57837 X-GNU-PR-Package: emacs Original-Received: via spool by 57837-submit@debbugs.gnu.org id=B57837.16633076393455 (code B ref 57837); Fri, 16 Sep 2022 05:54:01 +0000 Original-Received: (at 57837) by debbugs.gnu.org; 16 Sep 2022 05:53:59 +0000 Original-Received: from localhost ([127.0.0.1]:41247 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZ4IY-0000te-NC for submit@debbugs.gnu.org; Fri, 16 Sep 2022 01:53:59 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZ4IW-0000tO-Fv for 57837@debbugs.gnu.org; Fri, 16 Sep 2022 01:53:56 -0400 Original-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 ) 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==; Original-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 ) id 1oZ4IQ-0006pL-HC; Fri, 16 Sep 2022 01:53:50 -0400 In-Reply-To: (message from Sam Steingold on Thu, 15 Sep 2022 18:52:30 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:242691 Archived-At: > From: Sam Steingold > Cc: 57837@debbugs.gnu.org > Date: Thu, 15 Sep 2022 18:52:30 -0400 > > > * Eli Zaretskii [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.