[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: save-restriction, save-excursion
From: |
David Kastrup |
Subject: |
Re: save-restriction, save-excursion |
Date: |
17 Sep 2002 04:33:49 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Ryan Yeske <rcyeske+spam@vcn.bc.ca> writes:
> pokerface <pokerface@use.net> writes:
>
> > I am beginning to study Emacs Lisp and I have the following question:
> >
> > Why is it wrong to write (save-restriction
> > (save-excursion
> > ....))
> >
> > and it is recommended instead to write
> > (save-excursion
> > (save-restriction
> > ....))
>
> From the node "Narrowing" in the elisp manual:
>
> `save-restriction' does _not_ restore point and the mark; use
> `save-excursion' for that. If you use both `save-restriction' and
> `save-excursion' together, `save-excursion' should come first (on
> the outside). Otherwise, the old point value would be restored
> with temporary narrowing still in effect. If the old point value
> were outside the limits of the temporary narrowing, this would
> fail to restore it accurately.
Hmmm. What if I have a restriction active and write
(save-excursion
(save-restriction
(widen)
(goto (point-min))))
When the restriction gets restored, point will lie outside of the
restored restriction. Wouldn't that cause trouble?
Should one rather have
(save-excursion
(save-restriction
When the change of restriction is to something narrower, but
(save-restriction
(save-excursion
when the change is to something wider?
Or is this nonsense for some reason?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David.Kastrup@t-online.de