1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-29 07:58:28 +00:00

(appt-check): Use the new variables

appt-disp-window-function and appt-delete-window-function.
(appt-disp-window-function): New variable.
(appt-delete-window-function): New variable.
(appt-delete-window): New function.
(appt-disp-window): Don't delete the appt window here;
instead, call appt-delete-window-function.
Fixed bug that messed up the screen when appt-check ran
when mouse is in the minibuffer.
Call select-frame only if window-system.
This commit is contained in:
Richard M. Stallman 1994-01-21 21:21:20 +00:00
parent 76412d64d2
commit 5b5861558c

View File

@ -104,6 +104,17 @@
;;; reads. This is all done automatically.
;;; It is invoked from the function list-diary-entries.
;;;
;;; You can change the way the appointment window is created/deleted by
;;; setting the variables
;;;
;;; appt-disp-window-function
;;; and
;;; appt-delete-window-function
;;;
;;; For instance, these variables can be set to functions that display
;;; appointments in pop-up frames, which are lowered or iconified after
;;; appt-display-interval seconds.
;;;
;;; Code:
@ -153,6 +164,15 @@ The number before each time/message is the time in minutes from midnight.")
(defvar appt-display-interval 1
"*Number of minutes to wait between checking the appointment list.")
(defvar appt-buffer-name " *appt-buf*"
"Name of the appointments buffer.")
(defvar appt-disp-window-function 'appt-disp-window
"Function called to display appointment window.")
(defvar appt-delete-window-function 'appt-delete-window
"Function called to remove appointment window and buffer.")
(defun appt-check ()
"Check for an appointment and update the mode line.
@ -274,8 +294,15 @@ Therefore, you need to have `(display-time)' in your .emacs file."
(setq new-time (substring display-time-string
(match-beginning 0)
(match-end 0)))
(appt-disp-window min-to-app new-time
(car (cdr (car appt-time-msg-list)))))
(funcall
appt-disp-window-function
min-to-app new-time
(car (cdr (car appt-time-msg-list))))
(run-at-time
(format "%d sec" appt-display-duration)
nil
appt-delete-window-function))
;;; else
(if appt-visible
@ -312,32 +339,41 @@ Therefore, you need to have `(display-time)' in your .emacs file."
;; Display appointment message in a separate buffer.
(defun appt-disp-window (min-to-app new-time appt-msg)
(require 'electric)
(save-window-excursion
;; Make sure we're not in the minibuffer
;; before splitting the window.
;; Make sure we're not in the minibuffer
;; before splitting the window.
(if (= (frame-height)
(nth 3 (window-edges (selected-window))))
nil
(appt-select-lowest-window)
(split-window))
(if (equal (selected-window) (minibuffer-window))
(if (other-window 1)
(select-window (other-window 1))
(if window-system
(select-frame (other-frame 1)))))
(let* ((this-buffer (current-buffer))
(this-window (selected-window))
(appt-disp-buf (set-buffer (get-buffer-create appt-buffer-name))))
(let* ((this-buffer (current-buffer))
(appt-disp-buf (set-buffer (get-buffer-create "appt-buf"))))
(setq mode-line-format
(concat "-------------------- Appointment in "
min-to-app " minutes. " new-time " %-"))
(pop-to-buffer appt-disp-buf)
(insert-string appt-msg)
(shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf))
(set-buffer-modified-p nil)
(if appt-audible
(beep 1))
(sit-for appt-display-duration)
(if appt-audible
(beep 1))
(kill-buffer appt-disp-buf))))
(appt-select-lowest-window)
(split-window)
(pop-to-buffer appt-disp-buf)
(setq mode-line-format
(concat "-------------------- Appointment in "
min-to-app " minutes. " new-time " %-"))
(insert-string appt-msg)
(shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf))
(set-buffer-modified-p nil)
(select-window this-window)
(if appt-audible
(beep 1))))
(defun appt-delete-window ()
"Function called to undisplay appointment messages.
Usually just deletes the appointment buffer."
(delete-window (get-buffer-window appt-buffer-name))
(kill-buffer appt-buffer-name)
(if appt-audible
(beep 1)))
;; Select the lowest window on the frame.
(defun appt-select-lowest-window ()
@ -448,25 +484,25 @@ The time should be in either 24 hour format or am/pm format."
(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))
(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.
;; 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)))))
(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)))))))))
(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.
@ -525,3 +561,4 @@ The time should be in either 24 hour format or am/pm format."
(setq display-time-hook 'appt-check)
;;; appt.el ends here