emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problems with org-mode-hook when files are opened by org-agenda-list
@ 2009-03-12  7:42 Tassilo Horn
  2009-03-12  8:31 ` Carsten Dominik
  0 siblings, 1 reply; 3+ messages in thread
From: Tassilo Horn @ 2009-03-12  7:42 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I want that each time I startup emacs and each time I change a org file,
the agenda for this week should be exported to /tmp/org-agenda.txt.  I
use this file for creating an agenda popup in my window manager [1]

To achive that, I use the following code:

--8<---------------cut here---------------start------------->8---
(require 'org-install)
(eval-after-load 'org
  '(require 'org-id))

[...]

(defun th-org-mode-init ()
  [...]
  (add-hook 'after-save-hook 'th-org-update-agenda-file t t))

[...]

(defun th-org-update-agenda-file (&optional force)
  (interactive)
  (save-excursion
    (save-window-excursion
      (let ((file "/tmp/org-agenda.txt"))
        (org-agenda-list)
        (org-write-agenda file)))))

(th-org-update-agenda-file t)

(add-hook 'org-mode-hook 'th-org-mode-init)
--8<---------------cut here---------------end--------------->8---

When I start emacs now the file /tmp/org-agenda.txt is created by the
call to `th-org-update-agenda-file'.  But in all org buffers the value
of `after-save-hook' is nil, although it should contain
`th-org-update-agenda-file'.

When I revert the org buffers, the function is correctly added.

So it seems to me that when org files are opened by `org-agenda-list'
the `org-mode-hook' is skipped somehow.  Am I right and is this
intended?

Bye,
Tassilo
__________
[1] http://tsdh.wordpress.com/2009/03/04/integrating-emacs-org-mode-with-the-awesome-window-manager/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems with org-mode-hook when files are opened by org-agenda-list
  2009-03-12  7:42 Problems with org-mode-hook when files are opened by org-agenda-list Tassilo Horn
@ 2009-03-12  8:31 ` Carsten Dominik
  2009-03-12 16:02   ` Tassilo Horn
  0 siblings, 1 reply; 3+ messages in thread
From: Carsten Dominik @ 2009-03-12  8:31 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode


On Mar 12, 2009, at 8:42 AM, Tassilo Horn wrote:

> Hi all,
>
> I want that each time I startup emacs and each time I change a org  
> file,
> the agenda for this week should be exported to /tmp/org-agenda.txt.  I
> use this file for creating an agenda popup in my window manager [1]
>
> To achive that, I use the following code:
>
> --8<---------------cut here---------------start------------->8---
> (require 'org-install)
> (eval-after-load 'org
>  '(require 'org-id))
>
> [...]
>
> (defun th-org-mode-init ()
>  [...]
>  (add-hook 'after-save-hook 'th-org-update-agenda-file t t))
>
> [...]
>
> (defun th-org-update-agenda-file (&optional force)
>  (interactive)
>  (save-excursion
>    (save-window-excursion
>      (let ((file "/tmp/org-agenda.txt"))
>        (org-agenda-list)
>        (org-write-agenda file)))))
>
> (th-org-update-agenda-file t)
>
> (add-hook 'org-mode-hook 'th-org-mode-init)
> --8<---------------cut here---------------end--------------->8---

I think you need to swap the last two lines.  During the first
call to your update function (and therefore during
the first creation of an agenda which will find all the agenda
files), the org-mode-hook has not yet been modified.

- Carsten

>
> When I start emacs now the file /tmp/org-agenda.txt is created by the
> call to `th-org-update-agenda-file'.  But in all org buffers the value
> of `after-save-hook' is nil, although it should contain
> `th-org-update-agenda-file'.
>
> When I revert the org buffers, the function is correctly added.
>
> So it seems to me that when org files are opened by `org-agenda-list'
> the `org-mode-hook' is skipped somehow.  Am I right and is this
> intended?
>
> Bye,
> Tassilo
> __________
> [1] http://tsdh.wordpress.com/2009/03/04/integrating-emacs-org-mode-with-the-awesome-window-manager/
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems with org-mode-hook when files are opened by org-agenda-list
  2009-03-12  8:31 ` Carsten Dominik
@ 2009-03-12 16:02   ` Tassilo Horn
  0 siblings, 0 replies; 3+ messages in thread
From: Tassilo Horn @ 2009-03-12 16:02 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <dominik@science.uva.nl> writes:

>> --8<---------------cut here---------------start------------->8---
>> (defun th-org-update-agenda-file (&optional force)
>>  (interactive)
>>  (save-excursion
>>    (save-window-excursion
>>      (let ((file "/tmp/org-agenda.txt"))
>>        (org-agenda-list)
>>        (org-write-agenda file)))))
>>
>> (th-org-update-agenda-file t)
>>
>> (add-hook 'org-mode-hook 'th-org-mode-init)
>> --8<---------------cut here---------------end--------------->8---
>
> I think you need to swap the last two lines.

Gosh!  That's really too stupit.  Sometimes I'm really more than
routine-blinded...

Thanks a lot Carsten!
Tassilo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-12 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-12  7:42 Problems with org-mode-hook when files are opened by org-agenda-list Tassilo Horn
2009-03-12  8:31 ` Carsten Dominik
2009-03-12 16:02   ` Tassilo Horn

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).