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

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).