diff options
| author | Glenn Morris | 2011-05-06 00:14:30 -0700 |
|---|---|---|
| committer | Glenn Morris | 2011-05-06 00:14:30 -0700 |
| commit | 5006e6344af9d8b870b32ba9cd228c2aab8fae32 (patch) | |
| tree | da353deaa9462a04f7f41d834fb64c0dda7fe240 | |
| parent | b08a63ccec4bda5556777ab8538b92726fd55a1e (diff) | |
| download | emacs-5006e6344af9d8b870b32ba9cd228c2aab8fae32.tar.gz emacs-5006e6344af9d8b870b32ba9cd228c2aab8fae32.zip | |
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.
| -rw-r--r-- | doc/emacs/ChangeLog | 2 | ||||
| -rw-r--r-- | doc/emacs/calendar.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/calendar/appt.el | 38 |
5 files changed, 48 insertions, 6 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index dbb274360fd..bec432f6f23 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2011-05-06 Glenn Morris <rgm@gnu.org> | 1 | 2011-05-06 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * calendar.texi (Appointments): Mention appt-warning-time-regexp. | ||
| 4 | |||
| 3 | * cal-xtra.texi (Fancy Diary Display): Mention diary comments. | 5 | * cal-xtra.texi (Fancy Diary Display): Mention diary comments. |
| 4 | 6 | ||
| 5 | 2011-05-02 Lars Magne Ingebrigtsen <larsi@gnus.org> | 7 | 2011-05-02 Lars Magne Ingebrigtsen <larsi@gnus.org> |
diff --git a/doc/emacs/calendar.texi b/doc/emacs/calendar.texi index 757dc3b4ac7..fabd38ecc18 100644 --- a/doc/emacs/calendar.texi +++ b/doc/emacs/calendar.texi | |||
| @@ -1489,11 +1489,15 @@ Monday | |||
| 1489 | @end example | 1489 | @end example |
| 1490 | 1490 | ||
| 1491 | @vindex appt-message-warning-time | 1491 | @vindex appt-message-warning-time |
| 1492 | @vindex appt-warning-time-regexp | ||
| 1492 | @noindent | 1493 | @noindent |
| 1493 | Then on Mondays, you will be reminded at around 9:20am about your | 1494 | Then on Mondays, you will be reminded at around 9:20am about your |
| 1494 | coffee break and at around 11:50am about lunch. The variable | 1495 | coffee break and at around 11:50am about lunch. The variable |
| 1495 | @code{appt-message-warning-time} specifies how many minutes (default 12) | 1496 | @code{appt-message-warning-time} specifies how many minutes (default 12) |
| 1496 | in advance to warn you. | 1497 | in advance to warn you. This is a default warning time. Each |
| 1498 | appointment can specify a different warning time by adding a piece | ||
| 1499 | matching @code{appt-warning-time-regexp} (see that variable's | ||
| 1500 | documentation for details). | ||
| 1497 | 1501 | ||
| 1498 | You can write times in am/pm style (with @samp{12:00am} standing | 1502 | You can write times in am/pm style (with @samp{12:00am} standing |
| 1499 | for midnight and @samp{12:00pm} standing for noon), or 24-hour | 1503 | for midnight and @samp{12:00pm} standing for noon), or 24-hour |
| @@ -451,6 +451,10 @@ You can get a comparable behavior with: | |||
| 451 | *** Diary entries can contain non-printing `comments'. | 451 | *** Diary entries can contain non-printing `comments'. |
| 452 | See the variable `diary-comment-start'. | 452 | See the variable `diary-comment-start'. |
| 453 | 453 | ||
| 454 | +++ | ||
| 455 | *** Appointments can specify their individual warning times. | ||
| 456 | See the variable `appt-warning-time-regexp'. | ||
| 457 | |||
| 454 | *** New function `diary-hebrew-birthday'. | 458 | *** New function `diary-hebrew-birthday'. |
| 455 | 459 | ||
| 456 | --- | 460 | --- |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ef5e5422222..01c646412d4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2011-05-06 Glenn Morris <rgm@gnu.org> | 1 | 2011-05-06 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * calendar/appt.el (appt-message-warning-time): Doc fix. | ||
| 4 | (appt-warning-time-regexp): New option. | ||
| 5 | (appt-make-list): Respect appt-message-warning-time. | ||
| 6 | |||
| 3 | * calendar/diary-lib.el (diary-comment-start, diary-comment-end): | 7 | * calendar/diary-lib.el (diary-comment-start, diary-comment-end): |
| 4 | New options. | 8 | New options. |
| 5 | (diary-add-to-list): Strip comments from the displayed string. | 9 | (diary-add-to-list): Strip comments from the displayed string. |
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el index 1394efa880e..f7ec64c5060 100644 --- a/lisp/calendar/appt.el +++ b/lisp/calendar/appt.el | |||
| @@ -84,10 +84,22 @@ | |||
| 84 | :group 'calendar) | 84 | :group 'calendar) |
| 85 | 85 | ||
| 86 | (defcustom appt-message-warning-time 12 | 86 | (defcustom appt-message-warning-time 12 |
| 87 | "Time in minutes before an appointment that the warning begins." | 87 | "Default time in minutes before an appointment that the warning begins." |
| 88 | :type 'integer | 88 | :type 'integer |
| 89 | :group 'appt) | 89 | :group 'appt) |
| 90 | 90 | ||
| 91 | (defcustom appt-warning-time-regexp "warntime \\([0-9]+\\)" | ||
| 92 | "Regexp matching a string giving the warning time for an appointment. | ||
| 93 | The first subexpression matches the time in minutes (an integer). | ||
| 94 | This overrides the default `appt-message-warning-time'. | ||
| 95 | You may want to put this inside a diary comment (see `diary-comment-start'). | ||
| 96 | For example, to be warned 30 minutes in advance of an appointment: | ||
| 97 | 2011/06/01 12:00 Do something ## warntime 30 | ||
| 98 | " | ||
| 99 | :version "24.1" | ||
| 100 | :type 'regexp | ||
| 101 | :group 'appt) | ||
| 102 | |||
| 91 | (defcustom appt-audible t | 103 | (defcustom appt-audible t |
| 92 | "Non-nil means beep to indicate appointment." | 104 | "Non-nil means beep to indicate appointment." |
| 93 | :type 'boolean | 105 | :type 'boolean |
| @@ -509,7 +521,7 @@ Any appointments made with `appt-add' are not affected by this function." | |||
| 509 | ;; entry begins with a time, add it to the | 521 | ;; entry begins with a time, add it to the |
| 510 | ;; appt-time-msg-list. Then sort the list. | 522 | ;; appt-time-msg-list. Then sort the list. |
| 511 | (let ((entry-list diary-entries-list) | 523 | (let ((entry-list diary-entries-list) |
| 512 | time-string) | 524 | time-string literal) |
| 513 | ;; Below, we assume diary-entries-list was in date | 525 | ;; Below, we assume diary-entries-list was in date |
| 514 | ;; order. It is, unless something on | 526 | ;; order. It is, unless something on |
| 515 | ;; diary-list-entries-hook has changed it, eg | 527 | ;; diary-list-entries-hook has changed it, eg |
| @@ -530,7 +542,10 @@ Any appointments made with `appt-add' are not affected by this function." | |||
| 530 | (while (and entry-list | 542 | (while (and entry-list |
| 531 | (calendar-date-equal | 543 | (calendar-date-equal |
| 532 | (calendar-current-date) (caar entry-list))) | 544 | (calendar-current-date) (caar entry-list))) |
| 533 | (setq time-string (cadr (car entry-list))) | 545 | (setq time-string (cadr (car entry-list)) |
| 546 | ;; Including any comments. | ||
| 547 | literal (or (nth 2 (nth 3 (car entry-list))) | ||
| 548 | time-string)) | ||
| 534 | (while (string-match appt-time-regexp time-string) | 549 | (while (string-match appt-time-regexp time-string) |
| 535 | (let* ((beg (match-beginning 0)) | 550 | (let* ((beg (match-beginning 0)) |
| 536 | ;; Get just the time for this appointment. | 551 | ;; Get just the time for this appointment. |
| @@ -541,17 +556,30 @@ Any appointments made with `appt-add' are not affected by this function." | |||
| 541 | (concat "\n[ \t]*" appt-time-regexp) | 556 | (concat "\n[ \t]*" appt-time-regexp) |
| 542 | time-string | 557 | time-string |
| 543 | (match-end 0))) | 558 | (match-end 0))) |
| 559 | (warntime | ||
| 560 | (if (string-match appt-warning-time-regexp literal) | ||
| 561 | (string-to-number (match-string 1 literal)))) | ||
| 544 | ;; Get the whole string for this appointment. | 562 | ;; Get the whole string for this appointment. |
| 545 | (appt-time-string | 563 | (appt-time-string |
| 546 | (substring time-string beg end)) | 564 | (substring time-string beg end)) |
| 547 | (appt-time (list (appt-convert-time only-time))) | 565 | (appt-time (list (appt-convert-time only-time))) |
| 548 | (time-msg (list appt-time appt-time-string))) | 566 | (time-msg (append |
| 567 | (list appt-time appt-time-string) | ||
| 568 | (if warntime (list nil warntime))))) | ||
| 549 | ;; Add this appointment to appt-time-msg-list. | 569 | ;; Add this appointment to appt-time-msg-list. |
| 550 | (setq appt-time-msg-list | 570 | (setq appt-time-msg-list |
| 551 | (nconc appt-time-msg-list (list time-msg)) | 571 | (nconc appt-time-msg-list (list time-msg)) |
| 552 | ;; Discard this appointment from the string. | 572 | ;; Discard this appointment from the string. |
| 573 | ;; (This allows for multiple appts per entry.) | ||
| 553 | time-string | 574 | time-string |
| 554 | (if end (substring time-string end) "")))) | 575 | (if end (substring time-string end) "")) |
| 576 | ;; Similarly, discard the start of literal. | ||
| 577 | (and (> (length time-string) 0) | ||
| 578 | (string-match appt-time-regexp literal) | ||
| 579 | (setq end (string-match | ||
| 580 | (concat "\n[ \t]*" appt-time-regexp) | ||
| 581 | literal (match-end 0))) | ||
| 582 | (setq literal (substring literal end))))) | ||
| 555 | (setq entry-list (cdr entry-list))))) | 583 | (setq entry-list (cdr entry-list))))) |
| 556 | (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) | 584 | (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) |
| 557 | ;; Convert current time to minutes after midnight (12:01am = 1), | 585 | ;; Convert current time to minutes after midnight (12:01am = 1), |