Re: [O] notify, when something to do

2011-11-01 Thread Peter Münster
On Sun, Oct 23 2011, Bastien wrote:

>> - Perhaps the main problem: appt does not know about warning periods.
>>   There are items with "-3d", other with "-5M"[1]. There is only one
>>   universal appt-message-warning-time. Would it be possible, to have a
>>   individual warning-time for each todo-item, directly computed from the
>>   warning time in the org-timestamp?
>
> Check what info is available as text properties in the agenda 
> (with `C-u C-x =') and see if you can use this information in 
> a filter function.

There is `type = "upcoming-deadline"', so it should be doable.

Thanks for the filter-function and the scope-keywords!

-- 
   Peter




Re: [O] notify, when something to do

2011-10-25 Thread Marcelo de Moraes Serpa
Ha, the XMPP idea really appeals to me, endless possibilities :D

Thanks for sharing.


On Mon, Oct 24, 2011 at 10:01 AM, Christopher Allan Webber <
cweb...@dustycloud.org> wrote:

> Hey Peter,
>
> I also do appointments with orgmode.. I have it hooked up so that it
> sends me messages via XMPP/Jabber.  Possibly useful to you:
>
>
> http://dustycloud.org/blog/2010/11/21/emacs-appointment-notifications-via-xmpp
>
> pmli...@free.fr (Peter Münster) writes:
>
> > Hello,
> >
> > I would like to be notified[1], when a todo item enters the warning
> > period, scheduled time, or deadline.
> >
> > I can imagine writing a function, that executes every 5 minutes, that
> > scans all agenda files calling `org-get-[scheduled,deadline]-time', but
> > I hope, that there is already something, that I can use more easily.
> >
> > TIA for any help,
> > Peter
> >
> >
> > Footnotes:
> > [1]  For notifying, I'll use an external program, for example
> > "notify-send", because the emacs window is not always visible.
>
>


Re: [O] notify, when something to do

2011-10-24 Thread Christopher Allan Webber
Hey Peter,

I also do appointments with orgmode.. I have it hooked up so that it
sends me messages via XMPP/Jabber.  Possibly useful to you:

http://dustycloud.org/blog/2010/11/21/emacs-appointment-notifications-via-xmpp

pmli...@free.fr (Peter Münster) writes:

> Hello,
>
> I would like to be notified[1], when a todo item enters the warning
> period, scheduled time, or deadline.
>
> I can imagine writing a function, that executes every 5 minutes, that
> scans all agenda files calling `org-get-[scheduled,deadline]-time', but
> I hope, that there is already something, that I can use more easily.
>
> TIA for any help,
> Peter
>
>
> Footnotes: 
> [1]  For notifying, I'll use an external program, for example
> "notify-send", because the emacs window is not always visible.



Re: [O] notify, when something to do

2011-10-24 Thread Sebastien Vauban
Bastien,

Bastien wrote:
>> - How to distinguish between SCHEDULED and DEADLINE?  I'll
>>   investigate...
>
> I introduced the ability to use
>
> (org-agenda-to-appt nil t :scheduled)
>
> if you just want to get scheduled appointments.  This might
> speeds things and make them more flexible.

I have the impression we use SCHEDULED here with a wrong semantics.

What about the idea (launched by Carsten) of introducing another keyword like
APPT or EVENT [1] for such events to be warned of?

Best regards,
  Seb

Footnotes:

[1] http://www.mail-archive.com/emacs-orgmode@gnu.org/msg45063.html

-- 
Sebastien Vauban




Re: [O] notify, when something to do

2011-10-23 Thread Tassilo Horn
Bastien  wrote:

> Hi Tassilo,
> 
> Tassilo Horn  writes:
> 
> > But maybe one could change
> > `org-agenda-to-appt' to accept also a function as filter.
> 
> Done.  You can now use a fonction as a filter.  It will 
> filter through entries.  the only mandatory argument for
> this function will be an entry, i.e. something similar
> to what `org-agenda-get-day-entries' outputs.
> 
> Thanks for this idea!
> 
> -- 
>  Bastien

Hey Bastien,

This is awesome. Thanks a lot.

Tassilo



Re: [O] notify, when something to do

2011-10-23 Thread Bastien
Hi Peter,

pmli...@free.fr (Peter Münster) writes:

> - I think, I'll need a filter for org-agenda-to-appt, because I only
>   want TODO items. Should be no problem.

Yes -- just use a function who tries to match the TODO keyword 
against the entry.

> - How to distinguish between SCHEDULED and DEADLINE?  I'll
>   investigate...

I introduced the ability to use

(org-agenda-to-appt nil t :scheduled)

if you just want to get scheduled appointments.  This might
speeds things and make them more flexible.

> - Perhaps the main problem: appt does not know about warning periods.
>   There are items with "-3d", other with "-5M"[1]. There is only one
>   universal appt-message-warning-time. Would it be possible, to have a
>   individual warning-time for each todo-item, directly computed from the
>   warning time in the org-timestamp?

Check what info is available as text properties in the agenda 
(with `C-u C-x =') and see if you can use this information in 
a filter function.

HTH,

-- 
 Bastien



Re: [O] notify, when something to do

2011-10-23 Thread Bastien
Hi Tassilo,

Tassilo Horn  writes:

> But maybe one could change
> `org-agenda-to-appt' to accept also a function as filter.

Done.  You can now use a fonction as a filter.  It will 
filter through entries.  the only mandatory argument for
this function will be an entry, i.e. something similar
to what `org-agenda-get-day-entries' outputs.

Thanks for this idea!

-- 
 Bastien



Re: [O] notify, when something to do

2011-10-23 Thread Tassilo Horn
pmli...@free.fr (Peter Münster) writes:

Hi Peter,

> First, I took a look at the lines
>
> (org-agenda-to-appt t)
> (appt-activate 1)
>
> This is already a good starting point, just 3 remarks:
> - I think, I'll need a filter for org-agenda-to-appt, because I only
>   want TODO items. Should be no problem.

Yep.

> - How to distinguish between SCHEDULED and DEADLINE?  I'll
>   investigate...
> - Perhaps the main problem: appt does not know about warning periods.
>   There are items with "-3d", other with "-5M"[1]. There is only one
>   universal appt-message-warning-time. Would it be possible, to have a
>   individual warning-time for each todo-item, directly computed from the
>   warning time in the org-timestamp?

Not sure about the last two.  But maybe one could change
`org-agenda-to-appt' to accept also a function as filter.

Bye,
Tassilo




Re: [O] notify, when something to do

2011-10-23 Thread Peter Münster
On Sun, Oct 23 2011, Tassilo Horn wrote:

> pmli...@free.fr (Peter Münster) writes:
>
>> I would like to be notified[1], when a todo item enters the warning
>> period, scheduled time, or deadline.
>
> I export my org entries as appt alarms, so that I get system
> notifications 15 minutes before meetings (every 1 minute until I
> discard them).  Here's the code:

Hello Tassilo,

First, I took a look at the lines

--8<---cut here---start->8---
(org-agenda-to-appt t)
(appt-activate 1)
--8<---cut here---end--->8---

This is already a good starting point, just 3 remarks:
- I think, I'll need a filter for org-agenda-to-appt, because I only
  want TODO items. Should be no problem.
- How to distinguish between SCHEDULED and DEADLINE?  I'll
  investigate...
- Perhaps the main problem: appt does not know about warning periods.
  There are items with "-3d", other with "-5M"[1]. There is only one
  universal appt-message-warning-time. Would it be possible, to have a
  individual warning-time for each todo-item, directly computed from the
  warning time in the org-timestamp?

In the meantime, I'll take a look at your th-appt-alarm.
Thanks for your code!

   Peter

Footnotes: 
[1]  That means "warn 5 minutes before". I don't know, if org-mode
supports this. "-2H" for hours would be useful too.




Re: [O] notify, when something to do

2011-10-23 Thread Tassilo Horn
Tassilo Horn  writes:

> (defvar th-notify-title-to-id-map (make-hash-table :test 'string=)
>   "Maps TITLE values of notifications to the last notification ID.
> If ID is -1, then any further notifications with that body will
> be skipped.")
>
> (defun th-notify (&rest args)
>   "Create a notification popup.
> For ARGS, see `notifications-notify'.
> There's some new default behavior over the function above:
>
>   - Notifications with same :body replace each other.  :body,
> because my notifications are usually something like
>
>   :title \"Meeting with Hugo\"
>   :body \"In 15 Minutes\"
>
> where each minute a similar notification with decreasing
> minutes in the :body is triggered.

This comment is obviously outdated.  The notifications with equal :title
now replace each other.

Bye,
Tassilo




Re: [O] notify, when something to do

2011-10-23 Thread Tassilo Horn
pmli...@free.fr (Peter Münster) writes:

Hi Peter,

> I would like to be notified[1], when a todo item enters the warning
> period, scheduled time, or deadline.

I export my org entries as appt alarms, so that I get system
notifications 15 minutes before meetings (every 1 minute until I
discard them).  Here's the code:

--8<---cut here---start->8---
(defvar th-notify-title-to-id-map (make-hash-table :test 'string=)
  "Maps TITLE values of notifications to the last notification ID.
If ID is -1, then any further notifications with that body will
be skipped.")

(defun th-notify (&rest args)
  "Create a notification popup.
For ARGS, see `notifications-notify'.
There's some new default behavior over the function above:

  - Notifications with same :body replace each other.  :body,
because my notifications are usually something like

  :title \"Meeting with Hugo\"
  :body \"In 15 Minutes\"

where each minute a similar notification with decreasing
minutes in the :body is triggered.

  - If a notification was dismissed, then don't show any
notifications with that :title anymore (the next 15 minutes).

  - Use unlimited timeout."
  (require 'notifications)
  (let* ((title (plist-get args :body))
 (body (plist-get args :body))
 (replaces-id (or (plist-get args :replaces-id)
  (gethash title th-notify-title-to-id-map)))
 (on-close (or (plist-get args :on-close)
   `(lambda (id reason)
  (when (eq reason 'dismissed)
;; Mark as "don't show again!"
(puthash ,title -1 th-notify-title-to-id-map)
;; But clear that "dont-show-mark" after 15 minutes
(run-with-timer (* 15 60) nil
(lambda ()
  (remhash ,title 
th-notify-title-to-id-map)))
 ;; 0 means, it should not expire at all
 (timeout (or (plist-get args :timeout) 0)))
(unless (eql replaces-id -1)
  (puthash title (apply 'notifications-notify
(th-plist-put-many args
   :timeout timeout
   :replaces-id replaces-id
   :on-close on-close))
   th-notify-title-to-id-map

(defun th-appt-alarm (mins time text)
  "Show a notification popup (or update the current one) for the
appt with TEXT in MINS minutes (a string)."
  (let ((body (substring-no-properties text)))
(th-notify
 :title text
 :body (concat "Appointment "
   (if (string= mins "0")
   "NOW:"
 (concat "in " mins " minutes:"))

(setq appt-display-format 'window
  appt-disp-window-function 'th-appt-alarm
  appt-display-interval 1
  appt-display-duration 60)

(defun th-org-agenda-to-appt ()
  (require 'org-agenda)
  (org-agenda-to-appt t)
  (appt-activate 1))

(th-org-agenda-to-appt)
(add-hook 'org-finalize-agenda-hook 'th-org-agenda-to-appt)
--8<---cut here---end--->8---

Bye,
Tassilo