emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r104135: Allow per-appointment warnin


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104135: Allow per-appointment warning times.
Date: Fri, 06 May 2011 00:14:30 -0700
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104135
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Fri 2011-05-06 00:14:30 -0700
message:
  Allow per-appointment warning times.
  
  * lisp/calendar/appt.el (appt-message-warning-time): Doc fix.
  (appt-warning-time-regexp): New option.
  (appt-make-list): Respect appt-message-warning-time.
  
  * doc/emacs/calendar.texi (Appointments): Mention appt-warning-time-regexp.
  
  * etc/NEWS: Mention this.
modified:
  doc/emacs/ChangeLog
  doc/emacs/calendar.texi
  etc/NEWS
  lisp/ChangeLog
  lisp/calendar/appt.el
=== modified file 'doc/emacs/ChangeLog'
--- a/doc/emacs/ChangeLog       2011-05-06 04:28:53 +0000
+++ b/doc/emacs/ChangeLog       2011-05-06 07:14:30 +0000
@@ -1,5 +1,7 @@
 2011-05-06  Glenn Morris  <address@hidden>
 
+       * calendar.texi (Appointments): Mention appt-warning-time-regexp.
+
        * cal-xtra.texi (Fancy Diary Display): Mention diary comments.
 
 2011-05-02  Lars Magne Ingebrigtsen  <address@hidden>

=== modified file 'doc/emacs/calendar.texi'
--- a/doc/emacs/calendar.texi   2011-01-25 04:08:28 +0000
+++ b/doc/emacs/calendar.texi   2011-05-06 07:14:30 +0000
@@ -1489,11 +1489,15 @@
 @end example
 
 @vindex appt-message-warning-time
address@hidden appt-warning-time-regexp
 @noindent
 Then on Mondays, you will be reminded at around 9:20am about your
 coffee break and at around 11:50am about lunch.  The variable
 @code{appt-message-warning-time} specifies how many minutes (default 12)
-in advance to warn you.
+in advance to warn you.  This is a default warning time.  Each
+appointment can specify a different warning time by adding a piece
+matching @code{appt-warning-time-regexp} (see that variable's
+documentation for details).
 
   You can write times in am/pm style (with @samp{12:00am} standing
 for midnight and @samp{12:00pm} standing for noon), or 24-hour

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2011-05-06 06:30:56 +0000
+++ b/etc/NEWS  2011-05-06 07:14:30 +0000
@@ -451,6 +451,10 @@
 *** Diary entries can contain non-printing `comments'.
 See the variable `diary-comment-start'.
 
++++
+*** Appointments can specify their individual warning times.
+See the variable `appt-warning-time-regexp'.
+
 *** New function `diary-hebrew-birthday'.
 
 ---

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-05-06 04:28:53 +0000
+++ b/lisp/ChangeLog    2011-05-06 07:14:30 +0000
@@ -1,5 +1,9 @@
 2011-05-06  Glenn Morris  <address@hidden>
 
+       * calendar/appt.el (appt-message-warning-time): Doc fix.
+       (appt-warning-time-regexp): New option.
+       (appt-make-list): Respect appt-message-warning-time.
+
        * calendar/diary-lib.el (diary-comment-start, diary-comment-end):
        New options.
        (diary-add-to-list): Strip comments from the displayed string.

=== modified file 'lisp/calendar/appt.el'
--- a/lisp/calendar/appt.el     2011-04-19 04:11:01 +0000
+++ b/lisp/calendar/appt.el     2011-05-06 07:14:30 +0000
@@ -84,10 +84,22 @@
   :group 'calendar)
 
 (defcustom appt-message-warning-time 12
-  "Time in minutes before an appointment that the warning begins."
+  "Default time in minutes before an appointment that the warning begins."
   :type 'integer
   :group 'appt)
 
+(defcustom appt-warning-time-regexp "warntime \\([0-9]+\\)"
+  "Regexp matching a string giving the warning time for an appointment.
+The first subexpression matches the time in minutes (an integer).
+This overrides the default `appt-message-warning-time'.
+You may want to put this inside a diary comment (see `diary-comment-start').
+For example, to be warned 30 minutes in advance of an appointment:
+   2011/06/01 12:00 Do something ## warntime 30
+"
+  :version "24.1"
+  :type 'regexp
+  :group 'appt)
+
 (defcustom appt-audible t
   "Non-nil means beep to indicate appointment."
   :type 'boolean
@@ -509,7 +521,7 @@
             ;; entry begins with a time, add it to the
             ;; appt-time-msg-list.  Then sort the list.
             (let ((entry-list diary-entries-list)
-                  time-string)
+                  time-string literal)
               ;; Below, we assume diary-entries-list was in date
               ;; order.  It is, unless something on
               ;; diary-list-entries-hook has changed it, eg
@@ -530,7 +542,10 @@
               (while (and entry-list
                           (calendar-date-equal
                            (calendar-current-date) (caar entry-list)))
-                (setq time-string (cadr (car entry-list)))
+                (setq time-string (cadr (car entry-list))
+                      ;; Including any comments.
+                      literal (or (nth 2 (nth 3 (car entry-list)))
+                                  time-string))
                 (while (string-match appt-time-regexp time-string)
                   (let* ((beg (match-beginning 0))
                          ;; Get just the time for this appointment.
@@ -541,17 +556,30 @@
                                (concat "\n[ \t]*" appt-time-regexp)
                                time-string
                                (match-end 0)))
+                         (warntime
+                          (if (string-match appt-warning-time-regexp literal)
+                              (string-to-number (match-string 1 literal))))
                          ;; Get the whole string for this appointment.
                          (appt-time-string
                           (substring time-string beg end))
                          (appt-time (list (appt-convert-time only-time)))
-                         (time-msg (list appt-time appt-time-string)))
+                         (time-msg (append
+                                    (list appt-time appt-time-string)
+                                    (if warntime (list nil warntime)))))
                     ;; Add this appointment to appt-time-msg-list.
                     (setq appt-time-msg-list
                           (nconc appt-time-msg-list (list time-msg))
                           ;; Discard this appointment from the string.
+                          ;; (This allows for multiple appts per entry.)
                           time-string
-                          (if end (substring time-string end) ""))))
+                          (if end (substring time-string end) ""))
+                    ;; Similarly, discard the start of literal.
+                    (and (> (length time-string) 0)
+                         (string-match appt-time-regexp literal)
+                         (setq end (string-match
+                                    (concat "\n[ \t]*" appt-time-regexp)
+                                    literal (match-end 0)))
+                         (setq literal (substring literal end)))))
                 (setq entry-list (cdr entry-list)))))
         (setq appt-time-msg-list (appt-sort-list appt-time-msg-list))
         ;; Convert current time to minutes after midnight (12:01am = 1),


reply via email to

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