Re: [O] missing appointments

2012-02-23 Thread Nick Dokos
Rodrigo Amestica ramest...@lavabit.com 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








Re: [O] missing appointments

2012-02-23 Thread Memnon Anon
Nick Dokos nicholas.do...@hp.com writes:

 ;; wrong
 (setq org-appt-timer (run-at-time 00:01 nil (function org-agenda-to-appt)))
[...]
 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 :-)

http://doc.norang.ca/org-mode.html#sec-14-1

Memnon




Re: [O] missing appointments

2012-02-23 Thread Bernt Hansen
Memnon Anon gegendosenflei...@googlemail.com writes:

 Nick Dokos nicholas.do...@hp.com writes:

 ;; wrong
 (setq org-appt-timer (run-at-time 00:01 nil (function org-agenda-to-appt)))
 [...]
 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 :-)

 http://doc.norang.ca/org-mode.html#sec-14-1

 Memnon

Heh!  Even I had to look that up... and it's my document!

For the list archives I think this is the relevant part of the above
link (since the sec-14-1 is likely to change in the future)

--8---cut here---start-8---
; If we leave Emacs running overnight - reset the appointments one minute after 
midnight
(run-at-time 24:01 nil 'bh/org-agenda-to-appt)
--8---cut here---end---8---

This originally came from Carsten Dominik years ago ... when I was
setting up my appt for the first time.

Thanks Carsten!

Regards,
Bernt



Re: [O] missing appointments

2012-02-23 Thread Nick Dokos
Bernt Hansen be...@norang.ca wrote:

 Memnon Anon gegendosenflei...@googlemail.com writes:
 
  Nick Dokos nicholas.do...@hp.com writes:
 
  ;; wrong
  (setq org-appt-timer (run-at-time 00:01 nil (function 
  org-agenda-to-appt)))
  [...]
  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 :-)
 
  http://doc.norang.ca/org-mode.html#sec-14-1
 
  Memnon
 
 Heh!  Even I had to look that up... and it's my document!
 
 For the list archives I think this is the relevant part of the above
 link (since the sec-14-1 is likely to change in the future)
 
 ; If we leave Emacs running overnight - reset the appointments one minute 
 after midnight
 (run-at-time 24:01 nil 'bh/org-agenda-to-appt)
 
 This originally came from Carsten Dominik years ago ... when I was
 setting up my appt for the first time.
 
 Thanks Carsten!
 

Thanks, Memnon! And Bernt and Carsten (and also Russell Adams who had it in
the hack I mentioned yesterday)!

I'm not sure I understand how it works, but I've added it (plus some
debugging) and we'll see how it goes: is the 24:01 a relative time or
an absolute time? I can't make heads or tails of the run-at-time doc.
And what reschedules it for next time? Doesn't the timer fire once (if REPEAT
is nil) and then it's done? I remember I had some misconceptions
about run-at-time before and these are probably more misconceptions on
my part. One of these days, I'll dust the cobwebs out (but they keep
returning...)

Nick




Re: [O] missing appointments

2012-02-23 Thread Nick Dokos
Nick Dokos nicholas.do...@hp.com wrote:

 
 I'm not sure I understand how it works, but I've added it (plus some
 debugging) and we'll see how it goes: is the 24:01 a relative time or
 an absolute time? I can't make heads or tails of the run-at-time doc.

I went through the code: it's an absolute time and it represents one minute
past midnight of the next day (my original 00:01 was one minute past midnight
of the current day, i.e. some time in the past).

 And what reschedules it for next time? Doesn't the timer fire once (if REPEAT
 is nil) and then it's done?

Still not clear about this though. I'll see what happens at midnight tonight.

Nick

PS. BTW, I was just looking through Bernt's document and saw that in my earlier
mail, I missed the activation of appointments:

(appt-activate 1)

So that's one more thing for the OP to add to his .emacs.



[O] missing appointments

2012-02-22 Thread Rodrigo Amestica
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?

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?

thanks,
 Rodrigo