aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/calendar
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1994-08-04 05:44:30 +0000
committerRichard M. Stallman <[email protected]>1994-08-04 05:44:30 +0000
commit9c197f24a18bb196618e7022522c155d53ae6f07 (patch)
tree9bc326cbbe8b616ce298ad97f64b1dcac09cdcf0 /lisp/calendar
parent1507a647c0902f04d43715c96bcea1d867a33a80 (diff)
(appt-make-list): Do nothing unless range being processed
for diary entries includes today's date.
Diffstat (limited to 'lisp/calendar')
-rw-r--r--lisp/calendar/appt.el148
1 files changed, 83 insertions, 65 deletions
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index 8040f0321a..20f61faccc 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -65,7 +65,6 @@
;;;
;;; The following three lines are required:
;;; (display-time)
-;;; (autoload 'appt-make-list "appt.el" nil t)
;;; (add-hook 'diary-hook 'appt-make-list)
;;;
;;;
@@ -445,73 +444,92 @@ The time should be in either 24 hour format or am/pm format."
;; 02/23/89
;; 12:00pm lunch
;; Wednesday
-;; 10:00am group meeting"
+;; 10:00am group meeting
+;; We assume that the variables DATE and NUMBER
+;; hold the arguments that list-diary-entries received.
+;; They specify the range of dates that the diary is being processed for.
;;;###autoload
(defun appt-make-list ()
- (setq appt-time-msg-list nil)
-
- (save-excursion
- (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 ""))
- (while (and entry-list
- (calendar-date-equal
- (calendar-current-date) (car (car entry-list))))
- (let ((time-string (substring (prin1-to-string
- (cdr (car entry-list))) 2 -2)))
-
- (while (string-match
- "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?.*"
- time-string)
- (let* ((appt-time-string (substring time-string
- (match-beginning 0)
- (match-end 0))))
-
- (if (< (match-end 0) (length time-string))
- (setq new-time-string (substring time-string
- (+ (match-end 0) 1)
- nil))
- (setq new-time-string ""))
-
- (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?"
- time-string)
-
- (let* ((appt-time (list (appt-convert-time
- (substring time-string
- (match-beginning 0)
- (match-end 0)))))
- (time-msg (cons appt-time
- (list appt-time-string))))
- (setq time-string new-time-string)
- (setq appt-time-msg-list (append appt-time-msg-list
- (list time-msg)))))))
- (setq entry-list (cdr entry-list)))))
- (setq appt-time-msg-list (appt-sort-list appt-time-msg-list))
-
- ;; Get the current time and convert it to minutes
- ;; from midnight. ie. 12:01am = 1, midnight = 0,
- ;; so that the elements in the list
- ;; that are earlier than the present time can
- ;; be removed.
-
- (let* ((cur-hour(string-to-int
- (substring (current-time-string) 11 13)))
- (cur-min (string-to-int
- (substring (current-time-string) 14 16)))
- (cur-comp-time (+ (* cur-hour 60) cur-min))
- (appt-comp-time (car (car (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 (car (car (car appt-time-msg-list)))))))))
+ ;; 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.
+ (setq appt-time-msg-list nil)
+ (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 ""))
+ ;; 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) (car (car entry-list))))
+ (let ((time-string (substring (prin1-to-string
+ (cdr (car entry-list))) 2 -2)))
+
+ (while (string-match
+ "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?.*"
+ time-string)
+ (let* ((appt-time-string (substring time-string
+ (match-beginning 0)
+ (match-end 0))))
+
+ (if (< (match-end 0) (length time-string))
+ (setq new-time-string (substring time-string
+ (+ (match-end 0) 1)
+ nil))
+ (setq new-time-string ""))
+
+ (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?"
+ time-string)
+
+ (let* ((appt-time (list (appt-convert-time
+ (substring time-string
+ (match-beginning 0)
+ (match-end 0)))))
+ (time-msg (cons appt-time
+ (list appt-time-string))))
+ (setq time-string new-time-string)
+ (setq appt-time-msg-list (append appt-time-msg-list
+ (list time-msg)))))))
+ (setq entry-list (cdr entry-list)))))
+ (setq appt-time-msg-list (appt-sort-list appt-time-msg-list))
+
+ ;; Get the current time and convert it to minutes
+ ;; from midnight. ie. 12:01am = 1, midnight = 0,
+ ;; so that the elements in the list
+ ;; that are earlier than the present time can
+ ;; be removed.
+
+ (let* ((cur-hour(string-to-int
+ (substring (current-time-string) 11 13)))
+ (cur-min (string-to-int
+ (substring (current-time-string) 14 16)))
+ (cur-comp-time (+ (* cur-hour 60) cur-min))
+ (appt-comp-time (car (car (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 (car (car (car appt-time-msg-list))))))))))
;;Simple sort to put the appointments list in order.