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: Thu, 14 May 2009 19:28:53 +0200 Message-ID: References: <87d4ad8rb7.fsf@thinkpad.tsdh.de> <87skj7prdo.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 1M4ejx-0004ug-EL for emacs-orgmode@gnu.org; Thu, 14 May 2009 13:29:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M4ejt-0004uM-49 for emacs-orgmode@gnu.org; Thu, 14 May 2009 13:29:05 -0400 Received: from [199.232.76.173] (port=37084 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M4ejs-0004uJ-WA for emacs-orgmode@gnu.org; Thu, 14 May 2009 13:29:01 -0400 Received: from mail-ew0-f210.google.com ([209.85.219.210]:46463) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M4ejs-0004Kd-FT for emacs-orgmode@gnu.org; Thu, 14 May 2009 13:29:00 -0400 Received: by ewy6 with SMTP id 6so1876379ewy.42 for ; Thu, 14 May 2009 10:28:59 -0700 (PDT) In-Reply-To: <87skj7prdo.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 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. - Carsten On May 14, 2009, at 6:43 PM, Tassilo Horn wrote: > Carsten Dominik writes: > > Hi Carsten, > >>> --8<---------------cut here---------------start------------->8--- >>> (defun th-org-mode-init () >>> (add-hook 'after-save-hook 'th-org-update-agenda-file t t)) >>> >>> (add-hook 'org-mode-hook 'th-org-mode-init) >>> >>> ;; TODO: This errors when calling C-x s after modifying things in >>> the agenda. >>> (defun th-org-update-agenda-file (&optional force) >>> (interactive) >>> (when (and (eq major-mode 'org-mode) >>> (member buffer-file-name org-agenda-files)) >>> (save-excursion >>> (save-window-excursion >>> (let ((file "/tmp/org-agenda.txt")) >>> (org-agenda-list) >>> (org-write-agenda file)))))) >>> --8<---------------cut here---------------end--------------->8--- >>> >>> This works fine when I save an agenda file while in its buffer, but >>> when I edit the file via agenda commands and hit `C-x s', I'm asked >>> if I want to save "/home/horn/repos/org/uni.org" and say yes, I get >>> this error: >> >> This probably happens because you are relying on org-agenda-list >> which >> is supposed to display the agenda window and in this way set the >> selected window and buffer. In non-interactive use, the buffer is >> created, but display is delayed until after the next idle moment. >> >> Not tested, but this may help: >> >> Replace (org-agenda-write) with this: >> >> (with-current-buffer org-agenda-buffer-name (org-write-agenda file)) > > No, I'm sorry. I still get the error, and it's already triggered in > the > call to `org-agenda-list' before `org-write-agenda' is called. The > error is thrown in `org-agenda-get-day-entries'. > > Bye, > Tassilo