changeset 5659:32a02ab40d58

(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.
author Richard M. Stallman <rms@gnu.org>
date Fri, 21 Jan 1994 21:21:20 +0000
parents 4e3a6baa4750
children 0951c61a12f8
files lisp/calendar/appt.el
diffstat 1 files changed, 78 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/appt.el	Fri Jan 21 20:54:57 1994 +0000
+++ b/lisp/calendar/appt.el	Fri Jan 21 21:21:20 1994 +0000
@@ -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 @@
 
 (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 @@
 			      (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 @@
 ;; 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 @@
                     (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 @@
 (setq display-time-hook 'appt-check)
 
 ;;; appt.el ends here
+