From: David Kastrup <David.Kastrup@t-online.de>
Subject: Re: save-restriction, save-excursion
Date: 17 Sep 2002 04:33:49 +0200 [thread overview]
Message-ID: <x5hegppcoi.fsf@tupik.goethe.zz> (raw)
In-Reply-To: 87ofaxcr3e.fsf@cut.hotdog.tmp
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
next prev parent reply other threads:[~2002-09-17 2:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-16 23:31 save-restriction, save-excursion pokerface
2002-09-17 2:02 ` Ryan Yeske
2002-09-17 2:33 ` David Kastrup [this message]
2002-09-17 6:24 ` Ryan Yeske
2002-09-18 22:17 ` pokerface
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=x5hegppcoi.fsf@tupik.goethe.zz \
--to=david.kastrup@t-online.de \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).