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: Fri, 01 Apr 2011 13:39:08 +0100 Organization: SunSITE.dk - Supporting Open source Message-ID: <4d95c77a$0$23765$14726298@news.sunsite.dk> References: <3507e70b-e6a7-4d22-adbd-cc71c9181986@x8g2000prh.googlegroups.com> 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 1301661658 8181 80.91.229.12 (1 Apr 2011 12:40:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 1 Apr 2011 12:40:58 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 01 14:40:52 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 1Q5del-0007qk-H5 for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Apr 2011 14:40:51 +0200 Original-Received: from localhost ([127.0.0.1]:52992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5del-0006Mi-2N for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Apr 2011 08:40:51 -0400 Original-Path: usenet.stanford.edu!news.glorb.com!news2.glorb.com!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: <3507e70b-e6a7-4d22-adbd-cc71c9181986@x8g2000prh.googlegroups.com> Original-Lines: 29 Original-NNTP-Posting-Host: 92.232.137.113 Original-X-Trace: news.sunsite.dk DXC=H0MN:b_MPBXU2[:W; BVUdS?DZIH?UQ6E]45i7E1PQiLQiXd?DWbWG[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:80569 Archived-At: On 4/1/2011 4:20 AM, rusi wrote: > There is this 'new' save-excursion issue/discussion/bug here: > http://thread.gmane.org/gmane.emacs.orgmode/40417 > > I wonder how much it is related to this discussion? It is not exactly related. It is a probably something similar to this: (save-excursion (let ((x (buffer-substring (point-min) (point-max)))) (erase-buffer) (insert x))) What does it do? Well, save-excursion saves the point, but then erase-buffer destroys the point. So, the "point" moves to the beginning of buffer. And, save-excursion makes sure it stays there. Without save-excursion, the point would move to the end of the buffer because of (insert x). In the org-mode example in the thread, org-agenda-redo is probably doing a good job of putting the point at a good place. But the save-excursion at the top-level is negating all its good work. It just goes to show the fallacy of thinking that save-excursion doesn't hurt. Cheers, Uday