unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [appt] allow specifying warning time in diary
@ 2010-09-08  8:54 Leo
  2010-09-08  9:29 ` Andreas Schwab
  2010-09-08 14:34 ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: Leo @ 2010-09-08  8:54 UTC (permalink / raw)
  To: emacs-devel

Hello,

When I put an appointment in the diary, sometimes I also want to set an
alert time. For example, if I am meeting a friend in London, I need a
notice 3 hours before the appointment.

The attached patch allows inserting in the diary something like this:

Saturday
        13:00 #180 Lunch with Theresa.

Is this feature useful?

Leo

	Modified lisp/calendar/appt.el
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index 15a9d54..e70644c 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -273,6 +273,12 @@ for a warning to be issued.  The format of the time can be either
               Thursday
                 11:45am Lunch meeting.
 
+Optionally you can specify a warning time for an entry following
+the time. For example:
+
+              Thursday
+                11:45am #20 Lunch meeting.
+
 Appointments are checked every `appt-display-interval' minutes.
 The following variables control appointment notification:
 
@@ -579,7 +585,8 @@ appointment package (if it is not already active)."
                              (calendar-current-date) (caar entry-list)))
                   (setq time-string (cadr (car entry-list)))
                   (while (string-match appt-time-regexp time-string)
-                    (let* ((beg (match-beginning 0))
+                    (let* ((time-beg (match-beginning 0))
+                           (time-end (match-end 0))
                            ;; Get just the time for this appointment.
                            (only-time (match-string 0 time-string))
                            ;; Find the end of this appointment
@@ -590,9 +597,20 @@ appointment package (if it is not already active)."
                                  (match-end 0)))
                            ;; Get the whole string for this appointment.
                            (appt-time-string
-                            (substring time-string beg end))
+                            (substring time-string time-beg end))
+                           (warntime
+                            (when (and (string-match
+                                        "[ \t]*#\\([-+]?[0-9]+\\)[ \t]*"
+                                        appt-time-string time-end)
+                                       (= (match-beginning 0) time-end))
+                              (prog1 (string-to-number
+                                      (match-string 1 appt-time-string))
+                                (setq appt-time-string
+                                      (replace-match " " nil nil
+                                                     appt-time-string)))))
                            (appt-time (list (appt-convert-time only-time)))
-                           (time-msg (list appt-time appt-time-string)))
+                           (time-msg (list appt-time appt-time-string
+                                           nil warntime)))
                       ;; Add this appointment to appt-time-msg-list.
                       (setq appt-time-msg-list
                             (nconc appt-time-msg-list (list time-msg))





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

* Re: [appt] allow specifying warning time in diary
  2010-09-08  8:54 [appt] allow specifying warning time in diary Leo
@ 2010-09-08  9:29 ` Andreas Schwab
  2010-09-08  9:48   ` Leo
  2010-09-08 14:34 ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2010-09-08  9:29 UTC (permalink / raw)
  To: Leo; +Cc: emacs-devel

Leo <sdl.web@gmail.com> writes:

> +Optionally you can specify a warning time for an entry following
> +the time. For example:
> +
> +              Thursday
> +                11:45am #20 Lunch meeting.
> +

Please document the unit.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



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

* Re: [appt] allow specifying warning time in diary
  2010-09-08  9:29 ` Andreas Schwab
@ 2010-09-08  9:48   ` Leo
  0 siblings, 0 replies; 10+ messages in thread
From: Leo @ 2010-09-08  9:48 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel

On 2010-09-08 10:29 +0100, Andreas Schwab wrote:
> Leo <sdl.web@gmail.com> writes:
>
>> +Optionally you can specify a warning time for an entry following
>> +the time. For example:
>> +
>> +              Thursday
>> +                11:45am #20 Lunch meeting.
>> +
>
> Please document the unit.
>
> Andreas.

Thank you for the comment.

diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index e70644c..3573c95 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -273,8 +273,8 @@ for a warning to be issued.  The format of the time can be either
               Thursday
                 11:45am Lunch meeting.
 
-Optionally you can specify a warning time for an entry following
-the time. For example:
+Optionally you can specify a warning time (in minutes) for an
+entry following the time. For example:
 
               Thursday
                 11:45am #20 Lunch meeting.

Leo



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

* Re: [appt] allow specifying warning time in diary
  2010-09-08  8:54 [appt] allow specifying warning time in diary Leo
  2010-09-08  9:29 ` Andreas Schwab
@ 2010-09-08 14:34 ` Stefan Monnier
  2010-09-08 14:55   ` Leo
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2010-09-08 14:34 UTC (permalink / raw)
  To: Leo; +Cc: emacs-devel

> When I put an appointment in the diary, sometimes I also want to set an
> alert time. For example, if I am meeting a friend in London, I need a
> notice 3 hours before the appointment.

> The attached patch allows inserting in the diary something like this:

Looks good, thank you; can someone install it?


        Stefan


> Saturday
>         13:00 #180 Lunch with Theresa.

> Is this feature useful?

> Leo

> 	Modified lisp/calendar/appt.el
> diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
> index 15a9d54..e70644c 100644
> --- a/lisp/calendar/appt.el
> +++ b/lisp/calendar/appt.el
> @@ -273,6 +273,12 @@ for a warning to be issued.  The format of the time can be either
>                Thursday
>                  11:45am Lunch meeting.
 
> +Optionally you can specify a warning time for an entry following
> +the time. For example:
> +
> +              Thursday
> +                11:45am #20 Lunch meeting.
> +
>  Appointments are checked every `appt-display-interval' minutes.
>  The following variables control appointment notification:
 
> @@ -579,7 +585,8 @@ appointment package (if it is not already active)."
>                               (calendar-current-date) (caar entry-list)))
>                    (setq time-string (cadr (car entry-list)))
>                    (while (string-match appt-time-regexp time-string)
> -                    (let* ((beg (match-beginning 0))
> +                    (let* ((time-beg (match-beginning 0))
> +                           (time-end (match-end 0))
>                             ;; Get just the time for this appointment.
>                             (only-time (match-string 0 time-string))
>                             ;; Find the end of this appointment
> @@ -590,9 +597,20 @@ appointment package (if it is not already active)."
>                                   (match-end 0)))
>                             ;; Get the whole string for this appointment.
>                             (appt-time-string
> -                            (substring time-string beg end))
> +                            (substring time-string time-beg end))
> +                           (warntime
> +                            (when (and (string-match
> +                                        "[ \t]*#\\([-+]?[0-9]+\\)[ \t]*"
> +                                        appt-time-string time-end)
> +                                       (= (match-beginning 0) time-end))
> +                              (prog1 (string-to-number
> +                                      (match-string 1 appt-time-string))
> +                                (setq appt-time-string
> +                                      (replace-match " " nil nil
> +                                                     appt-time-string)))))
>                             (appt-time (list (appt-convert-time only-time)))
> -                           (time-msg (list appt-time appt-time-string)))
> +                           (time-msg (list appt-time appt-time-string
> +                                           nil warntime)))
>                        ;; Add this appointment to appt-time-msg-list.
>                        (setq appt-time-msg-list
>                              (nconc appt-time-msg-list (list time-msg))





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

* Re: [appt] allow specifying warning time in diary
  2010-09-08 14:34 ` Stefan Monnier
@ 2010-09-08 14:55   ` Leo
  2010-09-08 20:38     ` Leo
  0 siblings, 1 reply; 10+ messages in thread
From: Leo @ 2010-09-08 14:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On 2010-09-08 15:34 +0100, Stefan Monnier wrote:
> Looks good, thank you; can someone install it?
>
>
>         Stefan

Thanks for the interest. The previous patch doesn't take into account of
non-zero time-beg. This one fixes it and is simpler.

	Modified lisp/calendar/appt.el
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index fd15093..af60d78 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -273,6 +273,12 @@ for a warning to be issued.  The format of the time can be either
               Thursday
                 11:45am Lunch meeting.
 
+Optionally you can specify a warning time (in minutes) for an
+entry following the time, for example:
+
+              Thursday
+                11:45am #20 Lunch meeting.
+
 Appointments are checked every `appt-display-interval' minutes.
 The following variables control appointment notification:
 
@@ -579,9 +585,19 @@ appointment package (if it is not already active)."
                              (calendar-current-date) (caar entry-list)))
                   (setq time-string (cadr (car entry-list)))
                   (while (string-match appt-time-regexp time-string)
-                    (let* ((beg (match-beginning 0))
+                    (let* ((time-beg (match-beginning 0))
+                           (time-end (match-end 0))
                            ;; Get just the time for this appointment.
                            (only-time (match-string 0 time-string))
+                           (warntime
+                            (when (= time-end
+                                     (string-match
+                                      "[ \t]*#\\([-+]?[0-9]+\\)[ \t]*"
+                                      time-string time-end))
+                              (prog1 (string-to-number
+                                      (match-string 1 time-string))
+                                (setq time-string (replace-match
+                                                   " " nil nil time-string)))))
                            ;; Find the end of this appointment
                            ;; (the start of the next).
                            (end (string-match
@@ -590,9 +606,10 @@ appointment package (if it is not already active)."
                                  (match-end 0)))
                            ;; Get the whole string for this appointment.
                            (appt-time-string
-                            (substring time-string beg end))
+                            (substring time-string time-beg end))
                            (appt-time (list (appt-convert-time only-time)))
-                           (time-msg (list appt-time appt-time-string)))
+                           (time-msg (list appt-time appt-time-string
+                                           nil warntime)))
                       ;; Add this appointment to appt-time-msg-list.
                       (setq appt-time-msg-list
                             (nconc appt-time-msg-list (list time-msg))


Leo



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

* Re: [appt] allow specifying warning time in diary
  2010-09-08 14:55   ` Leo
@ 2010-09-08 20:38     ` Leo
  2010-09-09  8:54       ` Daniel Pittman
  0 siblings, 1 reply; 10+ messages in thread
From: Leo @ 2010-09-08 20:38 UTC (permalink / raw)
  To: emacs-devel

On 2010-09-08 15:55 +0100, Leo wrote:
> Thanks for the interest. The previous patch doesn't take into account of
> non-zero time-beg. This one fixes it and is simpler.

Sorry, found two bugs (one is typo).

So I made a test diary file as follows:

8 Sep 2010 23:00 test1 (no)
8 Sep 2010 23:00 #20 test2 (yes)
8 Sep 2010
  23:00 # xyz1 (no)
  23:00#20 xyz2 (yes)
  23:00 #1.2 xyz3 (no)
  23:59 #-1 xyz4 (yes)

no = warntime is not set
yes = warntime is set

The renewed patch works with the test file.

	Modified lisp/calendar/appt.el
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index fd15093..b590290 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -273,6 +273,12 @@ for a warning to be issued.  The format of the time can be either
               Thursday
                 11:45am Lunch meeting.
 
+Optionally you can specify a warning time (in minutes) for an
+entry following the time, for example:
+
+              Thursday
+                11:45am #20 Lunch meeting.
+
 Appointments are checked every `appt-display-interval' minutes.
 The following variables control appointment notification:
 
@@ -579,20 +585,30 @@ appointment package (if it is not already active)."
                              (calendar-current-date) (caar entry-list)))
                   (setq time-string (cadr (car entry-list)))
                   (while (string-match appt-time-regexp time-string)
-                    (let* ((beg (match-beginning 0))
+                    (let* ((time-beg (match-beginning 0))
+                           (time-end (match-end 0))
                            ;; Get just the time for this appointment.
                            (only-time (match-string 0 time-string))
+                           (warntime
+                            (when (eq time-end
+                                      (string-match
+                                       "[ \t]*#\\([-+]?[0-9]+\\)[ \t]+"
+                                       time-string time-end))
+                              (prog1 (string-to-number
+                                      (match-string 1 time-string))
+                                (setq time-string (replace-match
+                                                   " " nil nil time-string)))))
                            ;; Find the end of this appointment
                            ;; (the start of the next).
                            (end (string-match
                                  (concat "\n[ \t]*" appt-time-regexp)
-                                 time-string
-                                 (match-end 0)))
+                                 time-string time-end))
                            ;; Get the whole string for this appointment.
                            (appt-time-string
-                            (substring time-string beg end))
+                            (substring time-string time-beg end))
                            (appt-time (list (appt-convert-time only-time)))
-                           (time-msg (list appt-time appt-time-string)))
+                           (time-msg (list appt-time appt-time-string
+                                           nil warntime)))
                       ;; Add this appointment to appt-time-msg-list.
                       (setq appt-time-msg-list
                             (nconc appt-time-msg-list (list time-msg))





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

* Re: [appt] allow specifying warning time in diary
  2010-09-08 20:38     ` Leo
@ 2010-09-09  8:54       ` Daniel Pittman
  2010-09-10 11:11         ` Leo
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Pittman @ 2010-09-09  8:54 UTC (permalink / raw)
  To: emacs-devel

Leo <sdl.web@gmail.com> writes:
> On 2010-09-08 15:55 +0100, Leo wrote:
>
>> Thanks for the interest. The previous patch doesn't take into account of
>> non-zero time-beg. This one fixes it and is simpler.

[...]

> +Optionally you can specify a warning time (in minutes) for an
> +entry following the time, for example:
> +
> +              Thursday
> +                11:45am #20 Lunch meeting.
> +

I just caught up on this; wouldn't it be nicer to either use a real time value
(#:20, allowing for #1:00 or #1:20), or postfix that with the units, rather
than just assume minutes?

Otherwise my standard set of reminders for events would be:

  Thursday
    11:45AM #180 #60 #15 I /am/ rather forgetful and love reminders.

Regards,
        Daniel

-- 
✣ Daniel Pittman            ✉ daniel@rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons




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

* Re: [appt] allow specifying warning time in diary
  2010-09-09  8:54       ` Daniel Pittman
@ 2010-09-10 11:11         ` Leo
  2010-09-14  0:22           ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Leo @ 2010-09-10 11:11 UTC (permalink / raw)
  To: emacs-devel

On 2010-09-09 09:54 +0100, Daniel Pittman wrote:
>> +Optionally you can specify a warning time (in minutes) for an
>> +entry following the time, for example:
>> +
>> +              Thursday
>> +                11:45am #20 Lunch meeting.
>> +
>
> I just caught up on this; wouldn't it be nicer to either use a real
> time value (#:20, allowing for #1:00 or #1:20), or postfix that with
> the units, rather than just assume minutes?
>
> Otherwise my standard set of reminders for events would be:
>
>   Thursday
>     11:45AM #180 #60 #15 I /am/ rather forgetful and love reminders.
>
> Regards,
>         Daniel

The syntax can be changed without too much effort. I wonder if
supporting a set of reminders (warning times) is a welcomed feature.

I am thinking something like this.

The last element in appt-time-msg-list, the warning time, can take a
list of times and for each but the last value in that list, it will warn
for a duration (say 15 minutes).

For my personal use single warning time is enough. My patch is to
address the issue that setting a good default value for
appt-message-warning-time is impossible.

Leo




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

* Re: [appt] allow specifying warning time in diary
  2010-09-10 11:11         ` Leo
@ 2010-09-14  0:22           ` Glenn Morris
  2010-09-25 13:21             ` Leo
  0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2010-09-14  0:22 UTC (permalink / raw)
  To: Leo; +Cc: emacs-devel


Thanks, I'd like to see something like this, but I'd like a more
general solution that allows one to specify arbitrary appt parameters
in a diary entry. There aren't really any to specify apart from the
warntime at present, but in future one could imagine different
importance levels, notification methods, etc.

What I had in mind was a (customizable) marker at the end of diary
entries, which would be followed by a series of key/value pairs. Eg

10:30 Do stuff ## warntime 10 importance low ...

These would be stripped in the diary display.




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

* Re: [appt] allow specifying warning time in diary
  2010-09-14  0:22           ` Glenn Morris
@ 2010-09-25 13:21             ` Leo
  0 siblings, 0 replies; 10+ messages in thread
From: Leo @ 2010-09-25 13:21 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

On 2010-09-14 01:22 +0100, Glenn Morris wrote:
> Thanks, I'd like to see something like this, but I'd like a more
> general solution that allows one to specify arbitrary appt parameters
> in a diary entry. There aren't really any to specify apart from the
> warntime at present, but in future one could imagine different
> importance levels, notification methods, etc.
>
> What I had in mind was a (customizable) marker at the end of diary
> entries, which would be followed by a series of key/value pairs. Eg
>
> 10:30 Do stuff ## warntime 10 importance low ...
>
> These would be stripped in the diary display.

I think those are good things to add although I have tried to see if I
need them in the past few days, and it turns out specifying the warning
time is the only thing I need at the moment.

Leo



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

end of thread, other threads:[~2010-09-25 13:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-08  8:54 [appt] allow specifying warning time in diary Leo
2010-09-08  9:29 ` Andreas Schwab
2010-09-08  9:48   ` Leo
2010-09-08 14:34 ` Stefan Monnier
2010-09-08 14:55   ` Leo
2010-09-08 20:38     ` Leo
2010-09-09  8:54       ` Daniel Pittman
2010-09-10 11:11         ` Leo
2010-09-14  0:22           ` Glenn Morris
2010-09-25 13:21             ` Leo

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

	https://git.savannah.gnu.org/cgit/emacs.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).