From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: "Bill Brodie" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 02:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 12170@debbugs.gnu.org X-Debbugs-Original-To: Received: via spool by submit@debbugs.gnu.org id=B.134456400615880 (code B ref -1); Fri, 10 Aug 2012 02:01:02 +0000 Received: (at submit) by debbugs.gnu.org; 10 Aug 2012 02:00:06 +0000 Received: from localhost ([127.0.0.1]:45676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzeWC-00047z-Tq for submit@debbugs.gnu.org; Thu, 09 Aug 2012 22:00:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60998) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sze4X-0003Uc-No for submit@debbugs.gnu.org; Thu, 09 Aug 2012 21:31:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzdwZ-0003LO-Qc for submit@debbugs.gnu.org; Thu, 09 Aug 2012 21:23:16 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:42196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzdwZ-0003LJ-NQ for submit@debbugs.gnu.org; Thu, 09 Aug 2012 21:23:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzdwY-0002Cu-Gu for bug-gnu-emacs@gnu.org; Thu, 09 Aug 2012 21:23:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzdwV-0003L2-Pt for bug-gnu-emacs@gnu.org; Thu, 09 Aug 2012 21:23:14 -0400 Received: from mailbackend.panix.com ([166.84.1.89]:52054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzdwV-0003Ky-MD for bug-gnu-emacs@gnu.org; Thu, 09 Aug 2012 21:23:11 -0400 Received: from Chianti (cpe-67-250-32-171.nyc.res.rr.com [67.250.32.171]) by mailbackend.panix.com (Postfix) with ESMTP id 0572228FD7; Thu, 9 Aug 2012 21:23:11 -0400 (EDT) From: "Bill Brodie" Date: Thu, 9 Aug 2012 21:23:04 -0400 Message-ID: <000001cd7696$b0e93d60$12bbb820$@com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01CD7675.29D79D60" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac12lrCrUpu/i3v/RrS3ANz77XXu7w== Content-Language: en-us X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Mailman-Approved-At: Thu, 09 Aug 2012 22:00:03 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) This is a multi-part message in MIME format. ------=_NextPart_000_0001_01CD7675.29D79D60 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Running GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601) of 2012-06-10 on MARVIN under Windows 7. Define: (defun f (n) (save-excursion (forward-line (- n)) (recenter 0))) Let H be the window height in lines, and suppose that point is positioned at the beginning of line L > H. Despite 'save-excursion', (f K) moves point if K = H. It leaves point unchanged for any other value of K, 0 <= K < L. ------=_NextPart_000_0001_01CD7675.29D79D60 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Running = GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601) of 2012-06-10 on MARVIN under = Windows 7.

 

Define:

 

         &= nbsp;      (defun f (n) (save-excursion = (forward-line (- n)) (recenter 0)))

 

Let H be the = window height in lines, and suppose that point is positioned at the = beginning of line L > H.

 

Despite = ‘save-excursion’, (f K) moves point if K =3D H.  It = leaves point unchanged for any other value of K, 0 <=3D K < = L.

 

 

------=_NextPart_000_0001_01CD7675.29D79D60-- From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 09:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Bill Brodie Cc: 12170@debbugs.gnu.org Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134459175526628 (code B ref 12170); Fri, 10 Aug 2012 09:43:02 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 09:42:35 +0000 Received: from localhost ([127.0.0.1]:46034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szljm-0006vR-Q6 for submit@debbugs.gnu.org; Fri, 10 Aug 2012 05:42:35 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:36870) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1Szljk-0006vK-Ih for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 05:42:33 -0400 Received: (qmail invoked by alias); 10 Aug 2012 09:34:17 -0000 Received: from 62-47-36-71.adsl.highway.telekom.at (EHLO [62.47.36.71]) [62.47.36.71] by mail.gmx.net (mp012) with SMTP; 10 Aug 2012 11:34:17 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+gHZFhDImgKTtDQsype5h85S+8P0XfURrDYybhx/ WprE47Xb+LuZCo Message-ID: <5024D593.7080305@gmx.at> Date: Fri, 10 Aug 2012 11:34:11 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> In-Reply-To: <000001cd7696$b0e93d60$12bbb820$@com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > (defun f (n) (save-excursion (forward-line (- n)) (recenter > 0))) > > > > Let H be the window height in lines, and suppose that point is positioned at > the beginning of line L > H. > > > > Despite 'save-excursion', (f K) moves point if K = H. It leaves point > unchanged for any other value of K, 0 <= K < L. I'm not sure whether I clearly understand your scenario. Suppose with emacs -Q I evaluate (progn (defun f (n) (save-excursion (forward-line (- n)) (recenter 0))) (let ((buffer (switch-to-buffer "foo")) (height (window-height (get-buffer-window "foo")))) (insert-char 10 (* height 2)) (let ((pt (point))) (f height) (message "old %s new %s" pt (point))))) Then the values printed by the message are equal. Please elaborate. Thanks, martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Bastien Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 09:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: martin rudalics Cc: 12170@debbugs.gnu.org, Bill Brodie Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134459271928032 (code B ref 12170); Fri, 10 Aug 2012 09:59:01 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 09:58:39 +0000 Received: from localhost ([127.0.0.1]:46062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzlzL-0007I4-2o for submit@debbugs.gnu.org; Fri, 10 Aug 2012 05:58:39 -0400 Received: from mail-we0-f172.google.com ([74.125.82.172]:48377) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzlzI-0007Hw-Dn for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 05:58:37 -0400 Received: by weyu54 with SMTP id u54so914723wey.3 for <12170@debbugs.gnu.org>; Fri, 10 Aug 2012 02:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:date:message-id:mime-version:content-type; bh=0PaC4EotQuNSFxTyNVgalI9CaAkf8wcSm9GVeBO4JaM=; b=Qf+U592CopEloaELdMUxxaN9cMC9A8aLWf3e4U2O8o7TifLVMMnsBsiBkC+OYzfPJ3 Ged2NpNVIqmKOJWmNNAy/UYf8XQpkGZGVYKYTcl7eUNflCMrncnJ+gmQ787n/zjr09ez z9DpxtGZkIj56mIvmWnPTef9I268CKZSeBRRASHECPV8bBuTG6gQlW2O2EHq19c1GwCR 9W357eD2x7T6VpIOgQXuomMaAgpytVdTcg9FtkskEaJkRavLb/QHGDUBwkVA9Lcq/44t mnBD2PHc7l/ky82sg09jDqr8KlzH7wS6gutOl28uTcVbWzQA++QwvesXB1U00LPL6yLw k+fA== Received: by 10.180.106.97 with SMTP id gt1mr4740451wib.5.1344592221010; Fri, 10 Aug 2012 02:50:21 -0700 (PDT) Received: from myhost.localdomain (mar75-2-81-56-68-112.fbx.proxad.net. [81.56.68.112]) by mx.google.com with ESMTPS id w7sm6801133wiz.0.2012.08.10.02.50.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Aug 2012 02:50:20 -0700 (PDT) Received: by myhost.localdomain (Postfix, from userid 1000) id E818D8832; Fri, 10 Aug 2012 11:50:50 +0200 (CEST) From: Bastien In-Reply-To: <5024D593.7080305@gmx.at> (martin rudalics's message of "Fri, 10 Aug 2012 11:34:11 +0200") Organization: GNU References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) Date: Fri, 10 Aug 2012 11:50:50 +0200 Message-ID: <87lihnkrd1.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) martin rudalics writes: > Then the values printed by the message are equal. Indeed. > Please elaborate. I think the OP lacks something like `save-visual-excursion'. -- Bastien From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 13:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Bastien Cc: 12170@debbugs.gnu.org, Bill Brodie Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134460432616205 (code B ref 12170); Fri, 10 Aug 2012 13:13:02 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 13:12:06 +0000 Received: from localhost ([127.0.0.1]:46405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szp0Y-0004DI-8P for submit@debbugs.gnu.org; Fri, 10 Aug 2012 09:12:06 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:58333) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1Szp0W-0004DB-JZ for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 09:12:05 -0400 Received: (qmail invoked by alias); 10 Aug 2012 13:03:48 -0000 Received: from 62-47-41-199.adsl.highway.telekom.at (EHLO [62.47.41.199]) [62.47.41.199] by mail.gmx.net (mp027) with SMTP; 10 Aug 2012 15:03:48 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18C8GswIxUCyJ8yGVzcxBxHmsqfCWlHw2s/OPhD42 HUS6ianrmql4IE Message-ID: <502506AB.6050700@gmx.at> Date: Fri, 10 Aug 2012 15:03:39 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <87lihnkrd1.fsf@gnu.org> In-Reply-To: <87lihnkrd1.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > I think the OP lacks something like `save-visual-excursion'. Then `save-window-excursion' should handle it. martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: "Bill Brodie" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 13:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: "'martin rudalics'" Cc: 12170@debbugs.gnu.org Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134460653319387 (code B ref 12170); Fri, 10 Aug 2012 13:49:02 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 13:48:53 +0000 Received: from localhost ([127.0.0.1]:46447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szpa9-00052e-2r for submit@debbugs.gnu.org; Fri, 10 Aug 2012 09:48:53 -0400 Received: from mailbackend.panix.com ([166.84.1.89]:36774) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szpa3-00052T-V2 for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 09:48:49 -0400 Received: from Chianti (cpe-67-250-32-171.nyc.res.rr.com [67.250.32.171]) by mailbackend.panix.com (Postfix) with ESMTP id EC40128D1B; Fri, 10 Aug 2012 09:40:31 -0400 (EDT) From: "Bill Brodie" References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> In-Reply-To: <5024D593.7080305@gmx.at> Date: Fri, 10 Aug 2012 09:40:24 -0400 Message-ID: <003601cd76fd$b21cd590$165680b0$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac1221BBmxBbVopzTRW5A9LwDYg7jgAH3hvw Content-Language: en-us X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) Martin, Thanks for the test code and clarification request. (1) By "window height", I meant the number of lines displayed for the actual buffer, not counting the mode line or minibuffer. It turns out this is one less than the value returned by `window-height'. (2) The value of `point' changes (the cursor "hops", in other words) when the window is redisplayed, or when control returns to the user. Here is code that will produce the bug (with emacs -Q): (progn (defun f (n) (save-excursion (forward-line (- n)) (recenter 0))) (let ((buffer (switch-to-buffer "foo")) (height (1- (window-height (get-buffer-window "foo"))))) (insert-char 10 (* height 2)) (let ((pt (point))) (f height) (redisplay) (message "height %s old %s new %s" height pt (point))))) If you leave out the `redisplay' call, on the other hand, old = new in the message -- but after control returns to the user, point has still been moved in the buffer. Bill -----Original Message----- From: martin rudalics [mailto:rudalics@gmx.at] Sent: Friday, August 10, 2012 5:34 AM To: Bill Brodie Cc: 12170@debbugs.gnu.org Subject: Re: bug#12170: save-excursion fails boundary case with recenter > (defun f (n) (save-excursion (forward-line (- n)) (recenter > 0))) > > > > Let H be the window height in lines, and suppose that point is positioned at > the beginning of line L > H. > > > > Despite 'save-excursion', (f K) moves point if K = H. It leaves point > unchanged for any other value of K, 0 <= K < L. I'm not sure whether I clearly understand your scenario. Suppose with emacs -Q I evaluate (progn (defun f (n) (save-excursion (forward-line (- n)) (recenter 0))) (let ((buffer (switch-to-buffer "foo")) (height (window-height (get-buffer-window "foo")))) (insert-char 10 (* height 2)) (let ((pt (point))) (f height) (message "old %s new %s" pt (point))))) Then the values printed by the message are equal. Please elaborate. Thanks, martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 14:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Bill Brodie Cc: 12170@debbugs.gnu.org Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134461052825750 (code B ref 12170); Fri, 10 Aug 2012 14:56:01 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 14:55:28 +0000 Received: from localhost ([127.0.0.1]:47057 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzqcZ-0006hH-Ua for submit@debbugs.gnu.org; Fri, 10 Aug 2012 10:55:28 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:44679) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SzqcX-0006h7-NU for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 10:55:27 -0400 Received: (qmail invoked by alias); 10 Aug 2012 14:47:08 -0000 Received: from 62-47-41-199.adsl.highway.telekom.at (EHLO [62.47.41.199]) [62.47.41.199] by mail.gmx.net (mp041) with SMTP; 10 Aug 2012 16:47:08 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX180HSRcu1Q0rYpeAFGB5T7vvEjP33K387GxfjjfpJ O5O5RKnATHZXMx Message-ID: <50251EED.3010804@gmx.at> Date: Fri, 10 Aug 2012 16:47:09 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> In-Reply-To: <003601cd76fd$b21cd590$165680b0$@com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > (1) By "window height", I meant the number of lines displayed for the actual > buffer, not counting the mode line or minibuffer. It turns out this is one > less than the value returned by `window-height'. > > (2) The value of `point' changes (the cursor "hops", in other words) when > the window is redisplayed, or when control returns to the user. > > Here is code that will produce the bug (with emacs -Q): > > (progn > (defun f (n) > (save-excursion (forward-line (- n)) (recenter 0))) > (let ((buffer (switch-to-buffer "foo")) > (height (1- (window-height (get-buffer-window "foo"))))) > (insert-char 10 (* height 2)) > (let ((pt (point))) > (f height) > (redisplay) > (message "height %s old %s new %s" height pt (point))))) > > If you leave out the `redisplay' call, on the other hand, old = new in the > message -- but after control returns to the user, point has still been moved > in the buffer. I see it now, thanks. Surprisingly it doesn't show up with code like (progn (defmacro save-this-window-excursion (&rest body) "..." (let ((start (make-symbol "start")) (point (make-symbol "point"))) `(let ((,start (copy-marker (window-start))) (,point (copy-marker (window-point)))) (save-selected-window (progn ,@body)) (set-window-start (selected-window) ,start t) (set-window-point (selected-window) ,point)))) (defun f (n) (save-this-window-excursion (forward-line (- n)) (recenter 0))) (let ((buffer (switch-to-buffer "foo")) (height (1- (window-height (get-buffer-window "foo"))))) (insert-char 10 (* height 2)) (let ((pt (point))) (f height) (redisplay) (message "height %s old %s new %s" height pt (point))))) so I'd suspect the culprit somewhere in redisplay_window's code if (w->optional_new_start w->optional_new_start is 1 from `recenter' && CHARPOS (startp) >= BEGV && CHARPOS (startp) <= ZV) { w->optional_new_start = 0; start_display (&it, w, startp); move_it_to (&it, PT, 0, it.last_visible_y, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); if (IT_CHARPOS (it) == PT) w->force_start = 1; /* IT may overshoot PT if text at PT is invisible. */ else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT) w->force_start = 1; w->force_start 1 will cause redisplay to honor the start position set up by `recenter' despite of save_excursion_restore's Fgoto_char. } But I don't have the slightest idea how calling (set-window-start (selected-window) ,start t) would remedy this. Eli will soon teach us a lesson here. martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 15:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: "Bill Brodie" Cc: 'martin rudalics' , 12170@debbugs.gnu.org Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134461158727297 (code B ref 12170); Fri, 10 Aug 2012 15:14:01 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 15:13:07 +0000 Received: from localhost ([127.0.0.1]:47091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szqte-00076E-IA for submit@debbugs.gnu.org; Fri, 10 Aug 2012 11:13:06 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:35846) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szqtc-000766-0M for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 11:13:04 -0400 Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q7AF4lnn000341; Fri, 10 Aug 2012 11:04:47 -0400 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 4DA13B4177; Fri, 10 Aug 2012 11:04:47 -0400 (EDT) From: Stefan Monnier Message-ID: References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> Date: Fri, 10 Aug 2012 11:04:47 -0400 In-Reply-To: <003601cd76fd$b21cd590$165680b0$@com> (Bill Brodie's message of "Fri, 10 Aug 2012 09:40:24 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4306=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4306> : streams <797204> : uri <1188930> X-Spam-Score: -3.5 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) > (progn > (defun f (n) > (save-excursion (forward-line (- n)) (recenter 0))) > (let ((buffer (switch-to-buffer "foo")) > (height (1- (window-height (get-buffer-window "foo"))))) > (insert-char 10 (* height 2)) > (let ((pt (point))) > (f height) > (redisplay) > (message "height %s old %s new %s" height pt (point))))) As mentioned by Martin, this is a misunderstanding about what save-excursion does and what `point' is. Every buffer can have many different `point's (it basically has one per window, accessible via `window-point' and changeable via `set-window-point', plus one for itself, called `point'). `save-excursion' preserves only `point'. `recenter' changes `window-point'. But `point' and `window-point' are linked (point is set to window-point and vice-versa in various occasions), so they're often confused. It seems your real problem is not that `point' changes but that the cursor ends up in a different position than the one you wanted (the cursor position, is represented by `window-point' rather than by `point'), right? If so, you want to preserve window-point. And there's nothing quite like save-excursion to preserve window-point. You can try save-window-excursion, tho it will do a lot more than you asked for. Or otherwise manually read window-point at the beginning and set-window-point at the end. Stefan From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: "Bill Brodie" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 15:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: "'Stefan Monnier'" Cc: 'martin rudalics' , 12170@debbugs.gnu.org Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134461409230912 (code B ref 12170); Fri, 10 Aug 2012 15:55:01 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 15:54:52 +0000 Received: from localhost ([127.0.0.1]:47142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzrY3-00082X-Nw for submit@debbugs.gnu.org; Fri, 10 Aug 2012 11:54:51 -0400 Received: from mailbackend.panix.com ([166.84.1.89]:57725) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzrY1-00082P-Lo for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 11:54:50 -0400 Received: from Chianti (cpe-67-250-32-171.nyc.res.rr.com [67.250.32.171]) by mailbackend.panix.com (Postfix) with ESMTP id 195CE28354; Fri, 10 Aug 2012 11:46:33 -0400 (EDT) From: "Bill Brodie" References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> In-Reply-To: Date: Fri, 10 Aug 2012 11:46:25 -0400 Message-ID: <006101cd770f$4cd7d380$e6877a80$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac13CX2lO64ULKKRTeCzmRKokxrwUAAAMwwQ Content-Language: en-us X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) Thanks, Stefan. The purpose of the original code was to scroll the window so that a previous section marker is at the top of the window only if it will fit without moving point: (defun f () (interactive) (save-excursion (re-search-backward "^__") (beginning-of-line) (recenter 0))) I was surprised to discover that this fails if the span of lines from the previous section marker to the current position, inclusive, just barely won't fit in the window. Perhaps the moral is that `save-excursion' should not enclose any code, including `recenter', that affects how buffers are displayed within windows. Bill -----Original Message----- > (progn > (defun f (n) > (save-excursion (forward-line (- n)) (recenter 0))) > (let ((buffer (switch-to-buffer "foo")) > (height (1- (window-height (get-buffer-window "foo"))))) > (insert-char 10 (* height 2)) > (let ((pt (point))) > (f height) > (redisplay) > (message "height %s old %s new %s" height pt (point))))) As mentioned by Martin, this is a misunderstanding about what save-excursion does and what `point' is. Every buffer can have many different `point's (it basically has one per window, accessible via `window-point' and changeable via `set-window-point', plus one for itself, called `point'). `save-excursion' preserves only `point'. `recenter' changes `window-point'. But `point' and `window-point' are linked (point is set to window-point and vice-versa in various occasions), so they're often confused. It seems your real problem is not that `point' changes but that the cursor ends up in a different position than the one you wanted (the cursor position, is represented by `window-point' rather than by `point'), right? If so, you want to preserve window-point. And there's nothing quite like save-excursion to preserve window-point. You can try save-window-excursion, tho it will do a lot more than you asked for. Or otherwise manually read window-point at the beginning and set-window-point at the end. Stefan From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 16:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: martin rudalics Cc: 12170@debbugs.gnu.org, Bill Brodie Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446159891284 (code B ref 12170); Fri, 10 Aug 2012 16:27:01 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 16:26:29 +0000 Received: from localhost ([127.0.0.1]:47191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szs2e-0000Ke-A3 for submit@debbugs.gnu.org; Fri, 10 Aug 2012 12:26:28 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:44733) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szs2b-0000KY-Vb for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 12:26:26 -0400 Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q7AGI8tK004898; Fri, 10 Aug 2012 12:18:09 -0400 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id B61BAB4177; Fri, 10 Aug 2012 12:18:08 -0400 (EDT) From: Stefan Monnier Message-ID: References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> Date: Fri, 10 Aug 2012 12:18:08 -0400 In-Reply-To: <50251EED.3010804@gmx.at> (martin rudalics's message of "Fri, 10 Aug 2012 16:47:09 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4306=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4306> : streams <797228> : uri <1188987> X-Spam-Score: -3.5 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) > But I don't have the slightest idea how calling > (set-window-start (selected-window) ,start t) > would remedy this. Eli will soon teach us a lesson here. The redisplay tries to make sure (window-)point is visible, which can either be done by changing (window-)point or by changing window-start. The first happens when you use a scrolling operation (which sets window-start), the other happens in response to normal navigation in the buffer. Knowing which to do when is not obvious, but IIUC if window-start has not been changed, then the redisplay assumes that it is free to change (window-)point, whereas otherwise it will assume that it should not change (window-)point but can instead change window-start. Stefan From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 16:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 12170@debbugs.gnu.org, Bill Brodie Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446176863908 (code B ref 12170); Fri, 10 Aug 2012 16:55:01 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 16:54:46 +0000 Received: from localhost ([127.0.0.1]:47232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzsU1-00010y-Tx for submit@debbugs.gnu.org; Fri, 10 Aug 2012 12:54:46 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:58771) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SzsTz-00010p-L4 for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 12:54:44 -0400 Received: (qmail invoked by alias); 10 Aug 2012 16:46:26 -0000 Received: from 62-47-41-199.adsl.highway.telekom.at (EHLO [62.47.41.199]) [62.47.41.199] by mail.gmx.net (mp019) with SMTP; 10 Aug 2012 18:46:26 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/uRH5JqcHuaLjZziRjQiRnobP9qzg9h4T5JGQN4b MyYfyc3rZLIbyZ Message-ID: <50253AEF.4020705@gmx.at> Date: Fri, 10 Aug 2012 18:46:39 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > As mentioned by Martin, this is a misunderstanding about what > save-excursion does and what `point' is. As a matter of fact, I thought so initially but did not mention it. > Every buffer can have many different `point's (it basically has one per > window, accessible via `window-point' and changeable via > `set-window-point', plus one for itself, called `point'). > `save-excursion' preserves only `point'. > `recenter' changes `window-point'. The scenario shows up with one single window showing that buffer. > But `point' and `window-point' are linked (point is set to window-point > and vice-versa in various occasions), so they're often confused. > > It seems your real problem is not that `point' changes but that the > cursor ends up in a different position than the one you wanted (the > cursor position, is represented by `window-point' rather than by > `point'), right? > > If so, you want to preserve window-point. And there's nothing quite > like save-excursion to preserve window-point. You can try > save-window-excursion, tho it will do a lot more than you asked for. > Or otherwise manually read window-point at the beginning and > set-window-point at the end. Neither of these cut it. Maybe the purpose of `recenter' is to overrule, if necessary, any further point movement until the next redisplay. But I still don't understand how putting in a call of `set-window-start' with NOFORCE t can calm it. martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 16:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Bill Brodie Cc: 12170@debbugs.gnu.org, 'Stefan Monnier' Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446176983931 (code B ref 12170); Fri, 10 Aug 2012 16:55:01 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 16:54:58 +0000 Received: from localhost ([127.0.0.1]:47235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzsUD-00011L-SS for submit@debbugs.gnu.org; Fri, 10 Aug 2012 12:54:58 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:50998) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SzsUB-00011E-TB for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 12:54:56 -0400 Received: (qmail invoked by alias); 10 Aug 2012 16:46:38 -0000 Received: from 62-47-41-199.adsl.highway.telekom.at (EHLO [62.47.41.199]) [62.47.41.199] by mail.gmx.net (mp024) with SMTP; 10 Aug 2012 18:46:38 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/TwiweJZrTbue2165SuGCrlD/0EIN02U6P5bYn4I Ahsb/D1l3fkDUF Message-ID: <50253AFD.8070606@gmx.at> Date: Fri, 10 Aug 2012 18:46:53 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <006101cd770f$4cd7d380$e6877a80$@com> In-Reply-To: <006101cd770f$4cd7d380$e6877a80$@com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > Perhaps the moral is that `save-excursion' should not enclose any code, > including `recenter', that affects how buffers are displayed within windows. Ideally, code should not call `recenter' unless it's sure that no point-changing code follows it before the next redisplay. Or better, code should call `recenter' iff it definitely wants to overrule any point-changing code that follows it. martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 16:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 12170@debbugs.gnu.org, Bill Brodie Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446177204000 (code B ref 12170); Fri, 10 Aug 2012 16:56:02 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 16:55:20 +0000 Received: from localhost ([127.0.0.1]:47240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzsUZ-00012T-TD for submit@debbugs.gnu.org; Fri, 10 Aug 2012 12:55:20 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:50808) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SzsUY-00012M-BK for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 12:55:18 -0400 Received: (qmail invoked by alias); 10 Aug 2012 16:47:01 -0000 Received: from 62-47-41-199.adsl.highway.telekom.at (EHLO [62.47.41.199]) [62.47.41.199] by mail.gmx.net (mp071) with SMTP; 10 Aug 2012 18:47:01 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18fMj8raI4f+hTnd/5pGf+x3V1uSM0YLl1jVfGwYs x84XfOnSJ1br3u Message-ID: <50253B12.9010206@gmx.at> Date: Fri, 10 Aug 2012 18:47:14 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > Knowing which to do when is not obvious, but IIUC if window-start has > not been changed, then the redisplay assumes that it is free to change > (window-)point, whereas otherwise it will assume that it should not > change (window-)point but can instead change window-start. IIUC redisplay_window respects the window start position specified in w->start provided w->force_start or w->frozen_window_start_p hold. Scrolling, recentering, and things like `move-to-window-line' set the former (frozen_window_start_p seems purely internal). The question is whether these should prevail subsequent point movement or, subsequent point movement should prevail and reset these flags. martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 17:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: martin rudalics Cc: 12170@debbugs.gnu.org, Bill Brodie Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446189328994 (code B ref 12170); Fri, 10 Aug 2012 17:16:02 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 17:15:32 +0000 Received: from localhost ([127.0.0.1]:47273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szso7-0002Ky-RM for submit@debbugs.gnu.org; Fri, 10 Aug 2012 13:15:32 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:50761) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szso6-0002Kr-2G for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 13:15:30 -0400 Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q7AH7Cf4013863; Fri, 10 Aug 2012 13:07:12 -0400 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id A8CB7B4177; Fri, 10 Aug 2012 13:07:12 -0400 (EDT) From: Stefan Monnier Message-ID: References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <50253B12.9010206@gmx.at> Date: Fri, 10 Aug 2012 13:07:12 -0400 In-Reply-To: <50253B12.9010206@gmx.at> (martin rudalics's message of "Fri, 10 Aug 2012 18:47:14 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4306=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4306> : streams <797242> : uri <1189022> X-Spam-Score: -3.5 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) >> Knowing which to do when is not obvious, but IIUC if window-start has >> not been changed, then the redisplay assumes that it is free to change >> (window-)point, whereas otherwise it will assume that it should not >> change (window-)point but can instead change window-start. > IIUC redisplay_window respects the window start position specified in > w->start provided w->force_start or w->frozen_window_start_p hold. > Scrolling, recentering, and things like `move-to-window-line' set the > former (frozen_window_start_p seems purely internal). The question is > whether these should prevail subsequent point movement or, subsequent > point movement should prevail and reset these flags. Point movement can't convenient reset those flags because it's very frequent (so speed matters) and because those flags are about windows, whereas point movement is only indirectly related to windows (and only if the selected window happens to display the current buffer). Stefan From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 19:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Bill Brodie Cc: rudalics@gmx.at, 12170@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134462557618763 (code B ref 12170); Fri, 10 Aug 2012 19:07:01 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 19:06:16 +0000 Received: from localhost ([127.0.0.1]:47378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzuXI-0004sa-9X for submit@debbugs.gnu.org; Fri, 10 Aug 2012 15:06:16 -0400 Received: from mtaout20.012.net.il ([80.179.55.166]:42650) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzuXF-0004sR-TB for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 15:06:15 -0400 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0M8J00600YKUVQ00@a-mtaout20.012.net.il> for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 21:57:55 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8J006DKZCJK4F0@a-mtaout20.012.net.il>; Fri, 10 Aug 2012 21:57:55 +0300 (IDT) Date: Fri, 10 Aug 2012 21:58:02 +0300 From: Eli Zaretskii In-reply-to: <003601cd76fd$b21cd590$165680b0$@com> X-012-Sender: halo1@inter.net.il Message-id: <834noaefr9.fsf@gnu.org> References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) > From: "Bill Brodie" > Date: Fri, 10 Aug 2012 09:40:24 -0400 > Cc: 12170@debbugs.gnu.org > > (1) By "window height", I meant the number of lines displayed for the actual > buffer, not counting the mode line or minibuffer. It turns out this is one > less than the value returned by `window-height'. As documented, window-height returns the height of the window including the mode line (and the header line, if there is any). So the above is expected. From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Aug 2012 19:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: martin rudalics Cc: 12170@debbugs.gnu.org, wbrodie@panix.com Reply-To: Eli Zaretskii Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134462580419102 (code B ref 12170); Fri, 10 Aug 2012 19:11:02 +0000 Received: (at 12170) by debbugs.gnu.org; 10 Aug 2012 19:10:04 +0000 Received: from localhost ([127.0.0.1]:47384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szuax-0004y2-P1 for submit@debbugs.gnu.org; Fri, 10 Aug 2012 15:10:04 -0400 Received: from mtaout20.012.net.il ([80.179.55.166]:43424) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Szuav-0004xa-A0 for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 15:10:01 -0400 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0M8J00700ZDC1R00@a-mtaout20.012.net.il> for 12170@debbugs.gnu.org; Fri, 10 Aug 2012 22:01:44 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8J00632ZIVUY70@a-mtaout20.012.net.il>; Fri, 10 Aug 2012 22:01:44 +0300 (IDT) Date: Fri, 10 Aug 2012 22:01:51 +0300 From: Eli Zaretskii In-reply-to: <50251EED.3010804@gmx.at> X-012-Sender: halo1@inter.net.il Message-id: <83393uefkw.fsf@gnu.org> References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) > Date: Fri, 10 Aug 2012 16:47:09 +0200 > From: martin rudalics > Cc: 12170@debbugs.gnu.org > > (defun f (n) > (save-this-window-excursion (forward-line (- n)) (recenter 0))) > > (let ((buffer (switch-to-buffer "foo")) > (height (1- (window-height (get-buffer-window "foo"))))) > (insert-char 10 (* height 2)) > (let ((pt (point))) > (f height) > (redisplay) > (message "height %s old %s new %s" height pt (point))))) > > so I'd suspect the culprit somewhere in redisplay_window's code By saying "culprit" you mean you think this is a bug? I think Stefan explained why it isn't. > if (w->optional_new_start > > w->optional_new_start is 1 from `recenter' > > && CHARPOS (startp) >= BEGV > && CHARPOS (startp) <= ZV) > { > w->optional_new_start = 0; > start_display (&it, w, startp); > move_it_to (&it, PT, 0, it.last_visible_y, -1, > MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); > if (IT_CHARPOS (it) == PT) > w->force_start = 1; > /* IT may overshoot PT if text at PT is invisible. */ > else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT) > w->force_start = 1; > > w->force_start 1 will cause redisplay to honor the start position set up > by `recenter' Only if point will be visible when window is displayed starting at startp. > But I don't have the slightest idea how calling > > (set-window-start (selected-window) ,start t) > > would remedy this. Eli will soon teach us a lesson here. Not sure there's a lesson here to learn, but set-window-start sets the w->force_start flag unconditionally, so it will hold even if point is not in the displayed portion of the window (i.e., point will move). Does that explain things? From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 09:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 12170@debbugs.gnu.org, Bill Brodie Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446779835792 (code B ref 12170); Sat, 11 Aug 2012 09:40:02 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 09:39:43 +0000 Received: from localhost ([127.0.0.1]:48193 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T08AZ-0001VN-Hh for submit@debbugs.gnu.org; Sat, 11 Aug 2012 05:39:43 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:37677) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1T08AX-0001VG-Co for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 05:39:42 -0400 Received: (qmail invoked by alias); 11 Aug 2012 09:31:20 -0000 Received: from 62-47-60-244.adsl.highway.telekom.at (EHLO [62.47.60.244]) [62.47.60.244] by mail.gmx.net (mp030) with SMTP; 11 Aug 2012 11:31:20 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/5siFGZ6/5FjCkhpiSL0JiESYqTlTwXSbNp67l0L MIsfEA/3D/FaOw Message-ID: <50262674.8060008@gmx.at> Date: Sat, 11 Aug 2012 11:31:32 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <834noaefr9.fsf@gnu.org> In-Reply-To: <834noaefr9.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) >> (1) By "window height", I meant the number of lines displayed for the actual >> buffer, not counting the mode line or minibuffer. It turns out this is one >> less than the value returned by `window-height'. > > As documented, window-height returns the height of the window > including the mode line (and the header line, if there is any). So > the above is expected. To avoid this confusion `window-total-height' should be used instead of `window-height'. The "number of lines displayed for the actual buffer" is returned by the function `window-body-height'. martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 09:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 12170@debbugs.gnu.org, wbrodie@panix.com Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446780415896 (code B ref 12170); Sat, 11 Aug 2012 09:41:02 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 09:40:41 +0000 Received: from localhost ([127.0.0.1]:48200 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T08BU-0001X2-Te for submit@debbugs.gnu.org; Sat, 11 Aug 2012 05:40:41 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:56979) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1T08BS-0001Wu-0q for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 05:40:38 -0400 Received: (qmail invoked by alias); 11 Aug 2012 09:32:16 -0000 Received: from 62-47-60-244.adsl.highway.telekom.at (EHLO [62.47.60.244]) [62.47.60.244] by mail.gmx.net (mp016) with SMTP; 11 Aug 2012 11:32:16 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX196+j98//Z6MmotqVXjAbnrIcQFUWhdOvsmeOdJJp 2dIIaEbYKMzQhu Message-ID: <502626AD.1080505@gmx.at> Date: Sat, 11 Aug 2012 11:32:29 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> In-Reply-To: <83393uefkw.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) >> (defun f (n) >> (save-this-window-excursion (forward-line (- n)) (recenter 0))) >> >> (let ((buffer (switch-to-buffer "foo")) >> (height (1- (window-height (get-buffer-window "foo"))))) >> (insert-char 10 (* height 2)) >> (let ((pt (point))) >> (f height) >> (redisplay) >> (message "height %s old %s new %s" height pt (point))))) >> >> so I'd suspect the culprit somewhere in redisplay_window's code > > By saying "culprit" you mean you think this is a bug? I suppose so, yes. > I think Stefan > explained why it isn't. With the OP's last recipe, `point' moves to the position implied by the `recenter' call. With the `save-this-window-excursion' macro I gave, `point' moves to the position implied by that macro instead and the position implied by the `recenter' call is ignored. So here something unexplained happens. If we wanted to document the current behavior, we'd have to tell users that if they call any of the window-related movement functions like `recenter', `move-to-window-line', or `set-window-start' with a nil NOFORCE argument, then `point' may move after the next redisplay in order to honor the window start position implied by the last of these functions executed. Do you agree so far? If you agree, then we'd have to explain why a subsequent invocation of `set-window-start' with NOFORCE t can override the setting of the window start position implied by the last invocation of one of the functions mentioned above. >> w->force_start 1 will cause redisplay to honor the start position set up >> by `recenter' > > Only if point will be visible when window is displayed starting at > startp. I completely miss you here. >> But I don't have the slightest idea how calling >> >> (set-window-start (selected-window) ,start t) >> >> would remedy this. Eli will soon teach us a lesson here. > > Not sure there's a lesson here to learn, but set-window-start sets the > w->force_start flag unconditionally, IMHO if (NILP (noforce)) w->force_start = 1; means "conditionally". > so it will hold even if point is > not in the displayed portion of the window (i.e., point will move). > Does that explain things? Not yet ;-) martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 11:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: martin rudalics Cc: 12170@debbugs.gnu.org, wbrodie@panix.com Reply-To: Eli Zaretskii Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134468398114585 (code B ref 12170); Sat, 11 Aug 2012 11:20:02 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 11:19:41 +0000 Received: from localhost ([127.0.0.1]:48291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T09jI-0003nB-MU for submit@debbugs.gnu.org; Sat, 11 Aug 2012 07:19:41 -0400 Received: from mtaout23.012.net.il ([80.179.55.175]:49291) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T09jE-0003mw-Ss for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 07:19:38 -0400 Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0M8L00D0089R0A00@a-mtaout23.012.net.il> for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 14:11:14 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8L00CBO8EPW940@a-mtaout23.012.net.il>; Sat, 11 Aug 2012 14:11:14 +0300 (IDT) Date: Sat, 11 Aug 2012 14:11:23 +0300 From: Eli Zaretskii In-reply-to: <502626AD.1080505@gmx.at> X-012-Sender: halo1@inter.net.il Message-id: <83sjbtd6p0.fsf@gnu.org> References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) > Date: Sat, 11 Aug 2012 11:32:29 +0200 > From: martin rudalics > CC: wbrodie@panix.com, 12170@debbugs.gnu.org > > >> (defun f (n) > >> (save-this-window-excursion (forward-line (- n)) (recenter 0))) > >> > >> (let ((buffer (switch-to-buffer "foo")) > >> (height (1- (window-height (get-buffer-window "foo"))))) > >> (insert-char 10 (* height 2)) > >> (let ((pt (point))) > >> (f height) > >> (redisplay) > >> (message "height %s old %s new %s" height pt (point))))) > >> > >> so I'd suspect the culprit somewhere in redisplay_window's code > > > > By saying "culprit" you mean you think this is a bug? > > I suppose so, yes. > > > I think Stefan > > explained why it isn't. > > With the OP's last recipe, `point' moves to the position implied by the > `recenter' call. With the `save-this-window-excursion' macro I gave, > `point' moves to the position implied by that macro instead and the > position implied by the `recenter' call is ignored. So here something > unexplained happens. Your recipe also calls set-window-point, which moves point on its own, and also does this: /* We have to make sure that redisplay updates the window to show the new value of point. */ if (!EQ (window, selected_window)) ++windows_or_buffers_changed; The windows_or_buffers_changed flag will force a thorough redisplay. Given this, do we still have something unexplained? > If we wanted to document the current behavior, we'd have to tell users > that if they call any of the window-related movement functions like > `recenter', `move-to-window-line', or `set-window-start' with a nil > NOFORCE argument, then `point' may move after the next redisplay in > order to honor the window start position implied by the last of these > functions executed. Do you agree so far? I guess. > If you agree, then we'd have to explain why a subsequent invocation of > `set-window-start' with NOFORCE t can override the setting of the window > start position implied by the last invocation of one of the functions > mentioned above. You didn't just call set-window-start, you also called set-window-point. If I remove that second call, the result of your code is very different, and the window start position as the macro set it is still in effect when control is returned. > >> w->force_start 1 will cause redisplay to honor the start position set up > >> by `recenter' > > > > Only if point will be visible when window is displayed starting at > > startp. > > I completely miss you here. I meant this code: w->optional_new_start = 0; start_display (&it, w, startp); move_it_to (&it, PT, 0, it.last_visible_y, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); if (IT_CHARPOS (it) == PT) w->force_start = 1; /* IT may overshoot PT if text at PT is invisible. */ else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT) w->force_start = 1; It only sets the force_start flag if displaying the window starting at startp will show point visible inside the window. The call to move_it_to moves in a simulated display lines, and stops either at point or at the last pixel position visible in the window, whichever happens first. The subsequent test that IT_CHARPOS (it) == PT verifies that it stopped at point and not because it reached the end of the text displayed in the window. Ergo, sometimes setting the window start position will not be honored. That's what the comment above all this means when it says: /* If someone specified a new starting point but did not insist, check whether it can be used. */ "Did not insist" means that whoever set w->optional_new_start did not also set w->force_start. The "check whether it can be used" part describes what I just explained. > > Not sure there's a lesson here to learn, but set-window-start sets the > > w->force_start flag unconditionally, > > IMHO > > if (NILP (noforce)) > w->force_start = 1; > > means "conditionally". Right. So my current theory is that set-window-point is what makes the difference. From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 14:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 12170@debbugs.gnu.org, wbrodie@panix.com Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446954752804 (code B ref 12170); Sat, 11 Aug 2012 14:32:02 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 14:31:15 +0000 Received: from localhost ([127.0.0.1]:49451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0Cig-0000jA-P7 for submit@debbugs.gnu.org; Sat, 11 Aug 2012 10:31:15 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:42208) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1T0Cid-0000j1-P9 for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 10:31:12 -0400 Received: (qmail invoked by alias); 11 Aug 2012 14:22:49 -0000 Received: from 62-47-59-168.adsl.highway.telekom.at (EHLO [62.47.59.168]) [62.47.59.168] by mail.gmx.net (mp010) with SMTP; 11 Aug 2012 16:22:49 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/ijFsPrHjiJPQHnmLaT0W3SBL1I+7CPAB6A6ycTR 3CoKrg3jMdfW3l Message-ID: <50266AAF.4000504@gmx.at> Date: Sat, 11 Aug 2012 16:22:39 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> <83sjbtd6p0.fsf@gnu.org> In-Reply-To: <83sjbtd6p0.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.3 (/) > Your recipe also calls set-window-point, which moves point on its own, > and also does this: > > /* We have to make sure that redisplay updates the window to show > the new value of point. */ > if (!EQ (window, selected_window)) > ++windows_or_buffers_changed; > > The windows_or_buffers_changed flag will force a thorough redisplay. > > Given this, do we still have something unexplained? Yes, because `set-window-point' doesn't set windows_or_buffers_changed in the case at hand since the window is the selected window. Or am I missing something? >> If you agree, then we'd have to explain why a subsequent invocation of >> `set-window-start' with NOFORCE t can override the setting of the window >> start position implied by the last invocation of one of the functions >> mentioned above. > > You didn't just call set-window-start, you also called > set-window-point. If I remove that second call, the result of your > code is very different, and the window start position as the macro set > it is still in effect when control is returned. But `set-window-point' should be equivalent to `goto-char' here because the window is the selected window. >> >> w->force_start 1 will cause redisplay to honor the start position set up >> >> by `recenter' >> > >> > Only if point will be visible when window is displayed starting at >> > startp. >> >> I completely miss you here. > > I meant this code: > > w->optional_new_start = 0; > start_display (&it, w, startp); > move_it_to (&it, PT, 0, it.last_visible_y, -1, > MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); > if (IT_CHARPOS (it) == PT) > w->force_start = 1; > /* IT may overshoot PT if text at PT is invisible. */ > else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT) > w->force_start = 1; > > It only sets the force_start flag if displaying the window starting at > startp will show point visible inside the window. The call to > move_it_to moves in a simulated display lines, and stops either at > point or at the last pixel position visible in the window, whichever > happens first. The subsequent test that IT_CHARPOS (it) == PT > verifies that it stopped at point and not because it reached the end > of the text displayed in the window. > > Ergo, sometimes setting the window start position will not be > honored. That's what the comment above all this means when it says: > > /* If someone specified a new starting point but did not insist, > check whether it can be used. */ > > "Did not insist" means that whoever set w->optional_new_start did not > also set w->force_start. The "check whether it can be used" part > describes what I just explained. I believe you. But it remains a mystery to me why `set-window-point' should make a difference here. As a matter of fact, if I do (progn (defmacro save-this-window-excursion (&rest body) "..." (let ((start (make-symbol "start")) (point (make-symbol "point"))) `(let ((,start (copy-marker (window-start))) (,point (copy-marker (window-point)))) (save-selected-window (progn ,@body)) (set-window-start (selected-window) ,start t) (with-current-buffer (window-buffer (selected-window)) (goto-char ,point))))) (defun f (n) (save-this-window-excursion (forward-line (- n)) (recenter 0))) (let ((buffer (switch-to-buffer "foo")) (height (1- (window-height (get-buffer-window "foo"))))) (insert-char 10 (* height 2)) (let ((pt (point))) (f height) (redisplay) (message "height %s old %s new %s" height pt (point))))) I get the same results as with `set-window-point'. IMHO the `set-window-start' call makes the difference but I don't understand why. martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 15:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: martin rudalics Cc: 12170@debbugs.gnu.org, wbrodie@panix.com Reply-To: Eli Zaretskii Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446983227135 (code B ref 12170); Sat, 11 Aug 2012 15:19:02 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 15:18:42 +0000 Received: from localhost ([127.0.0.1]:49557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0DSc-0001r2-D0 for submit@debbugs.gnu.org; Sat, 11 Aug 2012 11:18:42 -0400 Received: from mtaout20.012.net.il ([80.179.55.166]:44415) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0DSZ-0001qu-OL for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 11:18:41 -0400 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0M8L00H00IWLDB00@a-mtaout20.012.net.il> for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 18:10:17 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8L00H6JJH4HI10@a-mtaout20.012.net.il>; Sat, 11 Aug 2012 18:10:16 +0300 (IDT) Date: Sat, 11 Aug 2012 18:10:26 +0300 From: Eli Zaretskii In-reply-to: <50266AAF.4000504@gmx.at> X-012-Sender: halo1@inter.net.il Message-id: <83mx21cvml.fsf@gnu.org> References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> <83sjbtd6p0.fsf@gnu.org> <50266AAF.4000504@gmx.at> X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) > Date: Sat, 11 Aug 2012 16:22:39 +0200 > From: martin rudalics > CC: wbrodie@panix.com, 12170@debbugs.gnu.org > > (progn > (defmacro save-this-window-excursion (&rest body) > "..." > (let ((start (make-symbol "start")) > (point (make-symbol "point"))) > `(let ((,start (copy-marker (window-start))) > (,point (copy-marker (window-point)))) > (save-selected-window > (progn ,@body)) > (set-window-start (selected-window) ,start t) > (with-current-buffer (window-buffer (selected-window)) > (goto-char ,point))))) > > (defun f (n) > (save-this-window-excursion (forward-line (- n)) (recenter 0))) > > (let ((buffer (switch-to-buffer "foo")) > (height (1- (window-height (get-buffer-window "foo"))))) > (insert-char 10 (* height 2)) > (let ((pt (point))) > (f height) > (redisplay) > (message "height %s old %s new %s" height pt (point))))) > > I get the same results as with `set-window-point'. IMHO the > `set-window-start' call makes the difference but I don't understand why. Maybe. If it's really important, I could try looking at this in the debugger, although doing so to investigate such situations is notoriously hard, because redisplay is entered several times. IMO, save-excursion is simply not designed to make sure display isn't changed in such cases. It's for excursions into other portions of the buffer for processing those other parts, without affecting display. If the processing also scrolls the screen or calls recenter or otherwise affects the display, all bets are off, because scrolling can legitimately move point, and when that happens, it is no longer clear that restoring point should take precedence over window-start etc. From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 16:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 12170@debbugs.gnu.org, wbrodie@panix.com Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134470162911915 (code B ref 12170); Sat, 11 Aug 2012 16:14:02 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 16:13:49 +0000 Received: from localhost ([127.0.0.1]:49661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0EJx-000368-4m for submit@debbugs.gnu.org; Sat, 11 Aug 2012 12:13:49 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:40337) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1T0EJu-000360-Cd for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 12:13:47 -0400 Received: (qmail invoked by alias); 11 Aug 2012 16:05:23 -0000 Received: from 62-47-59-168.adsl.highway.telekom.at (EHLO [62.47.59.168]) [62.47.59.168] by mail.gmx.net (mp028) with SMTP; 11 Aug 2012 18:05:23 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1983/4gvs9887adhANoB/tCbl0zR5xH5lGtujMF3c At9lw+IgHQv+Eg Message-ID: <502682BA.5050704@gmx.at> Date: Sat, 11 Aug 2012 18:05:14 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> <83sjbtd6p0.fsf@gnu.org> <50266AAF.4000504@gmx.at> <83mx21cvml.fsf@gnu.org> In-Reply-To: <83mx21cvml.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.3 (/) > Maybe. If it's really important, It's not. > I could try looking at this in the > debugger, although doing so to investigate such situations is > notoriously hard, because redisplay is entered several times. > > IMO, save-excursion is simply not designed to make sure display isn't > changed in such cases. Agreed. But `save-window-excursion' doesn't handle this case either. So the difference should be in one of the four assignments w->start_at_line_beg = 0; w->update_mode_line = 1; w->last_modified = 0; w->last_overlay_modified = 0; and I'd obviously vote for the first one. Interesting side-effect. martin From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: "Bill Brodie" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 16:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: "'Eli Zaretskii'" , "'martin rudalics'" Cc: 12170@debbugs.gnu.org Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134470297713862 (code B ref 12170); Sat, 11 Aug 2012 16:37:01 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 16:36:17 +0000 Received: from localhost ([127.0.0.1]:49687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0Efh-0003bX-Er for submit@debbugs.gnu.org; Sat, 11 Aug 2012 12:36:17 -0400 Received: from mailbackend.panix.com ([166.84.1.89]:57180) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0Eff-0003bQ-EW for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 12:36:16 -0400 Received: from Shallot (222.sub-166-248-12.myvzw.com [166.248.12.222]) by mailbackend.panix.com (Postfix) with ESMTP id 25FC528ED9; Sat, 11 Aug 2012 12:27:51 -0400 (EDT) From: "Bill Brodie" References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> <83sjbtd6p0.fsf@gnu.org> <50266AAF.4000504@gmx.at> <83mx21cvml.fsf@gnu.org> In-Reply-To: <83mx21cvml.fsf@gnu.org> Date: Sat, 11 Aug 2012 12:27:42 -0400 Message-ID: <7FB5A65153794BB5B65ED03DC376935B@Shallot> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: Ac1302r3JAZsudhSRWmbHMp04vlrvAACj82g X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7601.17609 X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) >From my point of view (the OP), I've generally used save-excursion to assemble or manipulate information elsewhere in the buffer or in other buffers, without explicit reference to window displays. This seems like a natural restriction. I've modified my original code to perform the window operations outside the form. Thanks for the illuminating discussion. -----Original Message----- From: Eli Zaretskii [mailto:eliz@gnu.org] IMO, save-excursion is simply not designed to make sure display isn't changed in such cases. It's for excursions into other portions of the buffer for processing those other parts, without affecting display. If the processing also scrolls the screen or calls recenter or otherwise affects the display, all bets are off, because scrolling can legitimately move point, and when that happens, it is no longer clear that restoring point should take precedence over window-start etc. From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 16:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: martin rudalics Cc: 12170@debbugs.gnu.org, wbrodie@panix.com Reply-To: Eli Zaretskii Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134470320914191 (code B ref 12170); Sat, 11 Aug 2012 16:41:02 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 16:40:09 +0000 Received: from localhost ([127.0.0.1]:49694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0EjQ-0003gq-Um for submit@debbugs.gnu.org; Sat, 11 Aug 2012 12:40:09 -0400 Received: from mtaout22.012.net.il ([80.179.55.172]:48986) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0EjP-0003gg-95 for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 12:40:08 -0400 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0M8L00600N5EM200@a-mtaout22.012.net.il> for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 19:31:44 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8L006XSN8V5BE0@a-mtaout22.012.net.il>; Sat, 11 Aug 2012 19:31:44 +0300 (IDT) Date: Sat, 11 Aug 2012 19:31:53 +0300 From: Eli Zaretskii In-reply-to: <502682BA.5050704@gmx.at> X-012-Sender: halo1@inter.net.il Message-id: <83ipcpcruu.fsf@gnu.org> References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> <83sjbtd6p0.fsf@gnu.org> <50266AAF.4000504@gmx.at> <83mx21cvml.fsf@gnu.org> <502682BA.5050704@gmx.at> X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) > Date: Sat, 11 Aug 2012 18:05:14 +0200 > From: martin rudalics > CC: wbrodie@panix.com, 12170@debbugs.gnu.org > > So the difference should be in one of the four assignments > > w->start_at_line_beg = 0; > w->update_mode_line = 1; > w->last_modified = 0; > w->last_overlay_modified = 0; > > and I'd obviously vote for the first one. Interesting side-effect. FWIW, there are only 2 places in redisplay that look at w->start_at_line_beg, but neither your nor Bill's recipe don't exercise the code of either of these two places. From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Aug 2012 16:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: rudalics@gmx.at Cc: 12170@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134470427915770 (code B ref 12170); Sat, 11 Aug 2012 16:58:01 +0000 Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 16:57:59 +0000 Received: from localhost ([127.0.0.1]:49712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0F0h-00046I-EO for submit@debbugs.gnu.org; Sat, 11 Aug 2012 12:57:59 -0400 Received: from mtaout20.012.net.il ([80.179.55.166]:64030) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0F0e-000469-O4 for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 12:57:57 -0400 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0M8L00I00O0UB600@a-mtaout20.012.net.il> for 12170@debbugs.gnu.org; Sat, 11 Aug 2012 19:49:32 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8L00I8YO2J9B30@a-mtaout20.012.net.il>; Sat, 11 Aug 2012 19:49:32 +0300 (IDT) Date: Sat, 11 Aug 2012 19:49:41 +0300 From: Eli Zaretskii In-reply-to: <83ipcpcruu.fsf@gnu.org> X-012-Sender: halo1@inter.net.il Message-id: <83has9cr16.fsf@gnu.org> References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> <83sjbtd6p0.fsf@gnu.org> <50266AAF.4000504@gmx.at> <83mx21cvml.fsf@gnu.org> <502682BA.5050704@gmx.at> <83ipcpcruu.fsf@gnu.org> X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) > Date: Sat, 11 Aug 2012 19:31:53 +0300 > From: Eli Zaretskii > Cc: 12170@debbugs.gnu.org, wbrodie@panix.com > > > Date: Sat, 11 Aug 2012 18:05:14 +0200 > > From: martin rudalics > > CC: wbrodie@panix.com, 12170@debbugs.gnu.org > > > > So the difference should be in one of the four assignments > > > > w->start_at_line_beg = 0; > > w->update_mode_line = 1; > > w->last_modified = 0; > > w->last_overlay_modified = 0; > > > > and I'd obviously vote for the first one. Interesting side-effect. > > FWIW, there are only 2 places in redisplay that look at > w->start_at_line_beg, but neither your nor Bill's recipe don't > exercise the code of either of these two places. As another FWIW, running the recipe with save-window-excursion shows that set-window-configuration called after the body tries to set the window start at position 1 and the window point at position 67. But the last position in a 33-line window that starts at position 1 is 33, so these two values cannot be satisfied at once. From unknown Sun Jun 22 07:50:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12170: save-excursion fails boundary case with recenter Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Aug 2012 10:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 12170@debbugs.gnu.org Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.134476798623492 (code B ref 12170); Sun, 12 Aug 2012 10:40:02 +0000 Received: (at 12170) by debbugs.gnu.org; 12 Aug 2012 10:39:46 +0000 Received: from localhost ([127.0.0.1]:50641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0VaD-00066q-US for submit@debbugs.gnu.org; Sun, 12 Aug 2012 06:39:46 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:49554) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1T0VaB-00066j-GQ for 12170@debbugs.gnu.org; Sun, 12 Aug 2012 06:39:44 -0400 Received: (qmail invoked by alias); 12 Aug 2012 10:31:16 -0000 Received: from 62-47-36-185.adsl.highway.telekom.at (EHLO [62.47.36.185]) [62.47.36.185] by mail.gmx.net (mp020) with SMTP; 12 Aug 2012 12:31:16 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX195OcwlYw15wXDxLWN7w7ezJG2KDPcFRr+0JOIrIu sTYaUdeExbsGPC Message-ID: <502785E9.20906@gmx.at> Date: Sun, 12 Aug 2012 12:31:05 +0200 From: martin rudalics MIME-Version: 1.0 References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> <83sjbtd6p0.fsf@gnu.org> <50266AAF.4000504@gmx.at> <83mx21cvml.fsf@gnu.org> <502682BA.5050704@gmx.at> <83ipcpcruu.fsf@gnu.org> <83has9cr16.fsf@gnu.org> In-Reply-To: <83has9cr16.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > As another FWIW, running the recipe with save-window-excursion shows > that set-window-configuration called after the body tries to set the > window start at position 1 and the window point at position 67. But > the last position in a 33-line window that starts at position 1 is 33, > so these two values cannot be satisfied at once. Due to the fact that we use markers when storing start and point positions. Usually the point position prevails. But apparently `recenter' is stronger. martin From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 24 23:48:59 2017 Received: (at control) by debbugs.gnu.org; 25 Mar 2017 03:48:59 +0000 Received: from localhost ([127.0.0.1]:43053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crchH-0006L1-EP for submit@debbugs.gnu.org; Fri, 24 Mar 2017 23:48:59 -0400 Received: from mail-it0-f54.google.com ([209.85.214.54]:36299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crchF-0006Ko-Hl for control@debbugs.gnu.org; Fri, 24 Mar 2017 23:48:58 -0400 Received: by mail-it0-f54.google.com with SMTP id w124so26995238itb.1 for ; Fri, 24 Mar 2017 20:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=qlz6w1AusQ70MpRvnect8xmwhxPxl4FH2IlQ+/auEag=; b=b/e26l9ZNPX8ZpkBeCEsnyBUkmKKqwfcEPsXohPvRKB/Ax9e/jq6N6MZ0ADgAuDj4m M4tStYsrf9MmuUCyiI2zI/0NRz4fP/pSboPFWB0uva/SFpic1x6cV6ruKsWhG2e79Obe jb6MTm2qC2cL1kC6eBZcsjs/GIYIzKJGIuMy94zpNpe50buzsl+pkrQ0AyWFu94WyJ8q IxM6cEU8AXjesk4NtDJXABqqc+HYY9HLtlFT7uejyPrDISLWQomASTgwZJIrvNrB/yip ztvkIBVsBrkDj3zIYfK74RtEB1UDWnS0n4NDJ3AAXoCGo0LxCLDPyRrbX4CYCZCzyuJp Bptg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=qlz6w1AusQ70MpRvnect8xmwhxPxl4FH2IlQ+/auEag=; b=M6pCFZvFL8dwvvuOVK3OdC4hql9fYItdP181vhUEAM4bjFai0OYodLNsfG2/JrTuus WZeV7wpeOW4MpD7DBb8ON6d77uhfjdFtk/W2AX+cx3hLQr/Gcwv6Xph99Dr40viwyzuE IDz3ZlpayfnfFiOHEtt8aBFmTWDnsaz6tv6K7j4ckUiMKdiVJHp/DI70t/fJ0I0vxBvB L7P83Lz9r6x1UV6N3JbTm2jAerXh0llCTdvugfjy+jjvys5PpyxgRVW1lnRI76FMvsPM swXGcjivBm4i/OJ6E13ahlqWLimTrZA7FZdrunK826SnOSwY4KojijKb3ghN2tsbf0YQ 7q6A== X-Gm-Message-State: AFeK/H0GToVJqB1QjyqJ4wf2moP05jx8lezpEYHn9OBBK+bUsMHQ4A/EyJtO38AtUnGxVQ== X-Received: by 10.36.1.208 with SMTP id 199mr409542itk.20.1490413731899; Fri, 24 Mar 2017 20:48:51 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id p201sm1985823itp.3.2017.03.24.20.48.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Mar 2017 20:48:51 -0700 (PDT) From: npostavs@users.sourceforge.net To: control@debbugs.gnu.org Subject: Re: bug#12170: save-excursion fails boundary case with recenter References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> <502626AD.1080505@gmx.at> <83sjbtd6p0.fsf@gnu.org> <50266AAF.4000504@gmx.at> <83mx21cvml.fsf@gnu.org> <7FB5A65153794BB5B65ED03DC376935B@Shallot> Date: Fri, 24 Mar 2017 23:50:15 -0400 In-Reply-To: <7FB5A65153794BB5B65ED03DC376935B@Shallot> (Bill Brodie's message of "Sat, 11 Aug 2012 12:27:42 -0400") Message-ID: <87tw6i10co.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) tags 12170 notabug close 12170 quit "Bill Brodie" writes: > From my point of view (the OP), I've generally used save-excursion to > assemble or manipulate information elsewhere in the buffer or in other > buffers, without explicit reference to window displays. This seems like a > natural restriction. > > I've modified my original code to perform the window operations outside the > form. Thanks for the illuminating discussion. > > -----Original Message----- > From: Eli Zaretskii [mailto:eliz@gnu.org] > > IMO, save-excursion is simply not designed to make sure display isn't > changed in such cases. It's for excursions into other portions of the > buffer for processing those other parts, without affecting display. > If the processing also scrolls the screen or calls recenter or > otherwise affects the display, all bets are off, because scrolling can > legitimately move point, and when that happens, it is no longer clear > that restoring point should take precedence over window-start etc.