From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#12170: save-excursion fails boundary case with recenter Date: Sat, 11 Aug 2012 11:32:29 +0200 Message-ID: <502626AD.1080505@gmx.at> References: <000001cd7696$b0e93d60$12bbb820$@com> <5024D593.7080305@gmx.at> <003601cd76fd$b21cd590$165680b0$@com> <50251EED.3010804@gmx.at> <83393uefkw.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1344677570 6278 80.91.229.3 (11 Aug 2012 09:32:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 11 Aug 2012 09:32:50 +0000 (UTC) Cc: 12170@debbugs.gnu.org, wbrodie@panix.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 11 11:32:49 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T083s-0002Uh-5c for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Aug 2012 11:32:48 +0200 Original-Received: from localhost ([::1]:54556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T083r-0007GT-C0 for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Aug 2012 05:32:47 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T083n-0007G8-At for bug-gnu-emacs@gnu.org; Sat, 11 Aug 2012 05:32:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T083m-0004gM-EX for bug-gnu-emacs@gnu.org; Sat, 11 Aug 2012 05:32:43 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T083m-0004gI-B5 for bug-gnu-emacs@gnu.org; Sat, 11 Aug 2012 05:32:42 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T08Bq-0001Xd-8u for bug-gnu-emacs@gnu.org; Sat, 11 Aug 2012 05:41:02 -0400 X-Loop: help-debbugs@gnu.org 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: Original-Received: via spool by 12170-submit@debbugs.gnu.org id=B12170.13446780415896 (code B ref 12170); Sat, 11 Aug 2012 09:41:02 +0000 Original-Received: (at 12170) by debbugs.gnu.org; 11 Aug 2012 09:40:41 +0000 Original-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 Original-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 Original-Received: (qmail invoked by alias); 11 Aug 2012 09:32:16 -0000 Original-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 In-Reply-To: <83393uefkw.fsf@gnu.org> X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:63033 Archived-At: >> (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