From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-15?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: `save-excursion' defeated by `set-buffer' Date: Fri, 11 Mar 2011 09:52:26 +0100 Message-ID: <4D79E2CA.9090600@easy-emacs.de> References: <4D792D16.1080900@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1299833307 11655 80.91.229.12 (11 Mar 2011 08:48:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 11 Mar 2011 08:48:27 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 11 09:48:22 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pxy1G-0001hO-76 for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Mar 2011 09:48:22 +0100 Original-Received: from localhost ([127.0.0.1]:41131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxy1E-0000ff-MT for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Mar 2011 03:48:20 -0500 Original-Received: from [140.186.70.92] (port=45310 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxy0T-0000bK-6P for help-gnu-emacs@gnu.org; Fri, 11 Mar 2011 03:47:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pxy0S-0002Pd-2u for help-gnu-emacs@gnu.org; Fri, 11 Mar 2011 03:47:33 -0500 Original-Received: from moutng.kundenserver.de ([212.227.17.8]:50116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pxy0R-0002PU-MK for help-gnu-emacs@gnu.org; Fri, 11 Mar 2011 03:47:32 -0500 Original-Received: from [192.168.178.29] (brln-4dbc7b97.pool.mediaWays.net [77.188.123.151]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MSFW3-1PVYBW3Tnn-00THxB; Fri, 11 Mar 2011 09:47:30 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6 In-Reply-To: X-Provags-ID: V02:K0:XI4P6+iF/XYCpDRYEnApPys/mOdvLbdydPT20qq3rsM lYTxcPu6BTqgTcQtkQjqIYI1lQ4pUn+u4nsiMGkAw3+l/kLWNF 05G8SRXIQ8UThaL4sh/cRb2jjy+j2HZRDBkGnon4d9wuFQwCzi kyt0J9/nxGCOzgxoI52d+eywsrO4BbPIXUpBUK3P4G0tltX5uZ pZNrFpj4irMYxzTKz9fS7Ua3wCEmhXhSnYiyxBn3tc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:79958 Archived-At: Am 11.03.2011 02:28, schrieb Stefan Monnier: >>> The difference between save-excursion and save-current-buffer is that >>> the first doesn't just save&restore the current buffer but also "point& >>> mark". But if you do `set-buffer' right after save-excursion then most >>> likely you will change neither point nor mark in the original buffer, so >>> the extra work performed by save-excursion compared to >>> save-current-buffer will be useless. >>> Now that's just a waste of resources but is otherwise harmless. >>> >>> Unless of course `blub' is already the current buffer to start with. >>> >>> I.e. whether point movement in "..." is undone by save-excursion will >>> depend dynamically upon whether the current buffer happens to be `blub', >>> which leads to subtle bugs. Hence the warning. > >> Thanks, this warning goes away if body is wrapped with a let: > >> (save-excursion >> (let () >> (set-buffer blub) >> ... >> )) > > I see you apparently didn't understand much of what I wrote :-( > > > Stefan > Maybe let's put the question another way: is there an example, where save-excursion will fail, ie not restore the buffer due to a set-buffer afterwards? Thanks Andreas