From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ryan Yeske Newsgroups: gmane.emacs.help Subject: Re: save-restriction, save-excursion Date: Tue, 17 Sep 2002 06:24:18 GMT Sender: help-gnu-emacs-admin@gnu.org Message-ID: <87fzw9ceye.fsf@cut.hotdog.tmp> References: <87ofaxcr3e.fsf@cut.hotdog.tmp> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1032244566 23535 127.0.0.1 (17 Sep 2002 06:36:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 17 Sep 2002 06:36:06 +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 17rBxs-00067R-00 for ; Tue, 17 Sep 2002 08:36:04 +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 17rBy2-00038a-00; Tue, 17 Sep 2002 02:36:14 -0400 Original-Path: shelby.stanford.edu!nntp.stanford.edu!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp.itservices.ubc.ca!cyclone.bc.net!newsfeed.telusplanet.net!news2.telusplanet.net.POSTED!53ab2750!not-for-mail Original-Newsgroups: comp.emacs,gnu.emacs.help Original-Lines: 42 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-NNTP-Posting-Host: 66.183.164.95 Original-X-Trace: news2.telusplanet.net 1032243858 66.183.164.95 (Tue, 17 Sep 2002 00:24:18 MDT) Original-NNTP-Posting-Date: Tue, 17 Sep 2002 00:24:18 MDT Original-Xref: nntp.stanford.edu comp.emacs:74550 gnu.emacs.help:104968 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:1523 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1523 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