-Any appointments made with `appt-add' are not affected by this function.
-
-For backwards compatibility, this function activates the
-appointment package (if it is not already active)."
- ;; See comments above appt-activate defun.
- (if (not appt-timer)
- (appt-activate 1)
- ;; We have something to do if the range of dates that the diary is
- ;; considering includes the current date.
- (if (and (not (calendar-date-compare
- (list (calendar-current-date))
- (list original-date)))
- (calendar-date-compare
- (list (calendar-current-date))
- (list (calendar-gregorian-from-absolute
- (+ (calendar-absolute-from-gregorian original-date)
- number)))))
- (save-excursion
- ;; Clear the appointments list, then fill it in from the diary.
- (dolist (elt appt-time-msg-list)
- ;; Delete any entries that were not made with appt-add.
- (unless (nth 2 elt)
- (setq appt-time-msg-list
- (delq elt appt-time-msg-list))))
- (if diary-entries-list
- ;; Cycle through the entry-list (diary-entries-list)
- ;; looking for entries beginning with a time. If the
- ;; entry begins with a time, add it to the
- ;; appt-time-msg-list. Then sort the list.
- (let ((entry-list diary-entries-list)
- (new-time-string "")
- time-string)
- ;; Skip diary entries for dates before today.
- (while (and entry-list
- (calendar-date-compare
- (car entry-list) (list (calendar-current-date))))
- (setq entry-list (cdr entry-list)))
- ;; Parse the entries for today.
- (while (and entry-list
- (calendar-date-equal
- (calendar-current-date) (caar entry-list)))
- (setq time-string (cadr (car entry-list)))
- (while (string-match appt-time-regexp time-string)
- (let* ((beg (match-beginning 0))
- ;; Get just the time for this appointment.
- (only-time (match-string 0 time-string))
- ;; Find the end of this appointment
- ;; (the start of the next).
- (end (string-match
- (concat "\n[ \t]*" appt-time-regexp)
- time-string
- (match-end 0)))
- ;; 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)))
- ;; 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.
- time-string
- (if end (substring time-string 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),
- ;; so that elements in the list that are earlier than the
- ;; present time can be removed.
- (let* ((now (decode-time))
- (cur-comp-time (+ (* 60 (nth 2 now)) (nth 1 now)))
- (appt-comp-time (caar (car appt-time-msg-list))))
- (while (and appt-time-msg-list (< appt-comp-time cur-comp-time))
- (setq appt-time-msg-list (cdr appt-time-msg-list))
- (if appt-time-msg-list
- (setq appt-comp-time (caar (car appt-time-msg-list))))))))))
+Any appointments made with `appt-add' are not affected by this function."
+ ;; We have something to do if the range of dates that the diary is
+ ;; considering includes the current date.
+ (if (and (not (calendar-date-compare
+ (list (calendar-current-date))
+ (list original-date)))
+ (calendar-date-compare
+ (list (calendar-current-date))
+ (list (calendar-gregorian-from-absolute
+ (+ (calendar-absolute-from-gregorian original-date)
+ number)))))
+ (save-excursion
+ ;; Clear the appointments list, then fill it in from the diary.
+ (dolist (elt appt-time-msg-list)
+ ;; Delete any entries that were not made with appt-add.
+ (unless (nth 2 elt)
+ (setq appt-time-msg-list
+ (delq elt appt-time-msg-list))))
+ (if diary-entries-list
+ ;; Cycle through the entry-list (diary-entries-list)
+ ;; looking for entries beginning with a time. If the
+ ;; 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 literal)
+ ;; Below, we assume diary-entries-list was in date
+ ;; order. It is, unless something on
+ ;; diary-list-entries-hook has changed it, eg
+ ;; diary-include-other-files (bug#7019). It must be
+ ;; in date order if number = 1.
+ (and diary-list-entries-hook
+ appt-display-diary
+ (not (eq diary-number-of-entries 1))
+ (not (memq (car (last diary-list-entries-hook))
+ '(diary-sort-entries sort-diary-entries)))
+ (setq entry-list (sort entry-list 'diary-entry-compare)))
+ ;; Skip diary entries for dates before today.
+ (while (and entry-list
+ (calendar-date-compare
+ (car entry-list) (list (calendar-current-date))))
+ (setq entry-list (cdr entry-list)))
+ ;; Parse the entries for today.
+ (while (and entry-list
+ (calendar-date-equal
+ (calendar-current-date) (caar 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.
+ (only-time (match-string 0 time-string))
+ ;; Find the end of this appointment
+ ;; (the start of the next).
+ (end (string-match
+ (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))
+ ;; FIXME why the list? It makes the first
+ ;; element (MINUTES) rather than MINUTES.
+ (appt-time (list (appt-convert-time only-time)))
+ (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) ""))
+ ;; 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),
+ ;; and remove elements in the list that are in the past.
+ (let* ((now (decode-time))
+ (now-mins (+ (* 60 (nth 2 now)) (nth 1 now))))
+ (while (and appt-time-msg-list
+ (< (caar (car appt-time-msg-list)) now-mins))
+ (setq appt-time-msg-list (cdr appt-time-msg-list)))))))