Mercurial > emacs
changeset 109003:ccf6e90ae542
Tweak previous change.
* lisp/calendar/appt.el (appt-time-msg-list): Doc fix.
(appt-check): Let-bind appt-warn-time.
(appt-add): Make the 3rd argument optional.
Simplify argument names. Doc fix. Check for integer WARNTIME.
Only add WARNTIME to the output list if non-nil.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 14 Jun 2010 20:42:33 -0700 |
parents | adda58866253 |
children | fd2ae9b03967 |
files | lisp/ChangeLog lisp/calendar/appt.el |
diffstat | 2 files changed, 43 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Mon Jun 14 20:38:58 2010 -0700 +++ b/lisp/ChangeLog Mon Jun 14 20:42:33 2010 -0700 @@ -1,3 +1,11 @@ +2010-06-15 Glenn Morris <rgm@gnu.org> + + * calendar/appt.el (appt-time-msg-list): Doc fix. + (appt-check): Let-bind appt-warn-time. + (appt-add): Make the 3rd argument optional. + Simplify argument names. Doc fix. Check for integer WARNTIME. + Only add WARNTIME to the output list if non-nil. + 2010-06-15 Ivan Kanis <apple@kanis.eu> * calendar/appt.el (appt-check): Let the 3rd element of
--- a/lisp/calendar/appt.el Mon Jun 14 20:38:58 2010 -0700 +++ b/lisp/calendar/appt.el Mon Jun 14 20:42:33 2010 -0700 @@ -183,16 +183,25 @@ (defconst appt-buffer-name "*appt-buf*" "Name of the appointments buffer.") +;; TODO Turn this into an alist? It would be easier to add more +;; optional elements. +;; TODO There should be a way to set WARNTIME (and other properties) +;; from the diary-file. Implementing that would be a good reason +;; to change this to an alist. (defvar appt-time-msg-list nil "The list of appointments for today. Use `appt-add' and `appt-delete' to add and delete appointments. The original list is generated from today's `diary-entries-list', and can be regenerated using the function `appt-check'. -Each element of the generated list has the form (MINUTES STRING [FLAG]); where -MINUTES is the time in minutes of the appointment after midnight, and -STRING is the description of the appointment. -FLAG, if non-nil, says that the element was made with `appt-add' -so calling `appt-make-list' again should preserve it.") +Each element of the generated list has the form +\(MINUTES STRING [FLAG] [WARNTIME]) +where MINUTES is the time in minutes of the appointment after midnight, +and STRING is the description of the appointment. +FLAG and WARNTIME can only be present if the element was made +with `appt-add'. A non-nil FLAG indicates that the element was made +with `appt-add', so calling `appt-make-list' again should preserve it. +If WARNTIME is non-nil, it is an integer to use in place +of `appt-message-warning-time'.") (defconst appt-max-time (1- (* 24 60)) "11:59pm in minutes - number of minutes in a day minus 1.") @@ -313,7 +322,7 @@ (zerop (mod prev-appt-display-count appt-display-interval)))) ;; Non-nil means only update the interval displayed in the mode line. (mode-line-only (unless full-check appt-now-displayed)) - now cur-comp-time appt-comp-time) + now cur-comp-time appt-comp-time appt-warn-time) (when (or full-check mode-line-only) (save-excursion ;; Convert current time to minutes after midnight (12.01am = 1). @@ -472,20 +481,28 @@ "[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?") ;;;###autoload -(defun appt-add (new-appt-time new-appt-msg new-appt-warning-time) - "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." +(defun appt-add (time msg &optional warntime) + "Add an appointment for today at TIME with message MSG. +The time should be in either 24 hour format or am/pm format. +Optional argument WARNTIME is an integer (or string) giving the number +of minutes before the appointment at which to start warning. +The default is `appt-message-warning-time'." (interactive "sTime (hh:mm[am/pm]): \nsMessage: -sDelay in minutes (press return for default): ") - (unless (string-match appt-time-regexp new-appt-time) +sMinutes before the appointment to start warning: ") + (unless (string-match appt-time-regexp time) (error "Unacceptable time-string")) - (setq new-appt-warning-time - (if (string= new-appt-warning-time "") - appt-message-warning-time - (string-to-number new-appt-warning-time))) - (let ((time-msg (list (list (appt-convert-time new-appt-time)) - (concat new-appt-time " " new-appt-msg) t - new-appt-warning-time))) + (and (stringp warntime) + (setq warntime (unless (string-equal warntime "") + (string-to-number warntime)))) + (and warntime + (not (integerp warntime)) + (error "Argument WARNTIME must be an integer, or nil")) + (let ((time-msg (list (list (appt-convert-time time)) + (concat time " " msg) t))) + ;; It is presently non-sensical to have multiple warnings about + ;; the same appointment with just different delays, but it might + ;; not always be so. TODO + (if warntime (setq time-msg (append time-msg (list warntime)))) (unless (member time-msg appt-time-msg-list) (setq appt-time-msg-list (appt-sort-list (nconc appt-time-msg-list (list time-msg)))))))