[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] appointment implement variable warning time

From: Ivan Kanis
Subject: [PATCH] appointment implement variable warning time
Date: Thu, 17 Dec 2009 13:42:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Hi Glenn,

I use appointment with org. I find that a global time delay for each
appointments is inconvenient. For example I need to be warned an hour
before an appointment downtown and only 5 minutes for a meeting at
work. I have hacked appt.el to keep track of a delay for each
appointment. The function appt-add is compatible with the old appt.

The last patch I posted on emacs devel broke appt-add. I have made the
third variable optional so that it's backward compatible. Could you
apply this patch to trunk?

diff -r 4003cf05080d -r 5def94ddbc89 lisp/misc/appt.el
--- a/lisp/misc/appt.el Thu Dec 17 10:13:58 2009 +0100
+++ b/lisp/misc/appt.el Thu Dec 17 10:17:32 2009 +0100
@@ -355,6 +355,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))
@@ -362,21 +364,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)
               (setq min-to-app (+ (- (1+ appt-max-time) cur-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))
@@ -472,14 +474,20 @@
-(defun appt-add (new-appt-time new-appt-msg)
+(defun appt-add (new-appt-time new-appt-msg &optional warn)
   "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 warn
+        (if (or (not warn) (string= warn ""))
+            appt-message-warning-time
+          (string-to-number warn)))
   (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
+                        warn)))
     (unless (member time-msg appt-time-msg-list)
       (setq appt-time-msg-list
             (appt-sort-list (nconc appt-time-msg-list (list time-msg)))))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]