From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Help debugging a problem when saving org-agenda files with C-x s Date: Sat, 16 May 2009 17:14:18 +0200 Message-ID: <515DB452-F8AD-4DD3-AD35-018F29398093@gmail.com> References: <87d4ad8rb7.fsf@thinkpad.tsdh.de> <87skj7prdo.fsf@thinkpad.tsdh.de> <87hbznh6ip.fsf@thinkpad.tsdh.de> Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M5NsD-0007ev-FL for emacs-orgmode@gnu.org; Sat, 16 May 2009 13:40:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M5Ns9-0007cl-UF for emacs-orgmode@gnu.org; Sat, 16 May 2009 13:40:37 -0400 Received: from [199.232.76.173] (port=48361 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M5Ns9-0007ce-R8 for emacs-orgmode@gnu.org; Sat, 16 May 2009 13:40:33 -0400 Received: from mail-ew0-f162.google.com ([209.85.219.162]:37729) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M5Ns7-0007H8-9g for emacs-orgmode@gnu.org; Sat, 16 May 2009 13:40:32 -0400 Received: by mail-ew0-f162.google.com with SMTP id 6so3266024ewy.42 for ; Sat, 16 May 2009 10:40:30 -0700 (PDT) In-Reply-To: <87hbznh6ip.fsf@thinkpad.tsdh.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Tassilo Horn Cc: emacs-orgmode@gnu.org On May 14, 2009, at 8:41 PM, Tassilo Horn wrote: > Carsten Dominik writes: > >> Did you restart Emacs? My idea was that the first time you call >> this, >> you change the file name of a buffer, and the second time the problem >> happens. > > First, I only evaled my function anew, but now I tried with a new > emacs > instance and the error is still the same. > > But now I can see what happens (but I don't have a solution right > now): > > - `C-x s' saves the modified org buffer (I checked that the changes > are saved to disk) > > - my function is triggered cause it's in `after-save-hook' buffer > locally Calling such functions recursively is never a good idea, even if it is accidental recursion in this case. You could and should turn off your hook function in after-safe-hook for the duration of your command. On common way to do this is to make it dependent on a variable and bind this variable dynamically while you run the hook function Like (defvar do-my-hook t) ... (defun th-org-update-agenda-file (&optional force) (interactive) (when (and do-my-hook (eq major-mode 'org-mode) (member buffer-file-name org-agenda-files)) (save-excursion (save-window-excursion (let ((do-my-hook nil) (file "/tmp/org-agenda.txt")) (org-agenda-list) (org-write-agenda file)))))) HTH - Carsten > > - somehow the buffer associated with the saved org file uni.org is > erased and org tries to insert an agendo into this buffer (only one > propertized line) > > Week-agenda (W20): > > and the major mode is now `org-agenda-mode', which results in the > error I posted when org tries to create the agenda page. > > Bye, > Tassilo > -- > [Emacs] is written in Lisp, which is the only computer language that > is > beautiful. -- Neal Stephenson, _In the Beginning was the Command > Line_