Mercurial > emacs
annotate lisp/calendar/appt.el @ 8243:bf7b3b969ab5
(syms_of_fileio): Finish previous change.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 14 Jul 1994 03:39:04 +0000 |
parents | 4fd40bd394fe |
children | 863e05092c58 |
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 |
7298 | 3 ;; Copyright (C) 1989, 1990, 1994 Free Software Foundation, Inc. |
846
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> |
6222 | 6 ;; Maintainer: FSF |
807
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) | |
6312 | 69 ;;; (add-hook 'diary-hook 'appt-make-list) |
179 | 70 ;;; |
71 ;;; | |
72 ;;; This is an example of what can be in your diary file: | |
73 ;;; Monday | |
74 ;;; 9:30am Coffee break | |
75 ;;; 12:00pm Lunch | |
76 ;;; | |
77 ;;; Based upon the above lines in your .emacs and diary files, | |
78 ;;; the calendar and diary will be displayed when you enter | |
79 ;;; emacs and your appointments list will automatically be created. | |
80 ;;; You will then be reminded at 9:20am about your coffee break | |
81 ;;; and at 11:50am to go to lunch. | |
82 ;;; | |
83 ;;; Use describe-function on appt-check for a description of other variables | |
84 ;;; that can be used to personalize the notification system. | |
85 ;;; | |
86 ;;; In order to add or delete items from todays list, use appt-add | |
87 ;;; and appt-delete. | |
88 ;;; | |
89 ;;; Additionally, the appointments list is recreated automatically | |
90 ;;; at 12:01am for those who do not logout every day or are programming | |
91 ;;; late. | |
92 ;;; | |
93 ;;; Brief internal description - Skip this if your not interested! | |
94 ;;; | |
95 ;;; The function appt-check is run from the 'loadst' process which is started | |
96 ;;; by invoking (display-time). A temporary function below modifies | |
97 ;;; display-time-filter | |
98 ;;; (from original time.el) to include a hook which will invoke appt-check. | |
99 ;;; This will not be necessary in the next version of gnuemacs. | |
100 ;;; | |
101 ;;; | |
102 ;;; The function appt-make-list creates the appointments list which appt-check | |
103 ;;; reads. This is all done automatically. | |
104 ;;; It is invoked from the function list-diary-entries. | |
105 ;;; | |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
106 ;;; You can change the way the appointment window is created/deleted by |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
107 ;;; setting the variables |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
108 ;;; |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
109 ;;; appt-disp-window-function |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
110 ;;; and |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
111 ;;; appt-delete-window-function |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
112 ;;; |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
113 ;;; For instance, these variables can be set to functions that display |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
114 ;;; appointments in pop-up frames, which are lowered or iconified after |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
115 ;;; appt-display-interval seconds. |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
116 ;;; |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
117 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
118 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
119 |
957 | 120 ;;;###autoload |
179 | 121 (defvar appt-issue-message t |
122 "*Non-nil means check for appointments in the diary buffer. | |
123 To be detected, the diary entry must have the time | |
124 as the first thing on a line.") | |
125 | |
957 | 126 ;;;###autoload |
5714
9f37f85000d8
(appt-display-interval, appt-display-duration)
Richard M. Stallman <rms@gnu.org>
parents:
5668
diff
changeset
|
127 (defvar appt-message-warning-time 12 |
179 | 128 "*Time in minutes before an appointment that the warning begins.") |
129 | |
957 | 130 ;;;###autoload |
179 | 131 (defvar appt-audible t |
132 "*Non-nil means beep to indicate appointment.") | |
133 | |
957 | 134 ;;;###autoload |
179 | 135 (defvar appt-visible t |
136 "*Non-nil means display appointment message in echo area.") | |
137 | |
957 | 138 ;;;###autoload |
179 | 139 (defvar appt-display-mode-line t |
140 "*Non-nil means display minutes to appointment and time on the mode line.") | |
141 | |
957 | 142 ;;;###autoload |
179 | 143 (defvar appt-msg-window t |
144 "*Non-nil means display appointment message in another window.") | |
145 | |
957 | 146 ;;;###autoload |
5714
9f37f85000d8
(appt-display-interval, appt-display-duration)
Richard M. Stallman <rms@gnu.org>
parents:
5668
diff
changeset
|
147 (defvar appt-display-duration 10 |
179 | 148 "*The number of seconds an appointment message is displayed.") |
149 | |
957 | 150 ;;;###autoload |
179 | 151 (defvar appt-display-diary t |
152 "*Non-nil means to display the next days diary on the screen. | |
153 This will occur at midnight when the appointment list is updated.") | |
154 | |
155 (defvar appt-time-msg-list nil | |
156 "The list of appointments for today. | |
157 Use `appt-add' and `appt-delete' to add and delete appointments from list. | |
158 The original list is generated from the today's `diary-entries-list'. | |
159 The number before each time/message is the time in minutes from midnight.") | |
160 | |
161 (defconst max-time 1439 | |
162 "11:59pm in minutes - number of minutes in a day minus 1.") | |
163 | |
5714
9f37f85000d8
(appt-display-interval, appt-display-duration)
Richard M. Stallman <rms@gnu.org>
parents:
5668
diff
changeset
|
164 (defvar appt-display-interval 3 |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
165 "*Number of minutes to wait between checking the appointment list.") |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
166 |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
167 (defvar appt-buffer-name " *appt-buf*" |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
168 "Name of the appointments buffer.") |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
169 |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
170 (defvar appt-disp-window-function 'appt-disp-window |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
171 "Function called to display appointment window.") |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
172 |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
173 (defvar appt-delete-window-function 'appt-delete-window |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
174 "Function called to remove appointment window and buffer.") |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
175 |
179 | 176 (defun appt-check () |
177 "Check for an appointment and update the mode line. | |
178 Note: the time must be the first thing in the line in the diary | |
179 for a warning to be issued. | |
180 | |
181 The format of the time can be either 24 hour or am/pm. | |
182 Example: | |
183 | |
184 02/23/89 | |
185 18:00 Dinner | |
186 | |
187 Thursday | |
188 11:45am Lunch meeting. | |
189 | |
190 The following variables control the action of the notification: | |
191 | |
192 appt-issue-message | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
193 If T, the diary buffer is checked for appointments. |
179 | 194 |
195 appt-message-warning-time | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
196 Variable used to determine if appointment message |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
197 should be displayed. |
179 | 198 |
199 appt-audible | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
200 Variable used to determine if appointment is audible. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
201 Default is t. |
179 | 202 |
203 appt-visible | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
204 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
|
205 displayed in the mini-buffer. Default is t. |
179 | 206 |
207 appt-msg-window | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
208 Variable used to determine if appointment message |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
209 should temporarily appear in another window. Mutually exclusive |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
210 to appt-visible. |
179 | 211 |
212 appt-display-duration | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
213 The number of seconds an appointment message |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
214 is displayed in another window. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
215 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
216 appt-display-interval |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
217 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
|
218 list. |
179 | 219 |
5668 | 220 appt-disp-window-function |
221 Function called to display appointment window. You can customize | |
222 appt.el by setting this variable to a function different from the | |
223 one provided with this package. | |
224 | |
225 appt-delete-window-function | |
226 Function called to remove appointment window and buffer. You can | |
227 customize appt.el by setting this variable to a function different | |
228 from the one provided with this package. | |
229 | |
179 | 230 This function is run from the loadst process for display time. |
231 Therefore, you need to have `(display-time)' in your .emacs file." | |
232 | |
233 | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
234 (if (or (= appt-display-interval 1) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
235 ;; This is true every appt-display-interval minutes. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
236 (= 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
|
237 (let ((min-to-app -1) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
238 (new-time "")) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
239 (save-excursion |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
240 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
241 ;; 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
|
242 ;; from midnight. ie. 12:01am = 1, midnight = 0. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
243 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
244 (let* ((cur-hour(string-to-int |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
245 (substring (current-time-string) 11 13))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
246 (cur-min (string-to-int |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
247 (substring (current-time-string) 14 16))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
248 (cur-comp-time (+ (* cur-hour 60) cur-min))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
249 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
250 ;; 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
|
251 ;; appointments to todays list. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
252 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
253 (if (= cur-comp-time 1) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
254 (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
|
255 (diary) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
256 (let ((diary-display-hook 'appt-make-list)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
257 (diary)))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
258 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
259 ;; 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
|
260 ;; user wants a message issued |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
261 ;; get the first time off of the list |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
262 ;; and calculate the number of minutes until |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
263 ;; the appointment. |
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 appt-issue-message appt-time-msg-list) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
266 (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
|
267 (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
|
268 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
269 (while (and appt-time-msg-list |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
270 (< appt-comp-time cur-comp-time)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
271 (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
|
272 (if appt-time-msg-list |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
273 (setq appt-comp-time |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
274 (car (car (car appt-time-msg-list)))))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
275 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
276 ;; If we have an appointment between midnight and |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
277 ;; 'appt-message-warning-time' minutes after midnight, |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
278 ;; 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
|
279 ;; 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
|
280 ;; 1439 minutes. Therefore we must recalculate the minutes |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
281 ;; 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
|
282 ;; minutes before midnight plus the number of |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
283 ;; minutes after midnight our appointment is. |
179 | 284 |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
285 (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
|
286 (> (+ cur-comp-time appt-message-warning-time) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
287 max-time)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
288 (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
|
289 appt-comp-time)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
290 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
291 ;; issue warning if the appointment time is |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
292 ;; within appt-message-warning time |
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 (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
|
295 (>= min-to-app 0)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
296 (progn |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
297 (if appt-msg-window |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
298 (progn |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
299 (string-match |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
300 "[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
|
301 display-time-string) |
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 (setq new-time (substring display-time-string |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
304 (match-beginning 0) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
305 (match-end 0))) |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
306 (funcall |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
307 appt-disp-window-function |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
308 min-to-app new-time |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
309 (car (cdr (car appt-time-msg-list)))) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
310 |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
311 (run-at-time |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
312 (format "%d sec" appt-display-duration) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
313 nil |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
314 appt-delete-window-function)) |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
315 ;;; else |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
316 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
317 (if appt-visible |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
318 (message "%s" |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
319 (car (cdr (car appt-time-msg-list))))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
320 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
321 (if appt-audible |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
322 (beep 1))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
323 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
324 (if appt-display-mode-line |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
325 (progn |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
326 (string-match |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
327 "[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
|
328 display-time-string) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
329 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
330 (setq new-time (substring display-time-string |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
331 (match-beginning 0) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
332 (match-end 0))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
333 (setq display-time-string |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
334 (concat "App't in " |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
335 min-to-app " min. " new-time " ")) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
336 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
337 ;; force mode line updates - from time.el |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
338 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
339 (save-excursion (set-buffer (other-buffer))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
340 (set-buffer-modified-p (buffer-modified-p)) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
341 (sit-for 0))) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
342 |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
343 (if (= min-to-app 0) |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
344 (setq appt-time-msg-list |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
345 (cdr appt-time-msg-list)))))))))))) |
179 | 346 |
347 | |
348 ;; Display appointment message in a separate buffer. | |
349 (defun appt-disp-window (min-to-app new-time appt-msg) | |
350 (require 'electric) | |
351 | |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
352 ;; Make sure we're not in the minibuffer |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
353 ;; before splitting the window. |
179 | 354 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
355 (if (equal (selected-window) (minibuffer-window)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
356 (if (other-window 1) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
357 (select-window (other-window 1)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
358 (if window-system |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
359 (select-frame (other-frame 1))))) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
360 |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
361 (let* ((this-buffer (current-buffer)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
362 (this-window (selected-window)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
363 (appt-disp-buf (set-buffer (get-buffer-create appt-buffer-name)))) |
179 | 364 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
365 (appt-select-lowest-window) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
366 (split-window) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
367 |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
368 (pop-to-buffer appt-disp-buf) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
369 (setq mode-line-format |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
370 (concat "-------------------- Appointment in " |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
371 min-to-app " minutes. " new-time " %-")) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
372 (insert-string appt-msg) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
373 (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
374 (set-buffer-modified-p nil) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
375 (select-window this-window) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
376 (if appt-audible |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
377 (beep 1)))) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
378 |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
379 (defun appt-delete-window () |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
380 "Function called to undisplay appointment messages. |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
381 Usually just deletes the appointment buffer." |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
382 (delete-window (get-buffer-window appt-buffer-name)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
383 (kill-buffer appt-buffer-name) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
384 (if appt-audible |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
385 (beep 1))) |
179 | 386 |
777 | 387 ;; Select the lowest window on the frame. |
179 | 388 (defun appt-select-lowest-window () |
389 (setq lowest-window (selected-window)) | |
390 (let* ((bottom-edge (car (cdr (cdr (cdr (window-edges)))))) | |
391 (last-window (previous-window)) | |
392 (window-search t)) | |
393 (while window-search | |
394 (let* ((this-window (next-window)) | |
395 (next-bottom-edge (car (cdr (cdr (cdr | |
396 (window-edges this-window))))))) | |
397 (if (< bottom-edge next-bottom-edge) | |
398 (progn | |
399 (setq bottom-edge next-bottom-edge) | |
400 (setq lowest-window this-window))) | |
401 | |
402 (select-window this-window) | |
403 (if (eq last-window this-window) | |
404 (progn | |
405 (select-window lowest-window) | |
406 (setq window-search nil))))))) | |
407 | |
408 | |
409 (defun appt-add (new-appt-time new-appt-msg) | |
410 "Add an appointment for the day at TIME and issue MESSAGE. | |
411 The time should be in either 24 hour format or am/pm format." | |
412 | |
413 (interactive "sTime (hh:mm[am/pm]): \nsMessage: ") | |
414 (if (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" new-appt-time) | |
415 nil | |
416 (error "Unacceptable time-string")) | |
417 | |
418 (let* ((appt-time-string (concat new-appt-time " " new-appt-msg)) | |
419 (appt-time (list (appt-convert-time new-appt-time))) | |
420 (time-msg (cons appt-time (list appt-time-string)))) | |
421 (setq appt-time-msg-list (append appt-time-msg-list | |
422 (list time-msg))) | |
423 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)))) | |
424 | |
425 (defun appt-delete () | |
426 "Delete an appointment from the list of appointments." | |
427 (interactive) | |
428 (let* ((tmp-msg-list appt-time-msg-list)) | |
429 (while tmp-msg-list | |
430 (let* ((element (car tmp-msg-list)) | |
431 (prompt-string (concat "Delete " | |
432 (prin1-to-string (car (cdr element))) | |
433 " from list? ")) | |
434 (test-input (y-or-n-p prompt-string))) | |
435 (setq tmp-msg-list (cdr tmp-msg-list)) | |
436 (if test-input | |
437 (setq appt-time-msg-list (delq element appt-time-msg-list))) | |
438 (setq tmp-appt-msg-list nil))) | |
439 (message ""))) | |
440 | |
441 | |
442 ;; Create the appointments list from todays diary buffer. | |
443 ;; The time must be at the beginning of a line for it to be | |
444 ;; put in the appointments list. | |
445 ;; 02/23/89 | |
446 ;; 12:00pm lunch | |
447 ;; Wednesday | |
448 ;; 10:00am group meeting" | |
449 | |
927 | 450 ;;;###autoload |
179 | 451 (defun appt-make-list () |
452 (setq appt-time-msg-list nil) | |
453 | |
454 (save-excursion | |
455 (if diary-entries-list | |
456 | |
457 ;; Cycle through the entry-list (diary-entries-list) | |
458 ;; looking for entries beginning with a time. If | |
459 ;; the entry begins with a time, add it to the | |
460 ;; appt-time-msg-list. Then sort the list. | |
461 | |
462 (let ((entry-list diary-entries-list) | |
463 (new-time-string "")) | |
464 (while (and entry-list | |
465 (calendar-date-equal | |
466 (calendar-current-date) (car (car entry-list)))) | |
467 (let ((time-string (substring (prin1-to-string | |
468 (cdr (car entry-list))) 2 -2))) | |
469 | |
470 (while (string-match | |
471 "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?.*" | |
472 time-string) | |
473 (let* ((appt-time-string (substring time-string | |
474 (match-beginning 0) | |
475 (match-end 0)))) | |
476 | |
477 (if (< (match-end 0) (length time-string)) | |
478 (setq new-time-string (substring time-string | |
479 (+ (match-end 0) 1) | |
480 nil)) | |
481 (setq new-time-string "")) | |
482 | |
483 (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" | |
484 time-string) | |
485 | |
486 (let* ((appt-time (list (appt-convert-time | |
487 (substring time-string | |
488 (match-beginning 0) | |
489 (match-end 0))))) | |
490 (time-msg (cons appt-time | |
491 (list appt-time-string)))) | |
492 (setq time-string new-time-string) | |
493 (setq appt-time-msg-list (append appt-time-msg-list | |
494 (list time-msg))))))) | |
495 (setq entry-list (cdr entry-list))))) | |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
496 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) |
179 | 497 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
498 ;; Get the current time and convert it to minutes |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
499 ;; from midnight. ie. 12:01am = 1, midnight = 0, |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
500 ;; so that the elements in the list |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
501 ;; that are earlier than the present time can |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
502 ;; be removed. |
179 | 503 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
504 (let* ((cur-hour(string-to-int |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
505 (substring (current-time-string) 11 13))) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
506 (cur-min (string-to-int |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
507 (substring (current-time-string) 14 16))) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
508 (cur-comp-time (+ (* cur-hour 60) cur-min)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
509 (appt-comp-time (car (car (car appt-time-msg-list))))) |
179 | 510 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
511 (while (and appt-time-msg-list (< appt-comp-time cur-comp-time)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
512 (setq appt-time-msg-list (cdr appt-time-msg-list)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
513 (if appt-time-msg-list |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
514 (setq appt-comp-time (car (car (car appt-time-msg-list))))))))) |
179 | 515 |
516 | |
517 ;;Simple sort to put the appointments list in order. | |
518 ;;Scan the list for the smallest element left in the list. | |
519 ;;Append the smallest element left into the new list, and remove | |
520 ;;it from the original list. | |
521 (defun appt-sort-list (appt-list) | |
522 (let ((order-list nil)) | |
523 (while appt-list | |
524 (let* ((element (car appt-list)) | |
525 (element-time (car (car element))) | |
526 (tmp-list (cdr appt-list))) | |
527 (while tmp-list | |
528 (if (< element-time (car (car (car tmp-list)))) | |
529 nil | |
530 (setq element (car tmp-list)) | |
531 (setq element-time (car (car element)))) | |
532 (setq tmp-list (cdr tmp-list))) | |
533 (setq order-list (append order-list (list element))) | |
534 (setq appt-list (delq element appt-list)))) | |
535 order-list)) | |
536 | |
537 | |
538 (defun appt-convert-time (time2conv) | |
539 "Convert hour:min[am/pm] format to minutes from midnight." | |
540 | |
541 (let ((conv-time 0) | |
542 (hr 0) | |
543 (min 0)) | |
544 | |
545 (string-match ":[0-9][0-9]" time2conv) | |
546 (setq min (string-to-int | |
547 (substring time2conv | |
548 (+ (match-beginning 0) 1) (match-end 0)))) | |
549 | |
550 (string-match "[0-9]?[0-9]:" time2conv) | |
551 (setq hr (string-to-int | |
552 (substring time2conv | |
553 (match-beginning 0) | |
554 (match-end 0)))) | |
555 | |
556 ;; convert the time appointment time into 24 hour time | |
557 | |
558 (if (and (string-match "[p][m]" time2conv) (< hr 12)) | |
559 (progn | |
560 (string-match "[0-9]?[0-9]:" time2conv) | |
561 (setq hr (+ 12 hr)))) | |
562 | |
563 ;; convert the actual time | |
564 ;; into minutes for comparison | |
565 ;; against the actual time. | |
566 | |
567 (setq conv-time (+ (* hr 60) min)) | |
568 conv-time)) | |
569 | |
6170 | 570 (add-hook 'display-time-hook 'appt-check) |
179 | 571 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
179
diff
changeset
|
572 ;;; appt.el ends here |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
573 |