Mercurial > emacs
annotate lisp/calendar/appt.el @ 5580:517d8eb361f8
* etags.c (stab_entry, stab_create, stab_find, stab_search,
stab_type, add_keyword, C_reate_stab, C_create_stabs): deleted.
Use gperf generated hash table instead of linked list.
(C_stab_entry, hash, in_word_set, get_C_stab, C_symtype): added.
Mostly code generated by gperf.
(consider_token): removed unused parameter `lp'.
(PF_funcs, getit): allow subroutine and similar declarations
to span multiple lines.
(C_entries): check for newline if inchar to avoid bus errors.
(process_file, find_entries): distinguish among nonexistent
and not regular file.
author | Francesco Potortì <pot@gnu.org> |
---|---|
date | Fri, 14 Jan 1994 17:02:11 +0000 |
parents | c7badee38b64 |
children | 32a02ab40d58 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
179
diff
changeset
|
1 ;;; appt.el --- appointment notification functions. |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
179
diff
changeset
|
2 |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
3 ;; Copyright (C) 1989, 1990 Free Software Foundation, Inc. |
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
5 ;; Author: Neil Mager <neilm@juliet.ll.mit.edu> |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
6 ;; Version: 2.1 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
7 ;; Keywords: calendar |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
8 |
179 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
179 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
25 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
26 |
179 | 27 ;; |
28 ;; appt.el - visible and/or audible notification of | |
29 ;; appointments from ~/diary file generated from | |
30 ;; Edward M. Reingold's calendar.el. | |
31 ;; | |
32 ;; | |
33 ;; Comments, corrections, and improvements should be sent to | |
34 ;; Neil M. Mager | |
35 ;; Net <neilm@juliet.ll.mit.edu> | |
36 ;; Voice (617) 981-4803 | |
37 ;;; | |
38 ;;; Thanks to Edward M. Reingold for much help and many suggestions, | |
39 ;;; And to many others for bug fixes and suggestions. | |
40 ;;; | |
41 ;;; | |
42 ;;; This functions in this file will alert the user of a | |
43 ;;; pending appointment based on their diary file. | |
44 ;;; | |
45 ;;; | |
46 ;;; ******* It is necessary to invoke 'display-time' ******** | |
47 ;;; ******* and 'diary' for this to work properly. ******** | |
48 ;;; | |
49 ;;; A message will be displayed in the mode line of the emacs buffer | |
50 ;;; and (if the user desires) the terminal will beep and display a message | |
51 ;;; from the diary in the mini-buffer, or the user may select to | |
52 ;;; have a message displayed in a new buffer. | |
53 ;;; | |
54 ;;; The variable 'appt-message-warning-time' allows the | |
55 ;;; user to specify how much notice they want before the appointment. The | |
56 ;;; variable 'appt-issue-message' specifies whether the user wants | |
57 ;;; to to be notified of a pending appointment. | |
58 ;;; | |
59 ;;; In order to use, the following should be in your .emacs file in addition to | |
60 ;;; creating a diary file and invoking calendar: | |
61 ;;; | |
62 ;;; Set some options | |
63 ;;; (setq view-diary-entries-initially t) | |
64 ;;; (setq appt-issue-message t) | |
65 ;;; | |
66 ;;; The following three lines are required: | |
67 ;;; (display-time) | |
68 ;;; (autoload 'appt-make-list "appt.el" nil t) | |
69 ;;; (setq diary-display-hook | |
70 ;;; (list 'appt-make-list 'prepare-fancy-diary-buffer)) | |
71 ;;; | |
72 ;;; | |
73 ;;; This is an example of what can be in your diary file: | |
74 ;;; Monday | |
75 ;;; 9:30am Coffee break | |
76 ;;; 12:00pm Lunch | |
77 ;;; | |
78 ;;; Based upon the above lines in your .emacs and diary files, | |
79 ;;; the calendar and diary will be displayed when you enter | |
80 ;;; emacs and your appointments list will automatically be created. | |
81 ;;; You will then be reminded at 9:20am about your coffee break | |
82 ;;; and at 11:50am to go to lunch. | |
83 ;;; | |
84 ;;; Use describe-function on appt-check for a description of other variables | |
85 ;;; that can be used to personalize the notification system. | |
86 ;;; | |
87 ;;; In order to add or delete items from todays list, use appt-add | |
88 ;;; and appt-delete. | |
89 ;;; | |
90 ;;; Additionally, the appointments list is recreated automatically | |
91 ;;; at 12:01am for those who do not logout every day or are programming | |
92 ;;; late. | |
93 ;;; | |
94 ;;; Brief internal description - Skip this if your not interested! | |
95 ;;; | |
96 ;;; The function appt-check is run from the 'loadst' process which is started | |
97 ;;; by invoking (display-time). A temporary function below modifies | |
98 ;;; display-time-filter | |
99 ;;; (from original time.el) to include a hook which will invoke appt-check. | |
100 ;;; This will not be necessary in the next version of gnuemacs. | |
101 ;;; | |
102 ;;; | |
103 ;;; The function appt-make-list creates the appointments list which appt-check | |
104 ;;; reads. This is all done automatically. | |
105 ;;; It is invoked from the function list-diary-entries. | |
106 ;;; | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
107 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
108 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
109 |
957 | 110 ;;;###autoload |
179 | 111 (defvar appt-issue-message t |
112 "*Non-nil means check for appointments in the diary buffer. | |
113 To be detected, the diary entry must have the time | |
114 as the first thing on a line.") | |
115 | |
957 | 116 ;;;###autoload |
179 | 117 (defvar appt-message-warning-time 10 |
118 "*Time in minutes before an appointment that the warning begins.") | |
119 | |
957 | 120 ;;;###autoload |
179 | 121 (defvar appt-audible t |
122 "*Non-nil means beep to indicate appointment.") | |
123 | |
957 | 124 ;;;###autoload |
179 | 125 (defvar appt-visible t |
126 "*Non-nil means display appointment message in echo area.") | |
127 | |
957 | 128 ;;;###autoload |
179 | 129 (defvar appt-display-mode-line t |
130 "*Non-nil means display minutes to appointment and time on the mode line.") | |
131 | |
957 | 132 ;;;###autoload |
179 | 133 (defvar appt-msg-window t |
134 "*Non-nil means display appointment message in another window.") | |
135 | |
957 | 136 ;;;###autoload |
179 | 137 (defvar appt-display-duration 5 |
138 "*The number of seconds an appointment message is displayed.") | |
139 | |
957 | 140 ;;;###autoload |
179 | 141 (defvar appt-display-diary t |
142 "*Non-nil means to display the next days diary on the screen. | |
143 This will occur at midnight when the appointment list is updated.") | |
144 | |
145 (defvar appt-time-msg-list nil | |
146 "The list of appointments for today. | |
147 Use `appt-add' and `appt-delete' to add and delete appointments from list. | |
148 The original list is generated from the today's `diary-entries-list'. | |
149 The number before each time/message is the time in minutes from midnight.") | |
150 | |
151 (defconst max-time 1439 | |
152 "11:59pm in minutes - number of minutes in a day minus 1.") | |
153 | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
154 (defvar appt-display-interval 1 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
155 "*Number of minutes to wait between checking the appointment list.") |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
156 |
179 | 157 (defun appt-check () |
158 "Check for an appointment and update the mode line. | |
159 Note: the time must be the first thing in the line in the diary | |
160 for a warning to be issued. | |
161 | |
162 The format of the time can be either 24 hour or am/pm. | |
163 Example: | |
164 | |
165 02/23/89 | |
166 18:00 Dinner | |
167 | |
168 Thursday | |
169 11:45am Lunch meeting. | |
170 | |
171 The following variables control the action of the notification: | |
172 | |
173 appt-issue-message | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
174 If T, the diary buffer is checked for appointments. |
179 | 175 |
176 appt-message-warning-time | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
177 Variable used to determine if appointment message |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
178 should be displayed. |
179 | 179 |
180 appt-audible | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
181 Variable used to determine if appointment is audible. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
182 Default is t. |
179 | 183 |
184 appt-visible | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
185 Variable used to determine if appointment message should be |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
186 displayed in the mini-buffer. Default is t. |
179 | 187 |
188 appt-msg-window | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
189 Variable used to determine if appointment message |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
190 should temporarily appear in another window. Mutually exclusive |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
191 to appt-visible. |
179 | 192 |
193 appt-display-duration | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
194 The number of seconds an appointment message |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
195 is displayed in another window. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
196 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
197 appt-display-interval |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
198 The number of minutes to wait between checking the appointments |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
199 list. |
179 | 200 |
201 This function is run from the loadst process for display time. | |
202 Therefore, you need to have `(display-time)' in your .emacs file." | |
203 | |
204 | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
205 (if (or (= appt-display-interval 1) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
206 ;; This is true every appt-display-interval minutes. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
207 (= 0 (mod (/ (nth 1 (current-time)) 60) appt-display-interval))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
208 (let ((min-to-app -1) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
209 (new-time "")) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
210 (save-excursion |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
211 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
212 ;; Get the current time and convert it to minutes |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
213 ;; from midnight. ie. 12:01am = 1, midnight = 0. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
214 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
215 (let* ((cur-hour(string-to-int |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
216 (substring (current-time-string) 11 13))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
217 (cur-min (string-to-int |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
218 (substring (current-time-string) 14 16))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
219 (cur-comp-time (+ (* cur-hour 60) cur-min))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
220 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
221 ;; If the time is 12:01am, we should update our |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
222 ;; appointments to todays list. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
223 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
224 (if (= cur-comp-time 1) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
225 (if (and view-diary-entries-initially appt-display-diary) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
226 (diary) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
227 (let ((diary-display-hook 'appt-make-list)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
228 (diary)))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
229 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
230 ;; If there are entries in the list, and the |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
231 ;; user wants a message issued |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
232 ;; get the first time off of the list |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
233 ;; and calculate the number of minutes until |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
234 ;; the appointment. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
235 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
236 (if (and appt-issue-message appt-time-msg-list) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
237 (let ((appt-comp-time (car (car (car appt-time-msg-list))))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
238 (setq min-to-app (- appt-comp-time cur-comp-time)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
239 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
240 (while (and appt-time-msg-list |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
241 (< appt-comp-time cur-comp-time)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
242 (setq appt-time-msg-list (cdr appt-time-msg-list)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
243 (if appt-time-msg-list |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
244 (setq appt-comp-time |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
245 (car (car (car appt-time-msg-list)))))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
246 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
247 ;; If we have an appointment between midnight and |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
248 ;; 'appt-message-warning-time' minutes after midnight, |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
249 ;; we must begin to issue a message before midnight. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
250 ;; Midnight is considered 0 minutes and 11:59pm is |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
251 ;; 1439 minutes. Therefore we must recalculate the minutes |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
252 ;; to appointment variable. It is equal to the number of |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
253 ;; minutes before midnight plus the number of |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
254 ;; minutes after midnight our appointment is. |
179 | 255 |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
256 (if (and (< appt-comp-time appt-message-warning-time) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
257 (> (+ cur-comp-time appt-message-warning-time) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
258 max-time)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
259 (setq min-to-app (+ (- (1+ max-time) cur-comp-time)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
260 appt-comp-time)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
261 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
262 ;; issue warning if the appointment time is |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
263 ;; within appt-message-warning time |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
264 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
265 (if (and (<= min-to-app appt-message-warning-time) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
266 (>= min-to-app 0)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
267 (progn |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
268 (if appt-msg-window |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
269 (progn |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
270 (string-match |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
271 "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
272 display-time-string) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
273 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
274 (setq new-time (substring display-time-string |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
275 (match-beginning 0) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
276 (match-end 0))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
277 (appt-disp-window min-to-app new-time |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
278 (car (cdr (car appt-time-msg-list))))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
279 ;;; else |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
280 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
281 (if appt-visible |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
282 (message "%s" |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
283 (car (cdr (car appt-time-msg-list))))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
284 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
285 (if appt-audible |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
286 (beep 1))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
287 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
288 (if appt-display-mode-line |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
289 (progn |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
290 (string-match |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
291 "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
292 display-time-string) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
293 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
294 (setq new-time (substring display-time-string |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
295 (match-beginning 0) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
296 (match-end 0))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
297 (setq display-time-string |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
298 (concat "App't in " |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
299 min-to-app " min. " new-time " ")) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
300 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
301 ;; force mode line updates - from time.el |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
302 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
303 (save-excursion (set-buffer (other-buffer))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
304 (set-buffer-modified-p (buffer-modified-p)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
305 (sit-for 0))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
306 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
307 (if (= min-to-app 0) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
308 (setq appt-time-msg-list |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
309 (cdr appt-time-msg-list)))))))))))) |
179 | 310 |
311 | |
312 ;; Display appointment message in a separate buffer. | |
313 (defun appt-disp-window (min-to-app new-time appt-msg) | |
314 (require 'electric) | |
315 (save-window-excursion | |
316 | |
317 ;; Make sure we're not in the minibuffer | |
318 ;; before splitting the window. | |
319 | |
777 | 320 (if (= (frame-height) |
179 | 321 (nth 3 (window-edges (selected-window)))) |
322 nil | |
323 (appt-select-lowest-window) | |
324 (split-window)) | |
325 | |
326 (let* ((this-buffer (current-buffer)) | |
327 (appt-disp-buf (set-buffer (get-buffer-create "appt-buf")))) | |
328 (setq mode-line-format | |
329 (concat "-------------------- Appointment in " | |
330 min-to-app " minutes. " new-time " %-")) | |
331 (pop-to-buffer appt-disp-buf) | |
332 (insert-string appt-msg) | |
333 (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf)) | |
334 (set-buffer-modified-p nil) | |
335 (if appt-audible | |
336 (beep 1)) | |
337 (sit-for appt-display-duration) | |
338 (if appt-audible | |
339 (beep 1)) | |
340 (kill-buffer appt-disp-buf)))) | |
341 | |
777 | 342 ;; Select the lowest window on the frame. |
179 | 343 (defun appt-select-lowest-window () |
344 (setq lowest-window (selected-window)) | |
345 (let* ((bottom-edge (car (cdr (cdr (cdr (window-edges)))))) | |
346 (last-window (previous-window)) | |
347 (window-search t)) | |
348 (while window-search | |
349 (let* ((this-window (next-window)) | |
350 (next-bottom-edge (car (cdr (cdr (cdr | |
351 (window-edges this-window))))))) | |
352 (if (< bottom-edge next-bottom-edge) | |
353 (progn | |
354 (setq bottom-edge next-bottom-edge) | |
355 (setq lowest-window this-window))) | |
356 | |
357 (select-window this-window) | |
358 (if (eq last-window this-window) | |
359 (progn | |
360 (select-window lowest-window) | |
361 (setq window-search nil))))))) | |
362 | |
363 | |
364 (defun appt-add (new-appt-time new-appt-msg) | |
365 "Add an appointment for the day at TIME and issue MESSAGE. | |
366 The time should be in either 24 hour format or am/pm format." | |
367 | |
368 (interactive "sTime (hh:mm[am/pm]): \nsMessage: ") | |
369 (if (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" new-appt-time) | |
370 nil | |
371 (error "Unacceptable time-string")) | |
372 | |
373 (let* ((appt-time-string (concat new-appt-time " " new-appt-msg)) | |
374 (appt-time (list (appt-convert-time new-appt-time))) | |
375 (time-msg (cons appt-time (list appt-time-string)))) | |
376 (setq appt-time-msg-list (append appt-time-msg-list | |
377 (list time-msg))) | |
378 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)))) | |
379 | |
380 (defun appt-delete () | |
381 "Delete an appointment from the list of appointments." | |
382 (interactive) | |
383 (let* ((tmp-msg-list appt-time-msg-list)) | |
384 (while tmp-msg-list | |
385 (let* ((element (car tmp-msg-list)) | |
386 (prompt-string (concat "Delete " | |
387 (prin1-to-string (car (cdr element))) | |
388 " from list? ")) | |
389 (test-input (y-or-n-p prompt-string))) | |
390 (setq tmp-msg-list (cdr tmp-msg-list)) | |
391 (if test-input | |
392 (setq appt-time-msg-list (delq element appt-time-msg-list))) | |
393 (setq tmp-appt-msg-list nil))) | |
394 (message ""))) | |
395 | |
396 | |
397 ;; Create the appointments list from todays diary buffer. | |
398 ;; The time must be at the beginning of a line for it to be | |
399 ;; put in the appointments list. | |
400 ;; 02/23/89 | |
401 ;; 12:00pm lunch | |
402 ;; Wednesday | |
403 ;; 10:00am group meeting" | |
404 | |
927 | 405 ;;;###autoload |
179 | 406 (defun appt-make-list () |
407 (setq appt-time-msg-list nil) | |
408 | |
409 (save-excursion | |
410 (if diary-entries-list | |
411 | |
412 ;; Cycle through the entry-list (diary-entries-list) | |
413 ;; looking for entries beginning with a time. If | |
414 ;; the entry begins with a time, add it to the | |
415 ;; appt-time-msg-list. Then sort the list. | |
416 | |
417 (let ((entry-list diary-entries-list) | |
418 (new-time-string "")) | |
419 (while (and entry-list | |
420 (calendar-date-equal | |
421 (calendar-current-date) (car (car entry-list)))) | |
422 (let ((time-string (substring (prin1-to-string | |
423 (cdr (car entry-list))) 2 -2))) | |
424 | |
425 (while (string-match | |
426 "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?.*" | |
427 time-string) | |
428 (let* ((appt-time-string (substring time-string | |
429 (match-beginning 0) | |
430 (match-end 0)))) | |
431 | |
432 (if (< (match-end 0) (length time-string)) | |
433 (setq new-time-string (substring time-string | |
434 (+ (match-end 0) 1) | |
435 nil)) | |
436 (setq new-time-string "")) | |
437 | |
438 (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" | |
439 time-string) | |
440 | |
441 (let* ((appt-time (list (appt-convert-time | |
442 (substring time-string | |
443 (match-beginning 0) | |
444 (match-end 0))))) | |
445 (time-msg (cons appt-time | |
446 (list appt-time-string)))) | |
447 (setq time-string new-time-string) | |
448 (setq appt-time-msg-list (append appt-time-msg-list | |
449 (list time-msg))))))) | |
450 (setq entry-list (cdr entry-list))))) | |
451 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) | |
452 | |
453 ;; Get the current time and convert it to minutes | |
454 ;; from midnight. ie. 12:01am = 1, midnight = 0, | |
455 ;; so that the elements in the list | |
456 ;; that are earlier than the present time can | |
457 ;; be removed. | |
458 | |
459 (let* ((cur-hour(string-to-int | |
460 (substring (current-time-string) 11 13))) | |
461 (cur-min (string-to-int | |
462 (substring (current-time-string) 14 16))) | |
463 (cur-comp-time (+ (* cur-hour 60) cur-min)) | |
464 (appt-comp-time (car (car (car appt-time-msg-list))))) | |
465 | |
466 (while (and appt-time-msg-list (< appt-comp-time cur-comp-time)) | |
467 (setq appt-time-msg-list (cdr appt-time-msg-list)) | |
468 (if appt-time-msg-list | |
469 (setq appt-comp-time (car (car (car appt-time-msg-list))))))))) | |
470 | |
471 | |
472 ;;Simple sort to put the appointments list in order. | |
473 ;;Scan the list for the smallest element left in the list. | |
474 ;;Append the smallest element left into the new list, and remove | |
475 ;;it from the original list. | |
476 (defun appt-sort-list (appt-list) | |
477 (let ((order-list nil)) | |
478 (while appt-list | |
479 (let* ((element (car appt-list)) | |
480 (element-time (car (car element))) | |
481 (tmp-list (cdr appt-list))) | |
482 (while tmp-list | |
483 (if (< element-time (car (car (car tmp-list)))) | |
484 nil | |
485 (setq element (car tmp-list)) | |
486 (setq element-time (car (car element)))) | |
487 (setq tmp-list (cdr tmp-list))) | |
488 (setq order-list (append order-list (list element))) | |
489 (setq appt-list (delq element appt-list)))) | |
490 order-list)) | |
491 | |
492 | |
493 (defun appt-convert-time (time2conv) | |
494 "Convert hour:min[am/pm] format to minutes from midnight." | |
495 | |
496 (let ((conv-time 0) | |
497 (hr 0) | |
498 (min 0)) | |
499 | |
500 (string-match ":[0-9][0-9]" time2conv) | |
501 (setq min (string-to-int | |
502 (substring time2conv | |
503 (+ (match-beginning 0) 1) (match-end 0)))) | |
504 | |
505 (string-match "[0-9]?[0-9]:" time2conv) | |
506 (setq hr (string-to-int | |
507 (substring time2conv | |
508 (match-beginning 0) | |
509 (match-end 0)))) | |
510 | |
511 ;; convert the time appointment time into 24 hour time | |
512 | |
513 (if (and (string-match "[p][m]" time2conv) (< hr 12)) | |
514 (progn | |
515 (string-match "[0-9]?[0-9]:" time2conv) | |
516 (setq hr (+ 12 hr)))) | |
517 | |
518 ;; convert the actual time | |
519 ;; into minutes for comparison | |
520 ;; against the actual time. | |
521 | |
522 (setq conv-time (+ (* hr 60) min)) | |
523 conv-time)) | |
524 | |
525 (setq display-time-hook 'appt-check) | |
526 | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
179
diff
changeset
|
527 ;;; appt.el ends here |