[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] Help debugging a problem when saving org-agenda files with
From: |
Tassilo Horn |
Subject: |
Re: [Orgmode] Help debugging a problem when saving org-agenda files with C-x s |
Date: |
Thu, 14 May 2009 18:43:15 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (gnu/linux) |
Carsten Dominik <address@hidden> 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