[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12170: save-excursion fails boundary case with recenter

From: martin rudalics
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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]