From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: pokerface Newsgroups: gmane.emacs.help Subject: Re: save-restriction, save-excursion Date: 18 Sep 2002 22:17:52 GMT Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: <87ofaxcr3e.fsf@cut.hotdog.tmp> <87fzw9ceye.fsf@cut.hotdog.tmp> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1032387963 28593 127.0.0.1 (18 Sep 2002 22:26:03 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 18 Sep 2002 22:26:03 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17rnGk-0007Qy-00 for ; Thu, 19 Sep 2002 00:26:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17rnGy-0001l9-00; Wed, 18 Sep 2002 18:26:16 -0400 Original-Path: shelby.stanford.edu!nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!news-feed1.de1.concert.net!fu-berlin.de!uni-berlin.de!81.84.20.179!not-for-mail Original-Newsgroups: comp.emacs,gnu.emacs.help Original-Lines: 49 Original-NNTP-Posting-Host: 81.84.20.179 Original-X-Trace: fu-berlin.de 1032387472 4550808 81.84.20.179 (16 [79624]) User-Agent: Xnews/5.04.25 Original-Xref: nntp.stanford.edu comp.emacs:74599 gnu.emacs.help:105050 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:1604 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1604 Thank you gentlemen for the helpful replies! Ryan Yeske wrote in news:87fzw9ceye.fsf@cut.hotdog.tmp: > David Kastrup writes: > >> Ryan Yeske writes: >> >> > 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? > > Try it :) > > It helps me to think about it like this: > > 1) save the point > 2) save the restriction > 3) frob the restriction (narrow *or* widen) > 4) frob the point > 5) restore the old restriction > 6) restore the old point > > It doesn't matter whether you are widening or narrowing. When the > restriction is restored (step 5), the point is adjusted to be within > the restriction (the point can never be outside the current > restriction). It doesn't really matter though, since the point is > then immediatly restored to the initial value within the initial > restriction at step 6. > > Ryan >