Mercurial > emacs
annotate lisp/calendar/appt.el @ 52149:9928a29a3e80
(Library Headers): Explain where to put -*-.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 06 Aug 2003 01:42:44 +0000 |
parents | 0d8b17d428b5 |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
30538
diff
changeset
|
1 ;;; appt.el --- appointment notification functions |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
179
diff
changeset
|
2 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
3 ;; Copyright (C) 1989, 1990, 1994, 1998 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 | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
179 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
26 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
27 |
179 | 28 ;; |
29 ;; appt.el - visible and/or audible notification of | |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
30 ;; appointments from ~/diary file. |
179 | 31 ;; |
32 ;;; | |
28404 | 33 ;;; Thanks to Edward M. Reingold for much help and many suggestions, |
179 | 34 ;;; And to many others for bug fixes and suggestions. |
35 ;;; | |
36 ;;; | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
37 ;;; This functions in this file will alert the user of a |
179 | 38 ;;; pending appointment based on their diary file. |
39 ;;; | |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
40 ;;; A message will be displayed in the mode line of the Emacs buffer |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
41 ;;; and (if you request) the terminal will beep and display a message |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
42 ;;; from the diary in the mini-buffer, or you can choose to |
179 | 43 ;;; have a message displayed in a new buffer. |
44 ;;; | |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
45 ;;; The variable `appt-message-warning-time' allows the |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
46 ;;; user to specify how much notice they want before the appointment. The |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
47 ;;; variable `appt-issue-message' specifies whether the user wants |
46163 | 48 ;;; to be notified of a pending appointment. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
49 ;;; |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
50 ;;; In order to use the appt package, you only need |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
51 ;;; to load it---provided you have appointments. |
179 | 52 ;;; |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
53 ;;; Before that, you can also set some options if you want |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
54 ;;; (setq view-diary-entries-initially t) |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
55 ;;; (setq appt-issue-message t) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
56 ;;; |
179 | 57 ;;; This is an example of what can be in your diary file: |
58 ;;; Monday | |
59 ;;; 9:30am Coffee break | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
60 ;;; 12:00pm Lunch |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
61 ;;; |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
62 ;;; Based upon the above lines in your .emacs and diary files, |
179 | 63 ;;; the calendar and diary will be displayed when you enter |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
64 ;;; Emacs and your appointments list will automatically be created. |
179 | 65 ;;; You will then be reminded at 9:20am about your coffee break |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
66 ;;; and at 11:50am to go to lunch. |
179 | 67 ;;; |
68 ;;; Use describe-function on appt-check for a description of other variables | |
69 ;;; that can be used to personalize the notification system. | |
70 ;;; | |
71 ;;; In order to add or delete items from todays list, use appt-add | |
72 ;;; and appt-delete. | |
73 ;;; | |
74 ;;; Additionally, the appointments list is recreated automatically | |
75 ;;; at 12:01am for those who do not logout every day or are programming | |
76 ;;; late. | |
77 ;;; | |
28404 | 78 ;;; Brief internal description - Skip this if you are not interested! |
179 | 79 ;;; |
80 ;;; The function appt-make-list creates the appointments list which appt-check | |
81 ;;; reads. This is all done automatically. | |
82 ;;; It is invoked from the function list-diary-entries. | |
83 ;;; | |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
84 ;;; 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
|
85 ;;; setting the variables |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
86 ;;; |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
87 ;;; appt-disp-window-function |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
88 ;;; and |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
89 ;;; appt-delete-window-function |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
90 ;;; |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
91 ;;; 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
|
92 ;;; appointments in pop-up frames, which are lowered or iconified after |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
93 ;;; appt-display-interval minutes. |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
94 ;;; |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
95 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
96 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
97 |
8500 | 98 ;; Make sure calendar is loaded when we compile this. |
99 (require 'calendar) | |
100 | |
12549 | 101 (provide 'appt) |
102 | |
957 | 103 ;;;###autoload |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
104 (defcustom appt-issue-message t |
179 | 105 "*Non-nil means check for appointments in the diary buffer. |
106 To be detected, the diary entry must have the time | |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
107 as the first thing on a line." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
108 :type 'boolean |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
109 :group 'appt) |
179 | 110 |
957 | 111 ;;;###autoload |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
112 (defcustom appt-message-warning-time 12 |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
113 "*Time in minutes before an appointment that the warning begins." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
114 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
115 :group 'appt) |
179 | 116 |
957 | 117 ;;;###autoload |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
118 (defcustom appt-audible t |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
119 "*Non-nil means beep to indicate appointment." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
120 :type 'boolean |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
121 :group 'appt) |
179 | 122 |
957 | 123 ;;;###autoload |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
124 (defcustom appt-visible t |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
125 "*Non-nil means display appointment message in echo area." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
126 :type 'boolean |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
127 :group 'appt) |
179 | 128 |
957 | 129 ;;;###autoload |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
130 (defcustom appt-display-mode-line t |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
131 "*Non-nil means display minutes to appointment and time on the mode line." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
132 :type 'boolean |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
133 :group 'appt) |
179 | 134 |
957 | 135 ;;;###autoload |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
136 (defcustom appt-msg-window t |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
137 "*Non-nil means display appointment message in another window." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
138 :type 'boolean |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
139 :group 'appt) |
179 | 140 |
957 | 141 ;;;###autoload |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
142 (defcustom appt-display-duration 10 |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
143 "*The number of seconds an appointment message is displayed." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
144 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
145 :group 'appt) |
179 | 146 |
957 | 147 ;;;###autoload |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
148 (defcustom appt-display-diary t |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
149 "*Non-nil means to display the next days diary on the screen. |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
150 This will occur at midnight when the appointment list is updated." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
151 :type 'boolean |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
152 :group 'appt) |
179 | 153 |
154 (defvar appt-time-msg-list nil | |
155 "The list of appointments for today. | |
156 Use `appt-add' and `appt-delete' to add and delete appointments from list. | |
157 The original list is generated from the today's `diary-entries-list'. | |
158 The number before each time/message is the time in minutes from midnight.") | |
159 | |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
160 (defconst appt-max-time 1439 |
179 | 161 "11:59pm in minutes - number of minutes in a day minus 1.") |
162 | |
17624
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
163 (defcustom appt-display-interval 3 |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
164 "*Number of minutes to wait between checking the appointment list." |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
165 :type 'integer |
7634c31da26e
Add defgroup and use defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
15679
diff
changeset
|
166 :group 'appt) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
167 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
168 (defvar appt-buffer-name " *appt-buf*" |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
169 "Name of the appointments buffer.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
170 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
171 (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
|
172 "Function called to display appointment window.") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
173 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
174 (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
|
175 "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
|
176 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
177 (defvar appt-mode-string nil |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
178 "String being displayed in the mode line saying you have an appointment. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
179 The actual string includes the amount of time till the appointment.") |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
180 |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
181 (defvar appt-prev-comp-time nil |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
182 "Time of day (mins since midnight) at which we last checked appointments.") |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
183 |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
184 (defvar appt-now-displayed nil |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
185 "Non-nil when we have started notifying about a appointment that is near.") |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
186 |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
187 (defvar appt-display-count nil) |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
188 |
179 | 189 (defun appt-check () |
190 "Check for an appointment and update the mode line. | |
191 Note: the time must be the first thing in the line in the diary | |
192 for a warning to be issued. | |
193 | |
194 The format of the time can be either 24 hour or am/pm. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
195 Example: |
179 | 196 |
197 02/23/89 | |
198 18:00 Dinner | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
199 |
179 | 200 Thursday |
201 11:45am Lunch meeting. | |
202 | |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
203 Appointments are checked every `appt-display-interval' minutes. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
204 The following variables control appointment notification: |
179 | 205 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
206 `appt-issue-message' |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
207 If t, the diary buffer is checked for appointments. |
179 | 208 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
209 `appt-message-warning-time' |
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 be displayed. |
179 | 212 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
213 `appt-audible' |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
214 Variable used to determine if appointment is audible. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
215 Default is t. |
179 | 216 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
217 `appt-visible' |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
218 Variable used to determine if appointment message should be |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
219 displayed in the mini-buffer. Default is t. |
179 | 220 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
221 `appt-msg-window' |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
222 Variable used to determine if appointment message |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
223 should temporarily appear in another window. Mutually exclusive |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
224 to `appt-visible'. |
179 | 225 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
226 `appt-display-duration' |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
227 The number of seconds an appointment message |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
228 is displayed in another window. |
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
229 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
230 `appt-disp-window-function' |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
231 Function called to display appointment window. You can customize |
5668 | 232 appt.el by setting this variable to a function different from the |
233 one provided with this package. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
234 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
235 `appt-delete-window-function' |
5668 | 236 Function called to remove appointment window and buffer. You can |
237 customize appt.el by setting this variable to a function different | |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
238 from the one provided with this package." |
179 | 239 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
240 (let* ((min-to-app -1) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
241 (new-time "") |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
242 (prev-appt-mode-string appt-mode-string) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
243 (prev-appt-display-count (or appt-display-count 0)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
244 ;; Non-nil means do a full check for pending appointments |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
245 ;; and display in whatever ways the user has selected. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
246 ;; When no appointment is being displayed, |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
247 ;; we always do a full check. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
248 (full-check |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
249 (or (not appt-now-displayed) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
250 ;; This is true every appt-display-interval minutes. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
251 (= 0 (mod prev-appt-display-count appt-display-interval)))) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
252 ;; Non-nil means only update the interval displayed in the mode line. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
253 (mode-line-only |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
254 (and (not full-check) appt-now-displayed))) |
179 | 255 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
256 (when (or full-check mode-line-only) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
257 (save-excursion |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
258 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
259 ;; Get the current time and convert it to minutes |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
260 ;; from midnight. ie. 12:01am = 1, midnight = 0. |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
261 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
262 (let* ((now (decode-time)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
263 (cur-hour (nth 2 now)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
264 (cur-min (nth 1 now)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
265 (cur-comp-time (+ (* cur-hour 60) cur-min))) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
266 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
267 ;; At the first check in any given day, update our |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
268 ;; appointments to today's list. |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
269 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
270 (if (or (null appt-prev-comp-time) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
271 (< cur-comp-time appt-prev-comp-time)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
272 (condition-case nil |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
273 (progn |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
274 (if (and view-diary-entries-initially appt-display-diary) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
275 (diary) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
276 (let ((diary-display-hook 'appt-make-list)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
277 (diary)))) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
278 (error nil))) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
279 (setq appt-prev-comp-time cur-comp-time) |
23124
176e4901705d
(appt-check): Clear appt-mode-string if we don't put something in it.
Karl Heuer <kwzh@gnu.org>
parents:
23123
diff
changeset
|
280 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
281 (setq appt-mode-string nil) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
282 (setq appt-display-count nil) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
283 |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
284 ;; If there are entries in the list, and the |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
285 ;; user wants a message issued, |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
286 ;; get the first time off of the list |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
287 ;; and calculate the number of minutes until the appointment. |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
288 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
289 (if (and appt-issue-message appt-time-msg-list) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
290 (let ((appt-comp-time (car (car (car appt-time-msg-list))))) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
291 (setq min-to-app (- appt-comp-time cur-comp-time)) |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
292 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
293 (while (and appt-time-msg-list |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
294 (< appt-comp-time cur-comp-time)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
295 (setq appt-time-msg-list (cdr appt-time-msg-list)) |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
296 (if appt-time-msg-list |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
297 (setq appt-comp-time |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
298 (car (car (car appt-time-msg-list)))))) |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
299 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
300 ;; If we have an appointment between midnight and |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
301 ;; 'appt-message-warning-time' minutes after midnight, |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
302 ;; we must begin to issue a message before midnight. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
303 ;; Midnight is considered 0 minutes and 11:59pm is |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
304 ;; 1439 minutes. Therefore we must recalculate the minutes |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
305 ;; to appointment variable. It is equal to the number of |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
306 ;; minutes before midnight plus the number of |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
307 ;; minutes after midnight our appointment is. |
179 | 308 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
309 (if (and (< appt-comp-time appt-message-warning-time) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
310 (> (+ cur-comp-time appt-message-warning-time) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
311 appt-max-time)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
312 (setq min-to-app (+ (- (1+ appt-max-time) cur-comp-time)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
313 appt-comp-time)) |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
314 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
315 ;; issue warning if the appointment time is |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
316 ;; within appt-message-warning time |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
317 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
318 (when (and (<= min-to-app appt-message-warning-time) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
319 (>= min-to-app 0)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
320 (setq appt-now-displayed t) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
321 (setq appt-display-count |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
322 (1+ prev-appt-display-count)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
323 (unless mode-line-only |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
324 (if appt-msg-window |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
325 (progn |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
326 (setq new-time (format-time-string "%a %b %e " |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
327 (current-time))) |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
328 (funcall |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
329 appt-disp-window-function |
28404 | 330 (number-to-string min-to-app) new-time |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
331 (car (cdr (car appt-time-msg-list)))) |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
332 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
333 (run-at-time |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
334 (format "%d sec" appt-display-duration) |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
335 nil |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
336 appt-delete-window-function)) |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
337 ;;; else |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
338 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
339 (if appt-visible |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
340 (message "%s" |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
341 (car (cdr (car appt-time-msg-list))))) |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
342 |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
343 (if appt-audible |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
344 (beep 1)))) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
345 |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
346 (when appt-display-mode-line |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
347 (setq appt-mode-string |
28404 | 348 (concat " App't in " |
349 (number-to-string min-to-app) | |
350 " min. "))) | |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
351 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
352 ;; When an appointment is reached, |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
353 ;; delete it from the list. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
354 ;; Reset the count to 0 in case we display another |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
355 ;; appointment on the next cycle. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
356 (if (= min-to-app 0) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
357 (setq appt-time-msg-list |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
358 (cdr appt-time-msg-list) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
359 appt-display-count nil))))) |
5034
c7badee38b64
(appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
957
diff
changeset
|
360 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
361 ;; If we have changed the mode line string, |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
362 ;; redisplay all mode lines. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
363 (and appt-display-mode-line |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
364 (not (equal appt-mode-string |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
365 prev-appt-mode-string)) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
366 (progn |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
367 (force-mode-line-update t) |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
368 ;; If the string now has a notification, |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
369 ;; redisplay right now. |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
370 (if appt-mode-string |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
371 (sit-for 0))))))))) |
179 | 372 |
373 | |
374 (defun appt-disp-window (min-to-app new-time appt-msg) | |
28404 | 375 "Display appointment message APPT-MSG in a separate buffer." |
179 | 376 (require 'electric) |
377 | |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
378 ;; 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
|
379 ;; before splitting the window. |
179 | 380 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
381 (if (equal (selected-window) (minibuffer-window)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
382 (if (other-window 1) |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
383 (select-window (other-window 1)) |
30538
c44ca494d993
(appt-disp-window): Use display-multi-frame-p
Eli Zaretskii <eliz@gnu.org>
parents:
30001
diff
changeset
|
384 (if (display-multi-frame-p) |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
385 (select-frame (other-frame 1))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
386 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
387 (let* ((this-buffer (current-buffer)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
388 (this-window (selected-window)) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
389 (appt-disp-buf (set-buffer (get-buffer-create appt-buffer-name)))) |
179 | 390 |
9413
e54eede71446
(appt-delete-window): Look on all frames for the window.
Richard M. Stallman <rms@gnu.org>
parents:
8500
diff
changeset
|
391 (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
|
392 ;; 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
|
393 (display-buffer appt-disp-buf) |
23777
5d10105c2906
(appt-disp-window): Use pop-to-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
23297
diff
changeset
|
394 (unless (or (special-display-p (buffer-name appt-disp-buf)) |
5d10105c2906
(appt-disp-window): Use pop-to-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
23297
diff
changeset
|
395 (same-window-p (buffer-name appt-disp-buf))) |
5d10105c2906
(appt-disp-window): Use pop-to-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
23297
diff
changeset
|
396 ;; By default, split the bottom window and use the lower part. |
5d10105c2906
(appt-disp-window): Use pop-to-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
23297
diff
changeset
|
397 (appt-select-lowest-window) |
5d10105c2906
(appt-disp-window): Use pop-to-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
23297
diff
changeset
|
398 (split-window)) |
9413
e54eede71446
(appt-delete-window): Look on all frames for the window.
Richard M. Stallman <rms@gnu.org>
parents:
8500
diff
changeset
|
399 (pop-to-buffer appt-disp-buf)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
400 (setq mode-line-format |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
401 (concat "-------------------- Appointment in " |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
402 min-to-app " minutes. " new-time " %-")) |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
403 (erase-buffer) |
41565
6ecdf9c3fd25
(appt-disp-window): Use insert instead of insert-string.
Pavel Janík <Pavel@Janik.cz>
parents:
38412
diff
changeset
|
404 (insert appt-msg) |
9413
e54eede71446
(appt-delete-window): Look on all frames for the window.
Richard M. Stallman <rms@gnu.org>
parents:
8500
diff
changeset
|
405 (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
|
406 (set-buffer-modified-p nil) |
13125
731ef06c5677
(appt-disp-window): Call raise-frame.
Richard M. Stallman <rms@gnu.org>
parents:
12549
diff
changeset
|
407 (raise-frame (selected-frame)) |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
408 (select-window this-window) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
409 (if appt-audible |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
410 (beep 1)))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
411 |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
412 (defun appt-delete-window () |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
413 "Function called to undisplay appointment messages. |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
414 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
|
415 (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
|
416 (and window |
28404 | 417 (or (eq window (frame-root-window (window-frame window))) |
9551
ac21ac5e8c69
(appt-select-lowest-window): Locally bind lowest-window.
Richard M. Stallman <rms@gnu.org>
parents:
9413
diff
changeset
|
418 (delete-window window)))) |
5659
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
419 (kill-buffer appt-buffer-name) |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
420 (if appt-audible |
32a02ab40d58
(appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents:
5034
diff
changeset
|
421 (beep 1))) |
179 | 422 |
423 (defun appt-select-lowest-window () | |
28404 | 424 "Select the lowest window on the frame." |
30001
55656f797f82
(appt-select-lowest-window): Use walk-windows
Gerd Moellmann <gerd@gnu.org>
parents:
28968
diff
changeset
|
425 (let ((lowest-window (selected-window)) |
55656f797f82
(appt-select-lowest-window): Use walk-windows
Gerd Moellmann <gerd@gnu.org>
parents:
28968
diff
changeset
|
426 (bottom-edge (nth 3 (window-edges)))) |
55656f797f82
(appt-select-lowest-window): Use walk-windows
Gerd Moellmann <gerd@gnu.org>
parents:
28968
diff
changeset
|
427 (walk-windows (lambda (w) |
55656f797f82
(appt-select-lowest-window): Use walk-windows
Gerd Moellmann <gerd@gnu.org>
parents:
28968
diff
changeset
|
428 (let ((next-bottom-edge (nth 3 (window-edges w)))) |
55656f797f82
(appt-select-lowest-window): Use walk-windows
Gerd Moellmann <gerd@gnu.org>
parents:
28968
diff
changeset
|
429 (when (< bottom-edge next-bottom-edge) |
55656f797f82
(appt-select-lowest-window): Use walk-windows
Gerd Moellmann <gerd@gnu.org>
parents:
28968
diff
changeset
|
430 (setq bottom-edge next-bottom-edge |
55656f797f82
(appt-select-lowest-window): Use walk-windows
Gerd Moellmann <gerd@gnu.org>
parents:
28968
diff
changeset
|
431 lowest-window w))))) |
55656f797f82
(appt-select-lowest-window): Use walk-windows
Gerd Moellmann <gerd@gnu.org>
parents:
28968
diff
changeset
|
432 (select-window lowest-window))) |
179 | 433 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
434 ;;;###autoload |
179 | 435 (defun appt-add (new-appt-time new-appt-msg) |
28404 | 436 "Add an appointment for the day at NEW-APPT-TIME and issue message NEW-APPT-MSG. |
179 | 437 The time should be in either 24 hour format or am/pm format." |
438 | |
439 (interactive "sTime (hh:mm[am/pm]): \nsMessage: ") | |
440 (if (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" new-appt-time) | |
441 nil | |
442 (error "Unacceptable time-string")) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
443 |
179 | 444 (let* ((appt-time-string (concat new-appt-time " " new-appt-msg)) |
445 (appt-time (list (appt-convert-time new-appt-time))) | |
446 (time-msg (cons appt-time (list appt-time-string)))) | |
28404 | 447 (setq appt-time-msg-list (nconc appt-time-msg-list (list time-msg))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
448 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)))) |
179 | 449 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
450 ;;;###autoload |
179 | 451 (defun appt-delete () |
452 "Delete an appointment from the list of appointments." | |
453 (interactive) | |
454 (let* ((tmp-msg-list appt-time-msg-list)) | |
455 (while tmp-msg-list | |
456 (let* ((element (car tmp-msg-list)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
457 (prompt-string (concat "Delete " |
46909
eb47511f3556
(appt-delete): Use substring-no-properties.
Richard M. Stallman <rms@gnu.org>
parents:
46861
diff
changeset
|
458 ;; We want to quote any doublequotes |
eb47511f3556
(appt-delete): Use substring-no-properties.
Richard M. Stallman <rms@gnu.org>
parents:
46861
diff
changeset
|
459 ;; in the string, as well as put |
eb47511f3556
(appt-delete): Use substring-no-properties.
Richard M. Stallman <rms@gnu.org>
parents:
46861
diff
changeset
|
460 ;; doublequotes around it. |
eb47511f3556
(appt-delete): Use substring-no-properties.
Richard M. Stallman <rms@gnu.org>
parents:
46861
diff
changeset
|
461 (prin1-to-string |
eb47511f3556
(appt-delete): Use substring-no-properties.
Richard M. Stallman <rms@gnu.org>
parents:
46861
diff
changeset
|
462 (substring-no-properties |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
463 (car (cdr element)) 0)) |
179 | 464 " from list? ")) |
465 (test-input (y-or-n-p prompt-string))) | |
466 (setq tmp-msg-list (cdr tmp-msg-list)) | |
467 (if test-input | |
9551
ac21ac5e8c69
(appt-select-lowest-window): Locally bind lowest-window.
Richard M. Stallman <rms@gnu.org>
parents:
9413
diff
changeset
|
468 (setq appt-time-msg-list (delq element appt-time-msg-list))))) |
26677
b6b1fe18ecf5
(appt-convert-time): Handle "12:MMam",
Gerd Moellmann <gerd@gnu.org>
parents:
24493
diff
changeset
|
469 (appt-check) |
179 | 470 (message ""))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
471 |
179 | 472 |
26935
9e0b4a6b5ad2
Bind free variables when compiling.
Dave Love <fx@gnu.org>
parents:
26677
diff
changeset
|
473 (eval-when-compile (defvar number) |
9e0b4a6b5ad2
Bind free variables when compiling.
Dave Love <fx@gnu.org>
parents:
26677
diff
changeset
|
474 (defvar original-date) |
9e0b4a6b5ad2
Bind free variables when compiling.
Dave Love <fx@gnu.org>
parents:
26677
diff
changeset
|
475 (defvar diary-entries-list)) |
927 | 476 ;;;###autoload |
179 | 477 (defun appt-make-list () |
28404 | 478 "Create the appointments list from todays diary buffer. |
479 The time must be at the beginning of a line for it to be | |
480 put in the appointments list. | |
481 02/23/89 | |
482 12:00pm lunch | |
483 Wednesday | |
484 10:00am group meeting | |
485 We assume that the variables DATE and NUMBER | |
486 hold the arguments that `list-diary-entries' received. | |
487 They specify the range of dates that the diary is being processed for." | |
488 | |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
489 ;; 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
|
490 ;; 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
|
491 (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
|
492 (list (calendar-current-date)) |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
493 (list original-date))) |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
494 (calendar-date-compare |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
495 (list (calendar-current-date)) |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
496 (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
|
497 (+ (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
|
498 number))))) |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
499 (save-excursion |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
500 ;; 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
|
501 (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
|
502 (if diary-entries-list |
179 | 503 |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
504 ;; Cycle through the entry-list (diary-entries-list) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
505 ;; looking for entries beginning with a time. If |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
506 ;; 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
|
507 ;; 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
|
508 |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
509 (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
|
510 (new-time-string "")) |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
511 ;; 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
|
512 (while (and entry-list |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
513 (calendar-date-compare |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
514 (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
|
515 (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
|
516 ;; Parse the entries for today. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
517 (while (and entry-list |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
518 (calendar-date-equal |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
519 (calendar-current-date) (car (car entry-list)))) |
46909
eb47511f3556
(appt-delete): Use substring-no-properties.
Richard M. Stallman <rms@gnu.org>
parents:
46861
diff
changeset
|
520 (let ((time-string (cadr (car entry-list)))) |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
521 (while (string-match |
46861
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
522 "\\([0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?\\).*" |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
523 time-string) |
46861
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
524 (let* ((beg (match-beginning 0)) |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
525 ;; Get just the time for this appointment. |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
526 (only-time (match-string 1 time-string)) |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
527 ;; Find the end of this appointment |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
528 ;; (the start of the next). |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
529 (end (string-match |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
530 "^[ \t]*[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
531 time-string |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
532 (match-end 0))) |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
533 ;; Get the whole string for this appointment. |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
534 (appt-time-string |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
535 (substring time-string beg (if end (1- end))))) |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
536 |
46861
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
537 ;; Add this appointment to appt-time-msg-list. |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
538 (let* ((appt-time (list (appt-convert-time only-time))) |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
539 (time-msg (list appt-time appt-time-string))) |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
540 (setq appt-time-msg-list |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
541 (nconc appt-time-msg-list (list time-msg)))) |
179 | 542 |
46861
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
543 ;; Discard this appointment from the string. |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
544 (setq time-string |
0d5d941c3b3e
(appt-make-list): Correct the parsing of each appointment from time-string.
Richard M. Stallman <rms@gnu.org>
parents:
46163
diff
changeset
|
545 (if end (substring time-string end) ""))))) |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
546 (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
|
547 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) |
179 | 548 |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
549 ;; 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
|
550 ;; 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
|
551 ;; 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
|
552 ;; 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
|
553 ;; be removed. |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
554 |
15679
4942f03c75f8
(appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
555 (let* ((now (decode-time)) |
4942f03c75f8
(appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
556 (cur-hour (nth 2 now)) |
4942f03c75f8
(appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
557 (cur-min (nth 1 now)) |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
558 (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
|
559 (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
|
560 |
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
561 (while (and appt-time-msg-list (< appt-comp-time cur-comp-time)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
562 (setq appt-time-msg-list (cdr appt-time-msg-list)) |
8440
863e05092c58
(appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
563 (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
|
564 (setq appt-comp-time (car (car (car appt-time-msg-list)))))))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
565 |
179 | 566 |
567 (defun appt-sort-list (appt-list) | |
28404 | 568 "Simple sort to put the appointments list APPT-LIST in order. |
569 Scan the list for the smallest element left in the list. | |
570 Append the smallest element left into the new list, and remove | |
571 it from the original list." | |
179 | 572 (let ((order-list nil)) |
573 (while appt-list | |
574 (let* ((element (car appt-list)) | |
575 (element-time (car (car element))) | |
576 (tmp-list (cdr appt-list))) | |
577 (while tmp-list | |
578 (if (< element-time (car (car (car tmp-list)))) | |
579 nil | |
580 (setq element (car tmp-list)) | |
581 (setq element-time (car (car element)))) | |
582 (setq tmp-list (cdr tmp-list))) | |
28404 | 583 (setq order-list (nconc order-list (list element))) |
179 | 584 (setq appt-list (delq element appt-list)))) |
585 order-list)) | |
586 | |
587 | |
588 (defun appt-convert-time (time2conv) | |
589 "Convert hour:min[am/pm] format to minutes from midnight." | |
590 | |
591 (let ((conv-time 0) | |
592 (hr 0) | |
593 (min 0)) | |
594 | |
28404 | 595 (string-match ":\\([0-9][0-9]\\)" time2conv) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
596 (setq min (string-to-int |
28404 | 597 (match-string 1 time2conv))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
598 |
179 | 599 (string-match "[0-9]?[0-9]:" time2conv) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
600 (setq hr (string-to-int |
28404 | 601 (match-string 0 time2conv))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
602 |
179 | 603 ;; convert the time appointment time into 24 hour time |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
604 |
26677
b6b1fe18ecf5
(appt-convert-time): Handle "12:MMam",
Gerd Moellmann <gerd@gnu.org>
parents:
24493
diff
changeset
|
605 (cond ((and (string-match "pm" time2conv) (< hr 12)) |
b6b1fe18ecf5
(appt-convert-time): Handle "12:MMam",
Gerd Moellmann <gerd@gnu.org>
parents:
24493
diff
changeset
|
606 (setq hr (+ 12 hr))) |
b6b1fe18ecf5
(appt-convert-time): Handle "12:MMam",
Gerd Moellmann <gerd@gnu.org>
parents:
24493
diff
changeset
|
607 ((and (string-match "am" time2conv) (= hr 12)) |
b6b1fe18ecf5
(appt-convert-time): Handle "12:MMam",
Gerd Moellmann <gerd@gnu.org>
parents:
24493
diff
changeset
|
608 (setq hr 0))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
609 |
179 | 610 ;; convert the actual time |
611 ;; into minutes for comparison | |
612 ;; against the actual time. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46909
diff
changeset
|
613 |
179 | 614 (setq conv-time (+ (* hr 60) min)) |
615 conv-time)) | |
616 | |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
617 (defvar appt-timer nil |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
618 "Timer used for diary appointment notifications (`appt-check').") |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
619 |
23297
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
620 (unless appt-timer |
e23cdc314c10
(appt-interval): Variable deleted.
Karl Heuer <kwzh@gnu.org>
parents:
23124
diff
changeset
|
621 (setq appt-timer (run-at-time t 60 'appt-check))) |
23112
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
622 |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
623 (or global-mode-string (setq global-mode-string '(""))) |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
624 (or (memq 'appt-mode-string global-mode-string) |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
625 (setq global-mode-string |
81052242dbce
(appt-mode-string): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17624
diff
changeset
|
626 (append global-mode-string '(appt-mode-string)))) |
179 | 627 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
179
diff
changeset
|
628 ;;; appt.el ends here |