changeset 109002:adda58866253

Close bug#5176. * lisp/calendar/appt.el (appt-check): Let the 3rd element of appt-time-msg-list specify the warning time. (appt-add): Add new argument with the warning time.
author Glenn Morris <rgm@gnu.org>
date Mon, 14 Jun 2010 20:38:58 -0700
parents fe1cb647c842
children ccf6e90ae542
files lisp/ChangeLog lisp/calendar/appt.el
diffstat 2 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Jun 12 13:21:01 2010 -0400
+++ b/lisp/ChangeLog	Mon Jun 14 20:38:58 2010 -0700
@@ -1,3 +1,9 @@
+2010-06-15  Ivan Kanis  <apple@kanis.eu>
+
+	* calendar/appt.el (appt-check): Let the 3rd element of
+	appt-time-msg-list specify the warning time.
+	(appt-add): Add new argument with the warning time.  (Bug#5176)
+
 2010-06-12  Bob Rogers  <rogers-emacs@rgrjr.dyndns.org>  (tiny change)
 
 	* vc-svn.el (vc-svn-after-dir-status): Fix regexp for Subversions
--- a/lisp/calendar/appt.el	Sat Jun 12 13:21:01 2010 -0400
+++ b/lisp/calendar/appt.el	Mon Jun 14 20:38:58 2010 -0700
@@ -353,6 +353,8 @@
         ;; calculate the number of minutes until the appointment.
         (when (and appt-issue-message appt-time-msg-list)
           (setq appt-comp-time (caar (car appt-time-msg-list))
+                appt-warn-time (or (nth 3 (car appt-time-msg-list))
+                                   appt-message-warning-time)
                 min-to-app (- appt-comp-time cur-comp-time))
           (while (and appt-time-msg-list
                       (< appt-comp-time cur-comp-time))
@@ -360,21 +362,21 @@
             (if appt-time-msg-list
                 (setq appt-comp-time (caar (car appt-time-msg-list)))))
           ;; If we have an appointment between midnight and
-          ;; `appt-message-warning-time' minutes after midnight, we
+          ;; `appt-warn-time' minutes after midnight, we
           ;; must begin to issue a message before midnight.  Midnight
           ;; is considered 0 minutes and 11:59pm is 1439
           ;; minutes.  Therefore we must recalculate the minutes to
           ;; appointment variable.  It is equal to the number of
           ;; minutes before midnight plus the number of minutes after
           ;; midnight our appointment is.
-          (if (and (< appt-comp-time appt-message-warning-time)
-                   (> (+ cur-comp-time appt-message-warning-time)
+          (if (and (< appt-comp-time appt-warn-time)
+                   (> (+ cur-comp-time appt-warn-time)
                       appt-max-time))
               (setq min-to-app (+ (- (1+ appt-max-time) cur-comp-time)
                                   appt-comp-time)))
           ;; Issue warning if the appointment time is within
           ;; appt-message-warning time.
-          (when (and (<= min-to-app appt-message-warning-time)
+          (when (and (<= min-to-app appt-warn-time)
                      (>= min-to-app 0))
             (setq appt-now-displayed t
                   appt-display-count (1+ prev-appt-display-count))
@@ -470,14 +472,20 @@
   "[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?")
 
 ;;;###autoload
-(defun appt-add (new-appt-time new-appt-msg)
+(defun appt-add (new-appt-time new-appt-msg new-appt-warning-time)
   "Add an appointment for today at NEW-APPT-TIME with message NEW-APPT-MSG.
 The time should be in either 24 hour format or am/pm format."
-  (interactive "sTime (hh:mm[am/pm]): \nsMessage: ")
+  (interactive "sTime (hh:mm[am/pm]): \nsMessage: 
+sDelay in minutes (press return for default): ")
   (unless (string-match appt-time-regexp new-appt-time)
     (error "Unacceptable time-string"))
+  (setq new-appt-warning-time
+        (if (string= new-appt-warning-time "")
+            appt-message-warning-time
+          (string-to-number new-appt-warning-time)))
   (let ((time-msg (list (list (appt-convert-time new-appt-time))
-                        (concat new-appt-time " " new-appt-msg) t)))
+                        (concat new-appt-time " " new-appt-msg) t
+                        new-appt-warning-time)))
     (unless (member time-msg appt-time-msg-list)
       (setq appt-time-msg-list
             (appt-sort-list (nconc appt-time-msg-list (list time-msg)))))))