GNU bug report logs - #12170
save-excursion fails boundary case with recenter

Previous Next

Package: emacs;

Reported by: "Bill Brodie" <wbrodie <at> panix.com>

Date: Fri, 10 Aug 2012 02:01:02 UTC

Severity: normal

Tags: notabug

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: martin rudalics <rudalics <at> gmx.at>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 12170 <at> debbugs.gnu.org, Bill Brodie <wbrodie <at> panix.com>
Subject: bug#12170: save-excursion fails boundary case with recenter
Date: Fri, 10 Aug 2012 18:46:39 +0200
> 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




This bug report was last modified 8 years and 62 days ago.

Previous Next


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