diff options
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/calendar/appt.el | 53 |
2 files changed, 43 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7ddd2325882..f3aff53e1b3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-06-15 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * calendar/appt.el (appt-time-msg-list): Doc fix. | ||
| 4 | (appt-check): Let-bind appt-warn-time. | ||
| 5 | (appt-add): Make the 3rd argument optional. | ||
| 6 | Simplify argument names. Doc fix. Check for integer WARNTIME. | ||
| 7 | Only add WARNTIME to the output list if non-nil. | ||
| 8 | |||
| 1 | 2010-06-15 Ivan Kanis <apple@kanis.eu> | 9 | 2010-06-15 Ivan Kanis <apple@kanis.eu> |
| 2 | 10 | ||
| 3 | * calendar/appt.el (appt-check): Let the 3rd element of | 11 | * calendar/appt.el (appt-check): Let the 3rd element of |
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el index 4ccdaac5264..7fcaab9da34 100644 --- a/lisp/calendar/appt.el +++ b/lisp/calendar/appt.el | |||
| @@ -183,16 +183,25 @@ Only relevant if reminders are being displayed in a window." | |||
| 183 | (defconst appt-buffer-name "*appt-buf*" | 183 | (defconst appt-buffer-name "*appt-buf*" |
| 184 | "Name of the appointments buffer.") | 184 | "Name of the appointments buffer.") |
| 185 | 185 | ||
| 186 | ;; TODO Turn this into an alist? It would be easier to add more | ||
| 187 | ;; optional elements. | ||
| 188 | ;; TODO There should be a way to set WARNTIME (and other properties) | ||
| 189 | ;; from the diary-file. Implementing that would be a good reason | ||
| 190 | ;; to change this to an alist. | ||
| 186 | (defvar appt-time-msg-list nil | 191 | (defvar appt-time-msg-list nil |
| 187 | "The list of appointments for today. | 192 | "The list of appointments for today. |
| 188 | Use `appt-add' and `appt-delete' to add and delete appointments. | 193 | Use `appt-add' and `appt-delete' to add and delete appointments. |
| 189 | The original list is generated from today's `diary-entries-list', and | 194 | The original list is generated from today's `diary-entries-list', and |
| 190 | can be regenerated using the function `appt-check'. | 195 | can be regenerated using the function `appt-check'. |
| 191 | Each element of the generated list has the form (MINUTES STRING [FLAG]); where | 196 | Each element of the generated list has the form |
| 192 | MINUTES is the time in minutes of the appointment after midnight, and | 197 | \(MINUTES STRING [FLAG] [WARNTIME]) |
| 193 | STRING is the description of the appointment. | 198 | where MINUTES is the time in minutes of the appointment after midnight, |
| 194 | FLAG, if non-nil, says that the element was made with `appt-add' | 199 | and STRING is the description of the appointment. |
| 195 | so calling `appt-make-list' again should preserve it.") | 200 | FLAG and WARNTIME can only be present if the element was made |
| 201 | with `appt-add'. A non-nil FLAG indicates that the element was made | ||
| 202 | with `appt-add', so calling `appt-make-list' again should preserve it. | ||
| 203 | If WARNTIME is non-nil, it is an integer to use in place | ||
| 204 | of `appt-message-warning-time'.") | ||
| 196 | 205 | ||
| 197 | (defconst appt-max-time (1- (* 24 60)) | 206 | (defconst appt-max-time (1- (* 24 60)) |
| 198 | "11:59pm in minutes - number of minutes in a day minus 1.") | 207 | "11:59pm in minutes - number of minutes in a day minus 1.") |
| @@ -313,7 +322,7 @@ displayed in a window: | |||
| 313 | (zerop (mod prev-appt-display-count appt-display-interval)))) | 322 | (zerop (mod prev-appt-display-count appt-display-interval)))) |
| 314 | ;; Non-nil means only update the interval displayed in the mode line. | 323 | ;; Non-nil means only update the interval displayed in the mode line. |
| 315 | (mode-line-only (unless full-check appt-now-displayed)) | 324 | (mode-line-only (unless full-check appt-now-displayed)) |
| 316 | now cur-comp-time appt-comp-time) | 325 | now cur-comp-time appt-comp-time appt-warn-time) |
| 317 | (when (or full-check mode-line-only) | 326 | (when (or full-check mode-line-only) |
| 318 | (save-excursion | 327 | (save-excursion |
| 319 | ;; Convert current time to minutes after midnight (12.01am = 1). | 328 | ;; Convert current time to minutes after midnight (12.01am = 1). |
| @@ -472,20 +481,28 @@ Usually just deletes the appointment buffer." | |||
| 472 | "[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?") | 481 | "[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?") |
| 473 | 482 | ||
| 474 | ;;;###autoload | 483 | ;;;###autoload |
| 475 | (defun appt-add (new-appt-time new-appt-msg new-appt-warning-time) | 484 | (defun appt-add (time msg &optional warntime) |
| 476 | "Add an appointment for today at NEW-APPT-TIME with message NEW-APPT-MSG. | 485 | "Add an appointment for today at TIME with message MSG. |
| 477 | The time should be in either 24 hour format or am/pm format." | 486 | The time should be in either 24 hour format or am/pm format. |
| 487 | Optional argument WARNTIME is an integer (or string) giving the number | ||
| 488 | of minutes before the appointment at which to start warning. | ||
| 489 | The default is `appt-message-warning-time'." | ||
| 478 | (interactive "sTime (hh:mm[am/pm]): \nsMessage: | 490 | (interactive "sTime (hh:mm[am/pm]): \nsMessage: |
| 479 | sDelay in minutes (press return for default): ") | 491 | sMinutes before the appointment to start warning: ") |
| 480 | (unless (string-match appt-time-regexp new-appt-time) | 492 | (unless (string-match appt-time-regexp time) |
| 481 | (error "Unacceptable time-string")) | 493 | (error "Unacceptable time-string")) |
| 482 | (setq new-appt-warning-time | 494 | (and (stringp warntime) |
| 483 | (if (string= new-appt-warning-time "") | 495 | (setq warntime (unless (string-equal warntime "") |
| 484 | appt-message-warning-time | 496 | (string-to-number warntime)))) |
| 485 | (string-to-number new-appt-warning-time))) | 497 | (and warntime |
| 486 | (let ((time-msg (list (list (appt-convert-time new-appt-time)) | 498 | (not (integerp warntime)) |
| 487 | (concat new-appt-time " " new-appt-msg) t | 499 | (error "Argument WARNTIME must be an integer, or nil")) |
| 488 | new-appt-warning-time))) | 500 | (let ((time-msg (list (list (appt-convert-time time)) |
| 501 | (concat time " " msg) t))) | ||
| 502 | ;; It is presently non-sensical to have multiple warnings about | ||
| 503 | ;; the same appointment with just different delays, but it might | ||
| 504 | ;; not always be so. TODO | ||
| 505 | (if warntime (setq time-msg (append time-msg (list warntime)))) | ||
| 489 | (unless (member time-msg appt-time-msg-list) | 506 | (unless (member time-msg appt-time-msg-list) |
| 490 | (setq appt-time-msg-list | 507 | (setq appt-time-msg-list |
| 491 | (appt-sort-list (nconc appt-time-msg-list (list time-msg))))))) | 508 | (appt-sort-list (nconc appt-time-msg-list (list time-msg))))))) |