From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Problems with org-mode-hook when files are opened by org-agenda-list Date: Thu, 12 Mar 2009 09:31:53 +0100 Message-ID: References: <87ocw7p4pq.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 1LhgKe-0004Qg-0u for emacs-orgmode@gnu.org; Thu, 12 Mar 2009 04:32:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LhgKc-0004QU-LP for emacs-orgmode@gnu.org; Thu, 12 Mar 2009 04:31:59 -0400 Received: from [199.232.76.173] (port=56306 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LhgKc-0004QN-GF for emacs-orgmode@gnu.org; Thu, 12 Mar 2009 04:31:58 -0400 Received: from mail-ew0-f179.google.com ([209.85.219.179]:44189) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LhgKc-00063O-3K for emacs-orgmode@gnu.org; Thu, 12 Mar 2009 04:31:58 -0400 Received: by ewy27 with SMTP id 27so442687ewy.42 for ; Thu, 12 Mar 2009 01:31:57 -0700 (PDT) In-Reply-To: <87ocw7p4pq.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 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