comparison lisp/calendar/appt.el @ 92968:e2f0046a8cb4

(appt-check, appt-delete, appt-make-list): Use caar.
author Glenn Morris <rgm@gnu.org>
date Sat, 15 Mar 2008 02:59:34 +0000
parents 0a27edb53589
children 0f4b8a3dc49e
comparison
equal deleted inserted replaced
92967:4151ef80cb37 92968:e2f0046a8cb4
75 75
76 ;;; Code: 76 ;;; Code:
77 77
78 ;; Make sure calendar is loaded when we compile this. 78 ;; Make sure calendar is loaded when we compile this.
79 (require 'calendar) 79 (require 'calendar)
80
81 (defvar diary-selective-display)
82 80
83 81
84 (defgroup appt nil 82 (defgroup appt nil
85 "Appointment notification." 83 "Appointment notification."
86 :group 'calendar) 84 :group 'calendar)
245 appt-delete-window-function)) 243 appt-delete-window-function))
246 ((eq appt-display-format 'echo) 244 ((eq appt-display-format 'echo)
247 (message "%s" string))) 245 (message "%s" string)))
248 (if appt-audible (beep 1)))) 246 (if appt-audible (beep 1))))
249 247
248
249 (defvar diary-selective-display)
250 250
251 (defun appt-check (&optional force) 251 (defun appt-check (&optional force)
252 "Check for an appointment and update any reminder display. 252 "Check for an appointment and update any reminder display.
253 If optional argument FORCE is non-nil, reparse the diary file for 253 If optional argument FORCE is non-nil, reparse the diary file for
254 appointments. Otherwise the diary file is only parsed once per day, 254 appointments. Otherwise the diary file is only parsed once per day,
356 appt-display-count nil) 356 appt-display-count nil)
357 ;; If there are entries in the list, and the user wants a 357 ;; If there are entries in the list, and the user wants a
358 ;; message issued, get the first time off of the list and 358 ;; message issued, get the first time off of the list and
359 ;; calculate the number of minutes until the appointment. 359 ;; calculate the number of minutes until the appointment.
360 (if (and appt-issue-message appt-time-msg-list) 360 (if (and appt-issue-message appt-time-msg-list)
361 (let ((appt-comp-time (car (car (car appt-time-msg-list))))) 361 (let ((appt-comp-time (caar (car appt-time-msg-list))))
362 (setq min-to-app (- appt-comp-time cur-comp-time)) 362 (setq min-to-app (- appt-comp-time cur-comp-time))
363 363
364 (while (and appt-time-msg-list 364 (while (and appt-time-msg-list
365 (< appt-comp-time cur-comp-time)) 365 (< appt-comp-time cur-comp-time))
366 (setq appt-time-msg-list (cdr appt-time-msg-list)) 366 (setq appt-time-msg-list (cdr appt-time-msg-list))
367 (if appt-time-msg-list 367 (if appt-time-msg-list
368 (setq appt-comp-time 368 (setq appt-comp-time
369 (car (car (car appt-time-msg-list)))))) 369 (caar (car appt-time-msg-list)))))
370 ;; If we have an appointment between midnight and 370 ;; If we have an appointment between midnight and
371 ;; `appt-message-warning-time' minutes after midnight, 371 ;; `appt-message-warning-time' minutes after midnight,
372 ;; we must begin to issue a message before midnight. 372 ;; we must begin to issue a message before midnight.
373 ;; Midnight is considered 0 minutes and 11:59pm is 373 ;; Midnight is considered 0 minutes and 11:59pm is
374 ;; 1439 minutes. Therefore we must recalculate the 374 ;; 1439 minutes. Therefore we must recalculate the
492 ;; We want to quote any doublequotes 492 ;; We want to quote any doublequotes
493 ;; in the string, as well as put 493 ;; in the string, as well as put
494 ;; doublequotes around it. 494 ;; doublequotes around it.
495 (prin1-to-string 495 (prin1-to-string
496 (substring-no-properties 496 (substring-no-properties
497 (car (cdr element)) 0)) 497 (cadr element) 0))
498 " from list? ")) 498 " from list? "))
499 (test-input (y-or-n-p prompt-string))) 499 (test-input (y-or-n-p prompt-string)))
500 (setq tmp-msg-list (cdr tmp-msg-list)) 500 (setq tmp-msg-list (cdr tmp-msg-list))
501 (if test-input 501 (if test-input
502 (setq appt-time-msg-list (delq element appt-time-msg-list))))) 502 (setq appt-time-msg-list (delq element appt-time-msg-list)))))
554 (car entry-list) (list (calendar-current-date)))) 554 (car entry-list) (list (calendar-current-date))))
555 (setq entry-list (cdr entry-list))) 555 (setq entry-list (cdr entry-list)))
556 ;; Parse the entries for today. 556 ;; Parse the entries for today.
557 (while (and entry-list 557 (while (and entry-list
558 (calendar-date-equal 558 (calendar-date-equal
559 (calendar-current-date) (car (car entry-list)))) 559 (calendar-current-date) (caar entry-list)))
560 (let ((time-string (cadr (car entry-list)))) 560 (let ((time-string (cadr (car entry-list))))
561 (while (string-match appt-time-regexp time-string) 561 (while (string-match appt-time-regexp time-string)
562 (let* ((beg (match-beginning 0)) 562 (let* ((beg (match-beginning 0))
563 ;; Get just the time for this appointment. 563 ;; Get just the time for this appointment.
564 (only-time (match-string 0 time-string)) 564 (only-time (match-string 0 time-string))
587 ;; time can be removed. 587 ;; time can be removed.
588 (let* ((now (decode-time)) 588 (let* ((now (decode-time))
589 (cur-hour (nth 2 now)) 589 (cur-hour (nth 2 now))
590 (cur-min (nth 1 now)) 590 (cur-min (nth 1 now))
591 (cur-comp-time (+ (* cur-hour 60) cur-min)) 591 (cur-comp-time (+ (* cur-hour 60) cur-min))
592 (appt-comp-time (car (caar appt-time-msg-list)))) 592 (appt-comp-time (caar (car appt-time-msg-list))))
593 593
594 (while (and appt-time-msg-list (< appt-comp-time cur-comp-time)) 594 (while (and appt-time-msg-list (< appt-comp-time cur-comp-time))
595 (setq appt-time-msg-list (cdr appt-time-msg-list)) 595 (setq appt-time-msg-list (cdr appt-time-msg-list))
596 (if appt-time-msg-list 596 (if appt-time-msg-list
597 (setq appt-comp-time (car (caar appt-time-msg-list)))))))))) 597 (setq appt-comp-time (caar (car appt-time-msg-list))))))))))
598 598
599 599
600 (defun appt-sort-list (appt-list) 600 (defun appt-sort-list (appt-list)
601 "Sort an appointment list, putting earlier items at the front. 601 "Sort an appointment list, putting earlier items at the front.
602 APPT-LIST is a list of the same format as `appt-time-msg-list'." 602 APPT-LIST is a list of the same format as `appt-time-msg-list'."