From: "Bill Brodie" <wbrodie@panix.com>
To: "'martin rudalics'" <rudalics@gmx.at>
Cc: 12170@debbugs.gnu.org
Subject: bug#12170: save-excursion fails boundary case with recenter
Date: Fri, 10 Aug 2012 09:40:24 -0400 [thread overview]
Message-ID: <003601cd76fd$b21cd590$165680b0$@com> (raw)
In-Reply-To: <5024D593.7080305@gmx.at>
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
next prev parent reply other threads:[~2012-08-10 13:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 1:23 bug#12170: save-excursion fails boundary case with recenter Bill Brodie
2012-08-10 9:34 ` martin rudalics
2012-08-10 9:50 ` Bastien
2012-08-10 13:03 ` martin rudalics
2012-08-10 13:40 ` Bill Brodie [this message]
2012-08-10 14:47 ` martin rudalics
2012-08-10 16:18 ` Stefan Monnier
2012-08-10 16:47 ` martin rudalics
2012-08-10 17:07 ` Stefan Monnier
2012-08-10 19:01 ` Eli Zaretskii
2012-08-11 9:32 ` martin rudalics
2012-08-11 11:11 ` Eli Zaretskii
2012-08-11 14:22 ` martin rudalics
2012-08-11 15:10 ` Eli Zaretskii
2012-08-11 16:05 ` martin rudalics
2012-08-11 16:31 ` Eli Zaretskii
2012-08-11 16:49 ` Eli Zaretskii
2012-08-12 10:31 ` martin rudalics
2012-08-11 16:27 ` Bill Brodie
2012-08-10 15:04 ` Stefan Monnier
2012-08-10 15:46 ` Bill Brodie
2012-08-10 16:46 ` martin rudalics
2012-08-10 16:46 ` martin rudalics
2012-08-10 18:58 ` Eli Zaretskii
2012-08-11 9:31 ` martin rudalics
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='003601cd76fd$b21cd590$165680b0$@com' \
--to=wbrodie@panix.com \
--cc=12170@debbugs.gnu.org \
--cc=rudalics@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.