- (let* ((min-to-app -1)
- (prev-appt-mode-string appt-mode-string)
- (prev-appt-display-count (or appt-display-count 0))
- ;; Non-nil means do a full check for pending appointments and
- ;; display in whatever ways the user has selected. When no
- ;; appointment is being displayed, we always do a full check.
- (full-check
- (or (not appt-now-displayed)
- ;; This is true every appt-display-interval minutes.
- (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 appt-warn-time)
- (when (or full-check mode-line-only)
- (save-excursion ; FIXME ?
- ;; Convert current time to minutes after midnight (12.01am = 1).
- (setq now (decode-time)
- cur-comp-time (+ (* 60 (nth 2 now)) (nth 1 now)))
- ;; At first check in any day, update appointments to today's list.
- (if (or force ; eg initialize, diary save
- (null appt-prev-comp-time) ; first check
- (< cur-comp-time appt-prev-comp-time)) ; new day
- (ignore-errors
- (let ((diary-hook (if (assoc 'appt-make-list diary-hook)
- diary-hook
- (cons 'appt-make-list diary-hook))))
- (if appt-display-diary
- (diary)
- ;; Not displaying the diary, so we can ignore
- ;; diary-number-of-entries. Since appt.el only
- ;; works on a daily basis, no need for more entries.
- (diary-list-entries (calendar-current-date) 1 t)))))
- (setq appt-prev-comp-time cur-comp-time
- appt-mode-string nil
- appt-display-count nil)
- ;; If there are entries in the list, and the user wants a
- ;; message issued, get the first time off of the list and
- ;; calculate the number of minutes until the appointment.
- (when appt-time-msg-list
- (setq appt-comp-time (caar (car appt-time-msg-list))
- appt-warn-time (or (nth 3 (car appt-time-msg-list))
- appt-message-warning-time)
- min-to-app (- appt-comp-time cur-comp-time))
- (while (and appt-time-msg-list
- (< appt-comp-time cur-comp-time))
+ (let* ((prev-appt-mode-string appt-mode-string)
+ (prev-appt-display-count appt-display-count)
+ ;; Convert current time to minutes after midnight (12.01am = 1).
+ (now (decode-time))
+ (now-mins (+ (* 60 (nth 2 now)) (nth 1 now)))
+ appt-mins appt-warn-time min-to-app min-list string-list)
+ (save-excursion ; FIXME ?
+ ;; At first check in any day, update appointments to today's list.
+ (if (or force ; eg initialize, diary save
+ (null appt-prev-comp-time) ; first check
+ (< now-mins appt-prev-comp-time)) ; new day
+ (ignore-errors
+ (let ((diary-hook (if (assoc 'appt-make-list diary-hook)
+ diary-hook
+ (cons 'appt-make-list diary-hook))))
+ (if appt-display-diary
+ (diary)
+ ;; Not displaying the diary, so we can ignore
+ ;; diary-number-of-entries. Since appt.el only
+ ;; works on a daily basis, no need for more entries.
+ (diary-list-entries (calendar-current-date) 1 t)))))
+ ;; Reset everything now in case we somehow missed a minute,
+ ;; or (more likely) an appt was deleted. (This is the only
+ ;; reason we need prev-appt-display-count.)
+ (setq appt-prev-comp-time now-mins
+ appt-mode-string nil
+ appt-display-count 0)
+ ;; If there are entries in the list get each time off of the
+ ;; list and calculate the number of minutes until the appointment.
+ ;; TODO we are looping over all the appointments each time.
+ ;; We could instead sort them by the time at which we need to
+ ;; start warning. But then removing entries in the past becomes
+ ;; less straightforward.
+ (dolist (appt appt-time-msg-list)
+ ;; Remove any entries that are in the past.
+ ;; FIXME how can there be any such entries, given that this
+ ;; function removes entries when they hit zero minutes,
+ ;; and appt-make-list doesn't add any in the past in the first place?
+ (if (< (setq appt-mins (caar appt)) now-mins)