Commit efa434d9 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(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.
parent b775a472
...@@ -44,8 +44,7 @@ ...@@ -44,8 +44,7 @@
;;; pending appointment based on their diary file. ;;; pending appointment based on their diary file.
;;; ;;;
;;; ;;;
;;; ******* It is necessary to invoke 'display-time' ******** ;;; ******* It is necessary to invoke 'diary' for this to work properly. ****
;;; ******* and 'diary' for this to work properly. ********
;;; ;;;
;;; A message will be displayed in the mode line of the emacs buffer ;;; A message will be displayed in the mode line of the emacs buffer
;;; and (if the user desires) the terminal will beep and display a message ;;; and (if the user desires) the terminal will beep and display a message
...@@ -60,14 +59,16 @@ ...@@ -60,14 +59,16 @@
;;; In order to use, the following should be in your .emacs file in addition to ;;; In order to use, the following should be in your .emacs file in addition to
;;; creating a diary file and invoking calendar: ;;; creating a diary file and invoking calendar:
;;; ;;;
;;; Set some options ;;; To enable appointment reminders, the following lines are required:
;;; (setq view-diary-entries-initially t)
;;; (setq appt-issue-message t)
;;;
;;; The following three lines are required:
;;; (display-time)
;;; (add-hook 'diary-hook 'appt-make-list) ;;; (add-hook 'diary-hook 'appt-make-list)
;;; (let ((diary-display-hook 'ignore))
;;; (diary))
;;; You can replace the last two with just (diary)
;;; if you want to display the diary as well.
;;; ;;;
;;; Before that, you can also set some options if you want
;;; (setq view-diary-entries-initially t)
;;; (setq appt-issue-message t)
;;; ;;;
;;; This is an example of what can be in your diary file: ;;; This is an example of what can be in your diary file:
;;; Monday ;;; Monday
...@@ -173,6 +174,12 @@ This will occur at midnight when the appointment list is updated." ...@@ -173,6 +174,12 @@ This will occur at midnight when the appointment list is updated."
:type 'boolean :type 'boolean
:group 'appt) :group 'appt)
(defcustom appt-interval 60
"*Interval in seconds between checking for appointments."
:type 'integer
:group 'appt
:version "20.3")
(defvar appt-time-msg-list nil (defvar appt-time-msg-list nil
"The list of appointments for today. "The list of appointments for today.
Use `appt-add' and `appt-delete' to add and delete appointments from list. Use `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,6 +203,9 @@ The number before each time/message is the time in minutes from midnight.")
(defvar appt-delete-window-function 'appt-delete-window (defvar appt-delete-window-function 'appt-delete-window
"Function called to remove appointment window and buffer.") "Function called to remove appointment window and buffer.")
(defvar appt-mode-string nil
"String to display in the mode line for an appointment.")
(defun appt-check () (defun appt-check ()
"Check for an appointment and update the mode line. "Check for an appointment and update the mode line.
Note: the time must be the first thing in the line in the diary Note: the time must be the first thing in the line in the diary
...@@ -212,46 +222,43 @@ Example: ...@@ -212,46 +222,43 @@ Example:
The following variables control the action of the notification: The following variables control the action of the notification:
appt-issue-message `appt-issue-message'
If T, the diary buffer is checked for appointments. If t, the diary buffer is checked for appointments.
appt-message-warning-time `appt-message-warning-time'
Variable used to determine if appointment message Variable used to determine if appointment message
should be displayed. should be displayed.
appt-audible `appt-audible'
Variable used to determine if appointment is audible. Variable used to determine if appointment is audible.
Default is t. Default is t.
appt-visible `appt-visible'
Variable used to determine if appointment message should be Variable used to determine if appointment message should be
displayed in the mini-buffer. Default is t. displayed in the mini-buffer. Default is t.
appt-msg-window `appt-msg-window'
Variable used to determine if appointment message Variable used to determine if appointment message
should temporarily appear in another window. Mutually exclusive should temporarily appear in another window. Mutually exclusive
to appt-visible. to `appt-visible'.
appt-display-duration `appt-display-duration'
The number of seconds an appointment message The number of seconds an appointment message
is displayed in another window. is displayed in another window.
appt-display-interval `appt-display-interval'
The number of minutes to wait between checking the appointments The number of minutes to wait between checking the appointments
list. list.
appt-disp-window-function `appt-disp-window-function '
Function called to display appointment window. You can customize Function called to display appointment window. You can customize
appt.el by setting this variable to a function different from the appt.el by setting this variable to a function different from the
one provided with this package. one provided with this package.
appt-delete-window-function `appt-delete-window-function '
Function called to remove appointment window and buffer. You can Function called to remove appointment window and buffer. You can
customize appt.el by setting this variable to a function different customize appt.el by setting this variable to a function different
from the one provided with this package. from the one provided with this package."
This function is run from the loadst process for display time.
Therefore, you need to have `(display-time)' in your .emacs file."
(if (or (= appt-display-interval 1) (if (or (= appt-display-interval 1)
...@@ -314,18 +321,12 @@ Therefore, you need to have `(display-time)' in your .emacs file." ...@@ -314,18 +321,12 @@ Therefore, you need to have `(display-time)' in your .emacs file."
;; issue warning if the appointment time is ;; issue warning if the appointment time is
;; within appt-message-warning time ;; within appt-message-warning time
(if (and (<= min-to-app appt-message-warning-time) (when (and (<= min-to-app appt-message-warning-time)
(>= min-to-app 0)) (>= min-to-app 0))
(progn
(if appt-msg-window (if appt-msg-window
(progn (progn
(string-match (setq new-time (format-time-string "%a %b %e "
"[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" (current-time)))
display-time-string)
(setq new-time (substring display-time-string
(match-beginning 0)
(match-end 0)))
(funcall (funcall
appt-disp-window-function appt-disp-window-function
min-to-app new-time min-to-app new-time
...@@ -344,25 +345,15 @@ Therefore, you need to have `(display-time)' in your .emacs file." ...@@ -344,25 +345,15 @@ Therefore, you need to have `(display-time)' in your .emacs file."
(if appt-audible (if appt-audible
(beep 1))) (beep 1)))
(if appt-display-mode-line (when appt-display-mode-line
(progn (setq appt-mode-string
(string-match (concat "App't in " min-to-app " min. "))
"[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?"
display-time-string)
(setq new-time (substring display-time-string
(match-beginning 0)
(match-end 0)))
(setq display-time-string
(concat "App't in "
min-to-app " min. " new-time " "))
(force-mode-line-update t) (force-mode-line-update t)
(sit-for 0))) (sit-for 0))
(if (= min-to-app 0) (if (= min-to-app 0)
(setq appt-time-msg-list (setq appt-time-msg-list
(cdr appt-time-msg-list)))))))))))) (cdr appt-time-msg-list)))))))))))
;; Display appointment message in a separate buffer. ;; Display appointment message in a separate buffer.
...@@ -392,6 +383,7 @@ Therefore, you need to have `(display-time)' in your .emacs file." ...@@ -392,6 +383,7 @@ Therefore, you need to have `(display-time)' in your .emacs file."
(setq mode-line-format (setq mode-line-format
(concat "-------------------- Appointment in " (concat "-------------------- Appointment in "
min-to-app " minutes. " new-time " %-")) min-to-app " minutes. " new-time " %-"))
(erase-buffer)
(insert-string appt-msg) (insert-string appt-msg)
(shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf t)) (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf t))
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
...@@ -612,7 +604,14 @@ The time should be in either 24 hour format or am/pm format." ...@@ -612,7 +604,14 @@ The time should be in either 24 hour format or am/pm format."
(setq conv-time (+ (* hr 60) min)) (setq conv-time (+ (* hr 60) min))
conv-time)) conv-time))
(add-hook 'display-time-hook 'appt-check) (defvar appt-timer nil
"Timer used for diary appointment notifications (`appt-check').")
;;; appt.el ends here (setq appt-timer (run-at-time t appt-interval 'appt-check))
(or global-mode-string (setq global-mode-string '("")))
(or (memq 'appt-mode-string global-mode-string)
(setq global-mode-string
(append global-mode-string '(appt-mode-string))))
;;; appt.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment