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