Mercurial > emacs
comparison lisp/calendar/appt.el @ 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 | c7badee38b64 |
children | 139b23d6a97b |
comparison
equal
deleted
inserted
replaced
5658:4e3a6baa4750 | 5659:32a02ab40d58 |
---|---|
102 ;;; | 102 ;;; |
103 ;;; The function appt-make-list creates the appointments list which appt-check | 103 ;;; The function appt-make-list creates the appointments list which appt-check |
104 ;;; reads. This is all done automatically. | 104 ;;; reads. This is all done automatically. |
105 ;;; It is invoked from the function list-diary-entries. | 105 ;;; It is invoked from the function list-diary-entries. |
106 ;;; | 106 ;;; |
107 ;;; You can change the way the appointment window is created/deleted by | |
108 ;;; setting the variables | |
109 ;;; | |
110 ;;; appt-disp-window-function | |
111 ;;; and | |
112 ;;; appt-delete-window-function | |
113 ;;; | |
114 ;;; For instance, these variables can be set to functions that display | |
115 ;;; appointments in pop-up frames, which are lowered or iconified after | |
116 ;;; appt-display-interval seconds. | |
117 ;;; | |
107 | 118 |
108 ;;; Code: | 119 ;;; Code: |
109 | 120 |
110 ;;;###autoload | 121 ;;;###autoload |
111 (defvar appt-issue-message t | 122 (defvar appt-issue-message t |
151 (defconst max-time 1439 | 162 (defconst max-time 1439 |
152 "11:59pm in minutes - number of minutes in a day minus 1.") | 163 "11:59pm in minutes - number of minutes in a day minus 1.") |
153 | 164 |
154 (defvar appt-display-interval 1 | 165 (defvar appt-display-interval 1 |
155 "*Number of minutes to wait between checking the appointment list.") | 166 "*Number of minutes to wait between checking the appointment list.") |
167 | |
168 (defvar appt-buffer-name " *appt-buf*" | |
169 "Name of the appointments buffer.") | |
170 | |
171 (defvar appt-disp-window-function 'appt-disp-window | |
172 "Function called to display appointment window.") | |
173 | |
174 (defvar appt-delete-window-function 'appt-delete-window | |
175 "Function called to remove appointment window and buffer.") | |
156 | 176 |
157 (defun appt-check () | 177 (defun appt-check () |
158 "Check for an appointment and update the mode line. | 178 "Check for an appointment and update the mode line. |
159 Note: the time must be the first thing in the line in the diary | 179 Note: the time must be the first thing in the line in the diary |
160 for a warning to be issued. | 180 for a warning to be issued. |
272 display-time-string) | 292 display-time-string) |
273 | 293 |
274 (setq new-time (substring display-time-string | 294 (setq new-time (substring display-time-string |
275 (match-beginning 0) | 295 (match-beginning 0) |
276 (match-end 0))) | 296 (match-end 0))) |
277 (appt-disp-window min-to-app new-time | 297 (funcall |
278 (car (cdr (car appt-time-msg-list))))) | 298 appt-disp-window-function |
299 min-to-app new-time | |
300 (car (cdr (car appt-time-msg-list)))) | |
301 | |
302 (run-at-time | |
303 (format "%d sec" appt-display-duration) | |
304 nil | |
305 appt-delete-window-function)) | |
279 ;;; else | 306 ;;; else |
280 | 307 |
281 (if appt-visible | 308 (if appt-visible |
282 (message "%s" | 309 (message "%s" |
283 (car (cdr (car appt-time-msg-list))))) | 310 (car (cdr (car appt-time-msg-list))))) |
310 | 337 |
311 | 338 |
312 ;; Display appointment message in a separate buffer. | 339 ;; Display appointment message in a separate buffer. |
313 (defun appt-disp-window (min-to-app new-time appt-msg) | 340 (defun appt-disp-window (min-to-app new-time appt-msg) |
314 (require 'electric) | 341 (require 'electric) |
315 (save-window-excursion | 342 |
316 | 343 ;; Make sure we're not in the minibuffer |
317 ;; Make sure we're not in the minibuffer | 344 ;; before splitting the window. |
318 ;; before splitting the window. | 345 |
319 | 346 (if (equal (selected-window) (minibuffer-window)) |
320 (if (= (frame-height) | 347 (if (other-window 1) |
321 (nth 3 (window-edges (selected-window)))) | 348 (select-window (other-window 1)) |
322 nil | 349 (if window-system |
323 (appt-select-lowest-window) | 350 (select-frame (other-frame 1))))) |
324 (split-window)) | 351 |
325 | 352 (let* ((this-buffer (current-buffer)) |
326 (let* ((this-buffer (current-buffer)) | 353 (this-window (selected-window)) |
327 (appt-disp-buf (set-buffer (get-buffer-create "appt-buf")))) | 354 (appt-disp-buf (set-buffer (get-buffer-create appt-buffer-name)))) |
328 (setq mode-line-format | 355 |
329 (concat "-------------------- Appointment in " | 356 (appt-select-lowest-window) |
330 min-to-app " minutes. " new-time " %-")) | 357 (split-window) |
331 (pop-to-buffer appt-disp-buf) | 358 |
332 (insert-string appt-msg) | 359 (pop-to-buffer appt-disp-buf) |
333 (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf)) | 360 (setq mode-line-format |
334 (set-buffer-modified-p nil) | 361 (concat "-------------------- Appointment in " |
335 (if appt-audible | 362 min-to-app " minutes. " new-time " %-")) |
336 (beep 1)) | 363 (insert-string appt-msg) |
337 (sit-for appt-display-duration) | 364 (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf)) |
338 (if appt-audible | 365 (set-buffer-modified-p nil) |
339 (beep 1)) | 366 (select-window this-window) |
340 (kill-buffer appt-disp-buf)))) | 367 (if appt-audible |
368 (beep 1)))) | |
369 | |
370 (defun appt-delete-window () | |
371 "Function called to undisplay appointment messages. | |
372 Usually just deletes the appointment buffer." | |
373 (delete-window (get-buffer-window appt-buffer-name)) | |
374 (kill-buffer appt-buffer-name) | |
375 (if appt-audible | |
376 (beep 1))) | |
341 | 377 |
342 ;; Select the lowest window on the frame. | 378 ;; Select the lowest window on the frame. |
343 (defun appt-select-lowest-window () | 379 (defun appt-select-lowest-window () |
344 (setq lowest-window (selected-window)) | 380 (setq lowest-window (selected-window)) |
345 (let* ((bottom-edge (car (cdr (cdr (cdr (window-edges)))))) | 381 (let* ((bottom-edge (car (cdr (cdr (cdr (window-edges)))))) |
446 (list appt-time-string)))) | 482 (list appt-time-string)))) |
447 (setq time-string new-time-string) | 483 (setq time-string new-time-string) |
448 (setq appt-time-msg-list (append appt-time-msg-list | 484 (setq appt-time-msg-list (append appt-time-msg-list |
449 (list time-msg))))))) | 485 (list time-msg))))))) |
450 (setq entry-list (cdr entry-list))))) | 486 (setq entry-list (cdr entry-list))))) |
451 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) | 487 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) |
452 | 488 |
453 ;; Get the current time and convert it to minutes | 489 ;; Get the current time and convert it to minutes |
454 ;; from midnight. ie. 12:01am = 1, midnight = 0, | 490 ;; from midnight. ie. 12:01am = 1, midnight = 0, |
455 ;; so that the elements in the list | 491 ;; so that the elements in the list |
456 ;; that are earlier than the present time can | 492 ;; that are earlier than the present time can |
457 ;; be removed. | 493 ;; be removed. |
458 | 494 |
459 (let* ((cur-hour(string-to-int | 495 (let* ((cur-hour(string-to-int |
460 (substring (current-time-string) 11 13))) | 496 (substring (current-time-string) 11 13))) |
461 (cur-min (string-to-int | 497 (cur-min (string-to-int |
462 (substring (current-time-string) 14 16))) | 498 (substring (current-time-string) 14 16))) |
463 (cur-comp-time (+ (* cur-hour 60) cur-min)) | 499 (cur-comp-time (+ (* cur-hour 60) cur-min)) |
464 (appt-comp-time (car (car (car appt-time-msg-list))))) | 500 (appt-comp-time (car (car (car appt-time-msg-list))))) |
465 | 501 |
466 (while (and appt-time-msg-list (< appt-comp-time cur-comp-time)) | 502 (while (and appt-time-msg-list (< appt-comp-time cur-comp-time)) |
467 (setq appt-time-msg-list (cdr appt-time-msg-list)) | 503 (setq appt-time-msg-list (cdr appt-time-msg-list)) |
468 (if appt-time-msg-list | 504 (if appt-time-msg-list |
469 (setq appt-comp-time (car (car (car appt-time-msg-list))))))))) | 505 (setq appt-comp-time (car (car (car appt-time-msg-list))))))))) |
470 | 506 |
471 | 507 |
472 ;;Simple sort to put the appointments list in order. | 508 ;;Simple sort to put the appointments list in order. |
473 ;;Scan the list for the smallest element left in the list. | 509 ;;Scan the list for the smallest element left in the list. |
474 ;;Append the smallest element left into the new list, and remove | 510 ;;Append the smallest element left into the new list, and remove |
523 conv-time)) | 559 conv-time)) |
524 | 560 |
525 (setq display-time-hook 'appt-check) | 561 (setq display-time-hook 'appt-check) |
526 | 562 |
527 ;;; appt.el ends here | 563 ;;; appt.el ends here |
564 |