[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/calendar/appt.el,v
From: |
Glenn Morris |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/calendar/appt.el,v |
Date: |
Wed, 02 Apr 2008 03:49:51 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Glenn Morris <gm> 08/04/02 03:49:50
Index: appt.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/calendar/appt.el,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- appt.el 26 Mar 2008 03:42:56 -0000 1.85
+++ appt.el 2 Apr 2008 03:49:50 -0000 1.86
@@ -165,7 +165,9 @@
(defcustom appt-disp-window-function 'appt-disp-window
"Function called to display appointment window.
-Only relevant if reminders are being displayed in a window."
+Only relevant if reminders are being displayed in a window.
+It should take three string arguments: the number of minutes till
+the appointment, the current time, and the text of the appointment."
:type '(choice (const appt-disp-window)
function)
:group 'appt)
@@ -232,6 +234,7 @@
(cond (appt-msg-window 'window)
(appt-visible 'echo))
appt-display-format)))
+ (if appt-audible (beep 1))
(cond ((eq appt-display-format 'window)
(funcall appt-disp-window-function
(number-to-string mins)
@@ -242,8 +245,7 @@
nil
appt-delete-window-function))
((eq appt-display-format 'echo)
- (message "%s" string)))
- (if appt-audible (beep 1))))
+ (message "%s" string)))))
(defvar diary-selective-display)
@@ -300,6 +302,7 @@
`appt-delete-window-function'
Function called to remove appointment window and buffer."
+ (interactive "P") ; so people can force updates
(let* ((min-to-app -1)
(prev-appt-mode-string appt-mode-string)
(prev-appt-display-count (or appt-display-count 0))
@@ -311,18 +314,14 @@
;; 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
- (and (not full-check) appt-now-displayed)))
+ (mode-line-only (unless full-check appt-now-displayed))
+ now cur-comp-time appt-comp-time)
(when (or full-check mode-line-only)
(save-excursion
- ;; Get the current time and convert it to minutes
- ;; from midnight, i.e.: 12:01am = 1, midnight = 0.
- (let* ((now (decode-time))
- (cur-hour (nth 2 now))
- (cur-min (nth 1 now))
- (cur-comp-time (+ (* cur-hour 60) cur-min)))
- ;; At the first check in any given day, update our
- ;; appointments to today's list.
+ ;; 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
@@ -346,8 +345,7 @@
(if d-buff
;; Displays the diary buffer.
(or selective (diary-show-all-entries))
- (and
- (setq d-buff (find-buffer-visiting
+ (and (setq d-buff (find-buffer-visiting
(substitute-in-file-name diary-file)))
(kill-buffer d-buff)))))
(error nil)))
@@ -357,24 +355,22 @@
;; 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.
- (if (and appt-issue-message appt-time-msg-list)
- (let ((appt-comp-time (caar (car appt-time-msg-list))))
- (setq min-to-app (- appt-comp-time cur-comp-time))
-
+ (when (and appt-issue-message appt-time-msg-list)
+ (setq appt-comp-time (caar (car appt-time-msg-list))
+ min-to-app (- appt-comp-time cur-comp-time))
(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)))))
+ (setq appt-comp-time (caar (car appt-time-msg-list)))))
;; If we have an appointment between midnight and
- ;; `appt-message-warning-time' minutes after midnight,
- ;; we must begin to issue a message before midnight.
- ;; Midnight is considered 0 minutes and 11:59pm is
- ;; 1439 minutes. Therefore we must recalculate the
- ;; minutes to appointment variable. It is equal to the
- ;; number of minutes before midnight plus the number
- ;; of minutes after midnight our appointment is.
+ ;; `appt-message-warning-time' minutes after midnight, we
+ ;; must begin to issue a message before midnight. Midnight
+ ;; is considered 0 minutes and 11:59pm is 1439
+ ;; minutes. Therefore we must recalculate the minutes to
+ ;; appointment variable. It is equal to the number of
+ ;; minutes before midnight plus the number of minutes after
+ ;; midnight our appointment is.
(if (and (< appt-comp-time appt-message-warning-time)
(> (+ cur-comp-time appt-message-warning-time)
appt-max-time))
@@ -394,23 +390,21 @@
(concat " " (propertize
(format "App't in %s min." min-to-app)
'face 'mode-line-emphasis))))
- ;; When an appointment is reached, delete it from
- ;; the list. Reset the count to 0 in case we
- ;; display another appointment on the next cycle.
+ ;; When an appointment is reached, delete it from the
+ ;; list. Reset the count to 0 in case we display another
+ ;; appointment on the next cycle.
(if (zerop min-to-app)
(setq appt-time-msg-list (cdr appt-time-msg-list)
- appt-display-count nil)))))
- ;; If we have changed the mode line string, redisplay all
- ;; mode lines.
+ appt-display-count nil))))
+ ;; If we have changed the mode line string, redisplay all mode lines.
(and appt-display-mode-line
- (not (equal appt-mode-string
+ (not (string-equal appt-mode-string
prev-appt-mode-string))
(progn
(force-mode-line-update t)
- ;; If the string now has a notification, redisplay
- ;; right now.
+ ;; If the string now has a notification, redisplay right now.
(if appt-mode-string
- (sit-for 0)))))))))
+ (sit-for 0))))))))
(defun appt-disp-window (min-to-app new-time appt-msg)
"Display appointment due in MIN-TO-APP (a string) minutes.
@@ -434,13 +428,20 @@
(when (>= (window-height) (* 2 window-min-height))
(select-window (split-window))))
(switch-to-buffer appt-disp-buf))
+ ;; FIXME Link to diary entry?
(calendar-set-mode-line
- (format " Appointment in %s minutes. %s " min-to-app new-time))
- (buffer-disable-undo)
+ (format " Appointment %s. %s "
+ (if (string-equal "0" min-to-app) "now"
+ (format "in %s minute%s" min-to-app
+ (if (string-equal "1" min-to-app) "" "s")))
+ new-time))
+ (setq buffer-read-only nil
+ buffer-undo-list t)
(erase-buffer)
(insert appt-msg)
(shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf t))
(set-buffer-modified-p nil)
+ (setq buffer-read-only t)
(raise-frame (selected-frame))
(select-window this-window)))
@@ -458,12 +459,13 @@
(defun appt-select-lowest-window ()
"Select the lowest window on the frame."
(let ((lowest-window (selected-window))
- (bottom-edge (nth 3 (window-edges))))
+ (bottom-edge (nth 3 (window-edges)))
+ next-bottom-edge)
(walk-windows (lambda (w)
- (let ((next-bottom-edge (nth 3 (window-edges w))))
- (when (< bottom-edge next-bottom-edge)
+ (when (< bottom-edge (setq next-bottom-edge
+ (nth 3 (window-edges w))))
(setq bottom-edge next-bottom-edge
- lowest-window w)))) 'nomini)
+ lowest-window w))) 'nomini)
(select-window lowest-window)))
(defconst appt-time-regexp
@@ -487,22 +489,16 @@
"Delete an appointment from the list of appointments."
(interactive)
(let ((tmp-msg-list appt-time-msg-list))
- (while tmp-msg-list
- (let* ((element (car tmp-msg-list))
- (prompt-string (concat "Delete "
- ;; We want to quote any doublequotes
- ;; in the string, as well as put
- ;; doublequotes around it.
+ (dolist (element tmp-msg-list)
+ (if (y-or-n-p (concat "Delete "
+ ;; We want to quote any doublequotes in the
+ ;; string, as well as put doublequotes around it.
(prin1-to-string
- (substring-no-properties
- (cadr element) 0))
+ (substring-no-properties (cadr element) 0))
" from list? "))
- (test-input (y-or-n-p prompt-string)))
- (setq tmp-msg-list (cdr tmp-msg-list))
- (if test-input
(setq appt-time-msg-list (delq element appt-time-msg-list)))))
(appt-check)
- (message "")))
+ (message ""))
(defvar number)
@@ -517,8 +513,7 @@
NUMBER hold the arguments that `diary-list-entries' received.
They specify the range of dates that the diary is being processed for.
-Any appointments made with `appt-add' are not affected by this
-function.
+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)."
@@ -548,7 +543,8 @@
;; 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 ""))
+ (new-time-string "")
+ time-string)
;; Skip diary entries for dates before today.
(while (and entry-list
(calendar-date-compare
@@ -558,7 +554,7 @@
(while (and entry-list
(calendar-date-equal
(calendar-current-date) (caar entry-list)))
- (let ((time-string (cadr (car 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.
@@ -571,27 +567,23 @@
(match-end 0)))
;; Get the whole string for this appointment.
(appt-time-string
- (substring time-string beg (if end (1- end)))))
- ;; Add this appointment to appt-time-msg-list.
- (let* ((appt-time (list (appt-convert-time only-time)))
+ (substring time-string beg (if end (1- 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))))
+ (nconc appt-time-msg-list (list time-msg))
;; Discard this appointment from the string.
- (setq time-string
- (if end (substring time-string end) "")))))
+ 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))
- ;; Get the current time and convert it to minutes from
- ;; midnight, i.e. 12:01am = 1, midnight = 0, so that the
- ;; elements in the list that are earlier than the present
- ;; time can be removed.
+ ;; 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-hour (nth 2 now))
- (cur-min (nth 1 now))
- (cur-comp-time (+ (* cur-hour 60) cur-min))
+ (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
- [Emacs-diffs] Changes to emacs/lisp/calendar/appt.el,v,
Glenn Morris <=