comparison lisp/calendar/appt.el @ 93532:54d9e787a82a

Whitespace only.
author Glenn Morris <rgm@gnu.org>
date Wed, 02 Apr 2008 03:51:47 +0000
parents 4fa95a348719
children a90650368da6
comparison
equal deleted inserted replaced
93531:147bcd5007bf 93532:54d9e787a82a
62 ;; `appt-check' reads. 62 ;; `appt-check' reads.
63 ;; 63 ;;
64 ;; You can change the way the appointment window is created/deleted by 64 ;; You can change the way the appointment window is created/deleted by
65 ;; setting the variables 65 ;; setting the variables
66 ;; 66 ;;
67 ;; appt-disp-window-function 67 ;; appt-disp-window-function
68 ;; and 68 ;; and
69 ;; appt-delete-window-function 69 ;; appt-delete-window-function
70 ;; 70 ;;
71 ;; For instance, these variables could be set to functions that display 71 ;; For instance, these variables could be set to functions that display
72 ;; appointments in pop-up frames, which are lowered or iconified after 72 ;; appointments in pop-up frames, which are lowered or iconified after
73 ;; `appt-display-interval' minutes. 73 ;; `appt-display-interval' minutes.
74 ;; 74 ;;
229 The variable `appt-audible' controls the audible reminder." 229 The variable `appt-audible' controls the audible reminder."
230 ;; Let-binding for backwards compatability. Remove when obsolete 230 ;; Let-binding for backwards compatability. Remove when obsolete
231 ;; vars appt-msg-window and appt-visible are dropped. 231 ;; vars appt-msg-window and appt-visible are dropped.
232 (let ((appt-display-format 232 (let ((appt-display-format
233 (if (eq appt-display-format 'ignore) 233 (if (eq appt-display-format 'ignore)
234 (cond (appt-msg-window 'window) 234 (cond (appt-msg-window 'window)
235 (appt-visible 'echo)) 235 (appt-visible 'echo))
236 appt-display-format))) 236 appt-display-format)))
237 (if appt-audible (beep 1)) 237 (if appt-audible (beep 1))
238 (cond ((eq appt-display-format 'window) 238 (cond ((eq appt-display-format 'window)
239 (funcall appt-disp-window-function 239 (funcall appt-disp-window-function
240 (number-to-string mins) 240 (number-to-string mins)
271 271
272 `appt-display-format' 272 `appt-display-format'
273 Controls the format in which reminders are displayed. 273 Controls the format in which reminders are displayed.
274 274
275 `appt-audible' 275 `appt-audible'
276 Variable used to determine if reminder is audible. 276 Variable used to determine if reminder is audible.
277 Default is t. 277 Default is t.
278 278
279 `appt-message-warning-time' 279 `appt-message-warning-time'
280 Variable used to determine when appointment message 280 Variable used to determine when appointment message
281 should first be displayed. 281 should first be displayed.
282 282
283 `appt-display-mode-line' 283 `appt-display-mode-line'
284 If non-nil, a generic message giving the time remaining 284 If non-nil, a generic message giving the time remaining
285 is shown in the mode-line when an appointment is due. 285 is shown in the mode-line when an appointment is due.
286 286
293 293
294 The following variables are only relevant if reminders are being 294 The following variables are only relevant if reminders are being
295 displayed in a window: 295 displayed in a window:
296 296
297 `appt-display-duration' 297 `appt-display-duration'
298 The number of seconds an appointment message is displayed. 298 The number of seconds an appointment message is displayed.
299 299
300 `appt-disp-window-function' 300 `appt-disp-window-function'
301 Function called to display appointment window. 301 Function called to display appointment window.
302 302
303 `appt-delete-window-function' 303 `appt-delete-window-function'
304 Function called to remove appointment window and buffer." 304 Function called to remove appointment window and buffer."
305 (interactive "P") ; so people can force updates 305 (interactive "P") ; so people can force updates
306 (let* ((min-to-app -1) 306 (let* ((min-to-app -1)
307 (prev-appt-mode-string appt-mode-string) 307 (prev-appt-mode-string appt-mode-string)
308 (prev-appt-display-count (or appt-display-count 0)) 308 (prev-appt-display-count (or appt-display-count 0))
309 ;; Non-nil means do a full check for pending appointments and 309 ;; Non-nil means do a full check for pending appointments and
310 ;; display in whatever ways the user has selected. When no 310 ;; display in whatever ways the user has selected. When no
311 ;; appointment is being displayed, we always do a full check. 311 ;; appointment is being displayed, we always do a full check.
312 (full-check 312 (full-check
313 (or (not appt-now-displayed) 313 (or (not appt-now-displayed)
314 ;; This is true every appt-display-interval minutes. 314 ;; This is true every appt-display-interval minutes.
315 (zerop (mod prev-appt-display-count appt-display-interval)))) 315 (zerop (mod prev-appt-display-count appt-display-interval))))
316 ;; Non-nil means only update the interval displayed in the mode line. 316 ;; Non-nil means only update the interval displayed in the mode line.
317 (mode-line-only (unless full-check appt-now-displayed)) 317 (mode-line-only (unless full-check appt-now-displayed))
318 now cur-comp-time appt-comp-time) 318 now cur-comp-time appt-comp-time)
319 (when (or full-check mode-line-only) 319 (when (or full-check mode-line-only)
320 (save-excursion 320 (save-excursion
321 ;; Convert current time to minutes after midnight (12.01am = 1). 321 ;; Convert current time to minutes after midnight (12.01am = 1).
322 (setq now (decode-time) 322 (setq now (decode-time)
323 cur-comp-time (+ (* 60 (nth 2 now)) (nth 1 now))) 323 cur-comp-time (+ (* 60 (nth 2 now)) (nth 1 now)))
324 ;; At first check in any day, update appointments to today's list. 324 ;; At first check in any day, update appointments to today's list.
325 (if (or force ; eg initialize, diary save 325 (if (or force ; eg initialize, diary save
326 (null appt-prev-comp-time) ; first check 326 (null appt-prev-comp-time) ; first check
327 (< cur-comp-time appt-prev-comp-time)) ; new day 327 (< cur-comp-time appt-prev-comp-time)) ; new day
416 (other-window 1) 416 (other-window 1)
417 (and (minibufferp) (display-multi-frame-p) (other-frame 1))) 417 (and (minibufferp) (display-multi-frame-p) (other-frame 1)))
418 (let ((this-window (selected-window)) 418 (let ((this-window (selected-window))
419 (appt-disp-buf (set-buffer (get-buffer-create appt-buffer-name)))) 419 (appt-disp-buf (set-buffer (get-buffer-create appt-buffer-name))))
420 (if (cdr (assq 'unsplittable (frame-parameters))) 420 (if (cdr (assq 'unsplittable (frame-parameters)))
421 ;; In an unsplittable frame, use something somewhere else. 421 ;; In an unsplittable frame, use something somewhere else.
422 (display-buffer appt-disp-buf) 422 (display-buffer appt-disp-buf)
423 (unless (or (special-display-p (buffer-name appt-disp-buf)) 423 (unless (or (special-display-p (buffer-name appt-disp-buf))
424 (same-window-p (buffer-name appt-disp-buf))) 424 (same-window-p (buffer-name appt-disp-buf)))
425 ;; By default, split the bottom window and use the lower part. 425 ;; By default, split the bottom window and use the lower part.
426 (appt-select-lowest-window) 426 (appt-select-lowest-window)
427 ;; Split the window, unless it's too small to do so. 427 ;; Split the window, unless it's too small to do so.
428 (when (>= (window-height) (* 2 window-min-height)) 428 (when (>= (window-height) (* 2 window-min-height))
429 (select-window (split-window)))) 429 (select-window (split-window))))
430 (switch-to-buffer appt-disp-buf)) 430 (switch-to-buffer appt-disp-buf))
431 ;; FIXME Link to diary entry? 431 ;; FIXME Link to diary entry?
448 (defun appt-delete-window () 448 (defun appt-delete-window ()
449 "Function called to undisplay appointment messages. 449 "Function called to undisplay appointment messages.
450 Usually just deletes the appointment buffer." 450 Usually just deletes the appointment buffer."
451 (let ((window (get-buffer-window appt-buffer-name t))) 451 (let ((window (get-buffer-window appt-buffer-name t)))
452 (and window 452 (and window
453 (or (eq window (frame-root-window (window-frame window))) 453 (or (eq window (frame-root-window (window-frame window)))
454 (delete-window window)))) 454 (delete-window window))))
455 (kill-buffer appt-buffer-name) 455 (kill-buffer appt-buffer-name)
456 (if appt-audible 456 (if appt-audible
457 (beep 1))) 457 (beep 1)))
458 458
459 (defun appt-select-lowest-window () 459 (defun appt-select-lowest-window ()
460 "Select the lowest window on the frame." 460 "Select the lowest window on the frame."
461 (let ((lowest-window (selected-window)) 461 (let ((lowest-window (selected-window))
462 (bottom-edge (nth 3 (window-edges))) 462 (bottom-edge (nth 3 (window-edges)))
463 next-bottom-edge) 463 next-bottom-edge)
464 (walk-windows (lambda (w) 464 (walk-windows (lambda (w)
465 (when (< bottom-edge (setq next-bottom-edge 465 (when (< bottom-edge (setq next-bottom-edge
466 (nth 3 (window-edges w)))) 466 (nth 3 (window-edges w))))
467 (setq bottom-edge next-bottom-edge 467 (setq bottom-edge next-bottom-edge
468 lowest-window w))) 'nomini) 468 lowest-window w))) 'nomini)
469 (select-window lowest-window))) 469 (select-window lowest-window)))
470 470
471 (defconst appt-time-regexp 471 (defconst appt-time-regexp
472 "[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?") 472 "[0-9]?[0-9]\\(h\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]\\)\\(am\\|pm\\)?")
473 473
608 (hr (if (string-match "[0-9]*[0-9]" time2conv) 608 (hr (if (string-match "[0-9]*[0-9]" time2conv)
609 (string-to-number (match-string 0 time2conv)) 609 (string-to-number (match-string 0 time2conv))
610 0))) 610 0)))
611 ;; Convert the time appointment time into 24 hour time. 611 ;; Convert the time appointment time into 24 hour time.
612 (cond ((and (string-match "pm" time2conv) (< hr 12)) 612 (cond ((and (string-match "pm" time2conv) (< hr 12))
613 (setq hr (+ 12 hr))) 613 (setq hr (+ 12 hr)))
614 ((and (string-match "am" time2conv) (= hr 12)) 614 ((and (string-match "am" time2conv) (= hr 12))
615 (setq hr 0))) 615 (setq hr 0)))
616 ;; Convert the actual time into minutes. 616 ;; Convert the actual time into minutes.
617 (+ (* hr 60) min))) 617 (+ (* hr 60) min)))
618 618
619 (defun appt-update-list () 619 (defun appt-update-list ()
649 ;; The new method is just to use (appt-activate 1). 649 ;; The new method is just to use (appt-activate 1).
650 ;; -- gmorris 650 ;; -- gmorris
651 651
652 ;;;###autoload 652 ;;;###autoload
653 (defun appt-activate (&optional arg) 653 (defun appt-activate (&optional arg)
654 "Toggle checking of appointments. 654 "Toggle checking of appointments.
655 With optional numeric argument ARG, turn appointment checking on if 655 With optional numeric argument ARG, turn appointment checking on if
656 ARG is positive, otherwise off." 656 ARG is positive, otherwise off."
657 (interactive "P") 657 (interactive "P")
658 (let ((appt-active appt-timer)) 658 (let ((appt-active appt-timer))
659 (setq appt-active (if arg (> (prefix-numeric-value arg) 0) 659 (setq appt-active (if arg (> (prefix-numeric-value arg) 0)