From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: missing appointments Date: Thu, 23 Feb 2012 04:02:14 -0500 Message-ID: <7071.1329987734@alphaville> References: Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:56366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0UZH-00009e-1d for emacs-orgmode@gnu.org; Thu, 23 Feb 2012 04:02:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0UZ7-0005pA-4Z for emacs-orgmode@gnu.org; Thu, 23 Feb 2012 04:02:26 -0500 Received: from g1t0027.austin.hp.com ([15.216.28.34]:21651) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0UZ6-0005oy-VN for emacs-orgmode@gnu.org; Thu, 23 Feb 2012 04:02:17 -0500 In-Reply-To: Message from Rodrigo Amestica of "Thu, 23 Feb 2012 00:32:00 EST." List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rodrigo Amestica Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Rodrigo Amestica wrote: > Hi, > > I use appt to connect desktop notifications to appointments in my > agenda. However, the connection between the appointments and the > notification system does not happen until I visit the agenda with, for > example, "C-c a a", which I sometimes forget to invoke and I end up > missing appointments. > > Trying to automate I created a short cut like this: > > emacs -f org-agenda-list my-main-org-file > > However, this seems to execute org-agenda-list before my-main-org-file > has fully opened in its own buffer and I end up with the window split into > two buffers: top one scratch and bottom one my-main-org-file, which is > visually very annoying. It is completely mysterious to me the timing > at which different actions take place within emacs and how to control > and sequence them, like a 'wait' call. > > Is there a way to automatically execute org-agenda-list after > my-main-org-file has fully finished opening in its buffer? > I think this is the wrong way to go about it. > Is it there some more streamlined way to connect agenda to > notifications such that I would not need to explicitly enable them > every time I open the file? > The way to do it is to call org-agenda-to-appt. The trick is to call this function at all the necessary places/times. I have the following code in my initialization file, after the rest of org initialization: --8<---------------cut here---------------start------------->8--- ... (org-agenda-to-appt) (defadvice org-agenda-redo (after org-agenda-redo-add-appts) "Pressing `r' on the agenda will also add appointments." (progn (setq appt-time-msg-list nil) (org-agenda-to-appt))) (ad-activate 'org-agenda-redo) (add-hook 'org-capture-after-finalize-hook (function org-agenda-to-appt) ) ;; wrong (setq org-appt-timer (run-at-time "00:01" nil (function org-agenda-to-appt))) ... --8<---------------cut here---------------end--------------->8--- There are four pieces here: o an explicit call - this gets executed at initialization and loads up the appt-time-msg-list from the agenda. o advising org-agenda-redo so that after it's done, it resets appt-time-msg-list and calls org-agenda-to-appt again. That way, if something goes wrong, I can pop up the agenda, press "r" and start afresh. o add a call to org-capture-after-finalize-hook - that way when I capture an appointment for today, it will be added automatically. o finally, I would like to add a call at midnight every day to recalculate appointments for the next day - unfortunately, the call above is not correct, so for now I do it manually with an org-agenda-redo as above. One of these days I'll get that fixed. If anybody has done that already, I'll gladly steal your code :-) I *think* that should catch everything. BTW, there is an org-hacks entry by Russell Adams: http://orgmode.org/worg/org-hacks.html#org-agenda-appt-zenity where he suggests also adding it to org-agenda-finalize-hook: that way it gets done every time you display the agenda as well. Not sure whether it's necessary or overkill for me, but it certainly wouldn't hurt. Nick