aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-08-26 21:14:25 +0000
committerRichard M. Stallman1998-08-26 21:14:25 +0000
commitefa434d9f2720aa71fbc67fed5897a2f16943fde (patch)
treec5b2da348abdb9fd99b9b29c13f2418fd32d8622
parentb775a47213c2e7e800f93cd663c2accfdf0f8373 (diff)
downloademacs-efa434d9f2720aa71fbc67fed5897a2f16943fde.tar.gz
emacs-efa434d9f2720aa71fbc67fed5897a2f16943fde.zip
(appt-mode-string): New variable.
(global-mode-string): Add appt-mode-string to it. (appt-check): Avoid using display-time-string to fetch current time. To display in mode line, use appt-mode-string.
-rw-r--r--lisp/calendar/appt.el143
1 files changed, 71 insertions, 72 deletions
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index 5df330fd977..0a21ee9a382 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -44,8 +44,7 @@
44;;; pending appointment based on their diary file. 44;;; pending appointment based on their diary file.
45;;; 45;;;
46;;; 46;;;
47;;; ******* It is necessary to invoke 'display-time' ******** 47;;; ******* It is necessary to invoke 'diary' for this to work properly. ****
48;;; ******* and 'diary' for this to work properly. ********
49;;; 48;;;
50;;; A message will be displayed in the mode line of the emacs buffer 49;;; A message will be displayed in the mode line of the emacs buffer
51;;; and (if the user desires) the terminal will beep and display a message 50;;; and (if the user desires) the terminal will beep and display a message
@@ -60,14 +59,16 @@
60;;; In order to use, the following should be in your .emacs file in addition to 59;;; In order to use, the following should be in your .emacs file in addition to
61;;; creating a diary file and invoking calendar: 60;;; creating a diary file and invoking calendar:
62;;; 61;;;
63;;; Set some options 62;;; To enable appointment reminders, the following lines are required:
64;;; (setq view-diary-entries-initially t) 63;;; (add-hook 'diary-hook 'appt-make-list)
65;;; (setq appt-issue-message t) 64;;; (let ((diary-display-hook 'ignore))
66;;; 65;;; (diary))
67;;; The following three lines are required: 66;;; You can replace the last two with just (diary)
68;;; (display-time) 67;;; if you want to display the diary as well.
69;;; (add-hook 'diary-hook 'appt-make-list)
70;;; 68;;;
69;;; Before that, you can also set some options if you want
70;;; (setq view-diary-entries-initially t)
71;;; (setq appt-issue-message t)
71;;; 72;;;
72;;; This is an example of what can be in your diary file: 73;;; This is an example of what can be in your diary file:
73;;; Monday 74;;; Monday
@@ -173,6 +174,12 @@ This will occur at midnight when the appointment list is updated."
173 :type 'boolean 174 :type 'boolean
174 :group 'appt) 175 :group 'appt)
175 176
177(defcustom appt-interval 60
178 "*Interval in seconds between checking for appointments."
179 :type 'integer
180 :group 'appt
181 :version "20.3")
182
176(defvar appt-time-msg-list nil 183(defvar appt-time-msg-list nil
177 "The list of appointments for today. 184 "The list of appointments for today.
178Use `appt-add' and `appt-delete' to add and delete appointments from list. 185Use `appt-add' and `appt-delete' to add and delete appointments from list.
@@ -196,6 +203,9 @@ The number before each time/message is the time in minutes from midnight.")
196(defvar appt-delete-window-function 'appt-delete-window 203(defvar appt-delete-window-function 'appt-delete-window
197 "Function called to remove appointment window and buffer.") 204 "Function called to remove appointment window and buffer.")
198 205
206(defvar appt-mode-string nil
207 "String to display in the mode line for an appointment.")
208
199(defun appt-check () 209(defun appt-check ()
200 "Check for an appointment and update the mode line. 210 "Check for an appointment and update the mode line.
201Note: the time must be the first thing in the line in the diary 211Note: the time must be the first thing in the line in the diary
@@ -212,46 +222,43 @@ Example:
212 222
213The following variables control the action of the notification: 223The following variables control the action of the notification:
214 224
215appt-issue-message 225`appt-issue-message'
216 If T, the diary buffer is checked for appointments. 226 If t, the diary buffer is checked for appointments.
217 227
218appt-message-warning-time 228`appt-message-warning-time'
219 Variable used to determine if appointment message 229 Variable used to determine if appointment message
220 should be displayed. 230 should be displayed.
221 231
222appt-audible 232`appt-audible'
223 Variable used to determine if appointment is audible. 233 Variable used to determine if appointment is audible.
224 Default is t. 234 Default is t.
225 235
226appt-visible 236`appt-visible'
227 Variable used to determine if appointment message should be 237 Variable used to determine if appointment message should be
228 displayed in the mini-buffer. Default is t. 238 displayed in the mini-buffer. Default is t.
229 239
230appt-msg-window 240`appt-msg-window'
231 Variable used to determine if appointment message 241 Variable used to determine if appointment message
232 should temporarily appear in another window. Mutually exclusive 242 should temporarily appear in another window. Mutually exclusive
233 to appt-visible. 243 to `appt-visible'.
234 244
235appt-display-duration 245`appt-display-duration'
236 The number of seconds an appointment message 246 The number of seconds an appointment message
237 is displayed in another window. 247 is displayed in another window.
238 248
239appt-display-interval 249`appt-display-interval'
240 The number of minutes to wait between checking the appointments 250 The number of minutes to wait between checking the appointments
241 list. 251 list.
242 252
243appt-disp-window-function 253`appt-disp-window-function '
244 Function called to display appointment window. You can customize 254 Function called to display appointment window. You can customize
245 appt.el by setting this variable to a function different from the 255 appt.el by setting this variable to a function different from the
246 one provided with this package. 256 one provided with this package.
247 257
248appt-delete-window-function 258`appt-delete-window-function '
249 Function called to remove appointment window and buffer. You can 259 Function called to remove appointment window and buffer. You can
250 customize appt.el by setting this variable to a function different 260 customize appt.el by setting this variable to a function different
251 from the one provided with this package. 261 from the one provided with this package."
252
253This function is run from the loadst process for display time.
254Therefore, you need to have `(display-time)' in your .emacs file."
255 262
256 263
257 (if (or (= appt-display-interval 1) 264 (if (or (= appt-display-interval 1)
@@ -314,55 +321,39 @@ Therefore, you need to have `(display-time)' in your .emacs file."
314 ;; issue warning if the appointment time is 321 ;; issue warning if the appointment time is
315 ;; within appt-message-warning time 322 ;; within appt-message-warning time
316 323
317 (if (and (<= min-to-app appt-message-warning-time) 324 (when (and (<= min-to-app appt-message-warning-time)
318 (>= min-to-app 0)) 325 (>= min-to-app 0))
319 (progn 326 (if appt-msg-window
320 (if appt-msg-window 327 (progn
321 (progn 328 (setq new-time (format-time-string "%a %b %e "
322 (string-match 329 (current-time)))
323 "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" 330 (funcall
324 display-time-string) 331 appt-disp-window-function
325 332 min-to-app new-time
326 (setq new-time (substring display-time-string 333 (car (cdr (car appt-time-msg-list))))
327 (match-beginning 0)
328 (match-end 0)))
329 (funcall
330 appt-disp-window-function
331 min-to-app new-time
332 (car (cdr (car appt-time-msg-list))))
333 334
334 (run-at-time 335 (run-at-time
335 (format "%d sec" appt-display-duration) 336 (format "%d sec" appt-display-duration)
336 nil 337 nil
337 appt-delete-window-function)) 338 appt-delete-window-function))
338 ;;; else 339 ;;; else
339 340
340 (if appt-visible 341 (if appt-visible
341 (message "%s" 342 (message "%s"
342 (car (cdr (car appt-time-msg-list))))) 343 (car (cdr (car appt-time-msg-list)))))
343 344
344 (if appt-audible 345 (if appt-audible
345 (beep 1))) 346 (beep 1)))
346 347
347 (if appt-display-mode-line 348 (when appt-display-mode-line
348 (progn 349 (setq appt-mode-string
349 (string-match 350 (concat "App't in " min-to-app " min. "))
350 "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" 351 (force-mode-line-update t)
351 display-time-string) 352 (sit-for 0))
352 353
353 (setq new-time (substring display-time-string 354 (if (= min-to-app 0)
354 (match-beginning 0) 355 (setq appt-time-msg-list
355 (match-end 0))) 356 (cdr appt-time-msg-list)))))))))))
356 (setq display-time-string
357 (concat "App't in "
358 min-to-app " min. " new-time " "))
359
360 (force-mode-line-update t)
361 (sit-for 0)))
362
363 (if (= min-to-app 0)
364 (setq appt-time-msg-list
365 (cdr appt-time-msg-list))))))))))))
366 357
367 358
368;; Display appointment message in a separate buffer. 359;; Display appointment message in a separate buffer.
@@ -392,6 +383,7 @@ Therefore, you need to have `(display-time)' in your .emacs file."
392 (setq mode-line-format 383 (setq mode-line-format
393 (concat "-------------------- Appointment in " 384 (concat "-------------------- Appointment in "
394 min-to-app " minutes. " new-time " %-")) 385 min-to-app " minutes. " new-time " %-"))
386 (erase-buffer)
395 (insert-string appt-msg) 387 (insert-string appt-msg)
396 (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf t)) 388 (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf t))
397 (set-buffer-modified-p nil) 389 (set-buffer-modified-p nil)
@@ -612,7 +604,14 @@ The time should be in either 24 hour format or am/pm format."
612 (setq conv-time (+ (* hr 60) min)) 604 (setq conv-time (+ (* hr 60) min))
613 conv-time)) 605 conv-time))
614 606
615(add-hook 'display-time-hook 'appt-check) 607(defvar appt-timer nil
608 "Timer used for diary appointment notifications (`appt-check').")
616 609
617;;; appt.el ends here 610(setq appt-timer (run-at-time t appt-interval 'appt-check))
611
612(or global-mode-string (setq global-mode-string '("")))
613(or (memq 'appt-mode-string global-mode-string)
614 (setq global-mode-string
615 (append global-mode-string '(appt-mode-string))))
618 616
617;;; appt.el ends here