From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Uday Reddy Newsgroups: gmane.emacs.help Subject: Re: `save-excursion' defeated by `set-buffer' Date: Sun, 13 Mar 2011 02:40:34 +0000 Organization: SunSITE.dk - Supporting Open source Message-ID: <4d7c2ea3$0$23757$14726298@news.sunsite.dk> References: <4D792D16.1080900@easy-emacs.de> <87pqpwr8ay.fsf@fencepost.gnu.org> <87d3lwr56j.fsf@fencepost.gnu.org> <4d7b8ea3$0$23760$14726298@news.sunsite.dk> <87k4g4pdi3.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1299987639 16655 80.91.229.12 (13 Mar 2011 03:40:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 13 Mar 2011 03:40:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 13 04:40:35 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 1PycAU-0004TF-7D for geh-help-gnu-emacs@m.gmane.org; Sun, 13 Mar 2011 04:40:34 +0100 Original-Received: from localhost ([127.0.0.1]:60064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PycAT-0005RI-OW for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Mar 2011 22:40:33 -0500 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!feed118.news.tele.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 Original-Newsgroups: gnu.emacs.help In-Reply-To: <87k4g4pdi3.fsf@fencepost.gnu.org> Original-Lines: 45 Original-NNTP-Posting-Host: 92.232.137.113 Original-X-Trace: news.sunsite.dk DXC=hN^C\aOHCDoPEW:6ooR3ldYSB=nbEKnkknM\f75cN1; d^H_C>[:W; BfUdS?DZIH?Ua6E]45i7E1PaiLQiXd?DWbgG[N=S 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:80048 Archived-At: On 3/12/2011 3:25 PM, David Kastrup wrote: >> Frankly, I think the warning message is quite fine. save-excursion is >> trying to preserve the point (and mark), but only for the >> current-buffer. set-buffer is changing the current-buffer and, so, >> the preservation of the point in the current-buffer is useless. > > There is little reason to warn about "useless" code. Why is that? I am quite happy to receive warnings about bad code. >> If one wants a completely plain warning message, it could be: >> >> "save-excursion has the effect of save-current-buffer" >> >> It doesn't say very much, but nobody will presumably argue about it. > > The most plausible theory I have for this thread is that you are > collectively trying to pull my leg. > > If you give the user that warning, he'll say "great, just like I wanted > it to do". Ok, how about "save-current-buffer is a better choice than save-excursion" > Why warn the user that "save-excursion" is doing what he wants it to do, > when the actual problem is that it may do more, namely reverting an > excursion happening unintendedly in the original buffer? If an excursion is happening unintentionally that is definitely a bug! You probably mean that reverting it unintentionally is not so bad. But I happen to think that it is. save-excursion's should be as close as possible to the point movements they are protecting. One shouldn't randomly wrap large pieces of bad code in save-excursion and hope that nobody will notice. It is really hard to maintain such code. The compiler warning is really welcome from my point of view. I only wish that the compiler warning was there 20 years ago so that I wouldn't have to deal with that mess now. But better late than never! Cheers, Uday