Commit 5006e634 authored by Glenn Morris's avatar Glenn Morris
Browse files

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.
parent b08a63cc
2011-05-06 Glenn Morris <rgm@gnu.org>
* calendar.texi (Appointments): Mention appt-warning-time-regexp.
* cal-xtra.texi (Fancy Diary Display): Mention diary comments.
2011-05-02 Lars Magne Ingebrigtsen <larsi@gnus.org>
......
......@@ -1489,11 +1489,15 @@ Monday
@end example
@vindex appt-message-warning-time
@vindex 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
......
......@@ -451,6 +451,10 @@ You can get a comparable behavior with:
*** 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'.
---
......
2011-05-06 Glenn Morris <rgm@gnu.org>
* 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.
......
......@@ -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 @@ Any appointments made with `appt-add' are not affected by this function."
;; 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 @@ Any appointments made with `appt-add' are not affected by this function."
(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 @@ Any appointments made with `appt-add' are not affected by this function."
(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),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment