annotate lisp/calendar/appt.el @ 17442:eb87aef64274

Doc fixes.
author Richard M. Stallman <rms@gnu.org>
date Mon, 14 Apr 1997 01:40:31 +0000
parents 4942f03c75f8
children 7634c31da26e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4fd40bd394fe Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 6312
diff changeset
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
957444150c1a Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 6170
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; any later version.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13125
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13125
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13125
diff changeset
24 ;; Boston, MA 02111-1307, USA.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;; appt.el - visible and/or audible notification of
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ;; appointments from ~/diary file generated from
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;; Edward M. Reingold's calendar.el.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ;; Comments, corrections, and improvements should be sent to
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;; Neil M. Mager
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;; Net <neilm@juliet.ll.mit.edu>
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ;; Voice (617) 981-4803
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 ;;; Thanks to Edward M. Reingold for much help and many suggestions,
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 ;;; And to many others for bug fixes and suggestions.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 ;;; This functions in this file will alert the user of a
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 ;;; pending appointment based on their diary file.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 ;;; ******* It is necessary to invoke 'display-time' ********
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 ;;; ******* and 'diary' for this to work properly. ********
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 ;;; A message will be displayed in the mode line of the emacs buffer
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 ;;; and (if the user desires) the terminal will beep and display a message
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 ;;; from the diary in the mini-buffer, or the user may select to
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 ;;; have a message displayed in a new buffer.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 ;;; The variable 'appt-message-warning-time' allows the
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 ;;; user to specify how much notice they want before the appointment. The
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 ;;; variable 'appt-issue-message' specifies whether the user wants
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 ;;; to to be notified of a pending appointment.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 ;;; In order to use, the following should be in your .emacs file in addition to
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 ;;; creating a diary file and invoking calendar:
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 ;;; Set some options
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 ;;; (setq view-diary-entries-initially t)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 ;;; (setq appt-issue-message t)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 ;;; The following three lines are required:
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 ;;; (display-time)
6312
b55a8ce60e85 Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6222
diff changeset
69 ;;; (add-hook 'diary-hook 'appt-make-list)
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 ;;; This is an example of what can be in your diary file:
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 ;;; Monday
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 ;;; 9:30am Coffee break
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 ;;; 12:00pm Lunch
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 ;;; Based upon the above lines in your .emacs and diary files,
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 ;;; the calendar and diary will be displayed when you enter
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 ;;; emacs and your appointments list will automatically be created.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 ;;; You will then be reminded at 9:20am about your coffee break
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 ;;; and at 11:50am to go to lunch.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 ;;; Use describe-function on appt-check for a description of other variables
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 ;;; that can be used to personalize the notification system.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 ;;; In order to add or delete items from todays list, use appt-add
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 ;;; and appt-delete.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 ;;; Additionally, the appointments list is recreated automatically
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 ;;; at 12:01am for those who do not logout every day or are programming
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 ;;; late.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 ;;; Brief internal description - Skip this if your not interested!
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 ;;; The function appt-check is run from the 'loadst' process which is started
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 ;;; by invoking (display-time). A temporary function below modifies
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 ;;; display-time-filter
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 ;;; (from original time.el) to include a hook which will invoke appt-check.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 ;;; This will not be necessary in the next version of gnuemacs.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 ;;;
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 ;;; The function appt-make-list creates the appointments list which appt-check
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 ;;; reads. This is all done automatically.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 ;;; It is invoked from the function list-diary-entries.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 ;;;
5659
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
106 ;;; You can change the way the appointment window is created/deleted by
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
107 ;;; setting the variables
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
108 ;;;
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
109 ;;; appt-disp-window-function
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
110 ;;; and
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
111 ;;; appt-delete-window-function
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
112 ;;;
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
113 ;;; For instance, these variables can be set to functions that display
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
114 ;;; appointments in pop-up frames, which are lowered or iconified after
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
115 ;;; appt-display-interval seconds.
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
116 ;;;
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 777
diff changeset
117
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 777
diff changeset
118 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 777
diff changeset
119
8500
1e2396756604 Require calendar.
Richard M. Stallman <rms@gnu.org>
parents: 8493
diff changeset
120 ;; Make sure calendar is loaded when we compile this.
1e2396756604 Require calendar.
Richard M. Stallman <rms@gnu.org>
parents: 8493
diff changeset
121 (require 'calendar)
1e2396756604 Require calendar.
Richard M. Stallman <rms@gnu.org>
parents: 8493
diff changeset
122
12549
f92983da3dfd Add provide.
Karl Heuer <kwzh@gnu.org>
parents: 11592
diff changeset
123 (provide 'appt)
f92983da3dfd Add provide.
Karl Heuer <kwzh@gnu.org>
parents: 11592
diff changeset
124
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 927
diff changeset
125 ;;;###autoload
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (defvar appt-issue-message t
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 "*Non-nil means check for appointments in the diary buffer.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 To be detected, the diary entry must have the time
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 as the first thing on a line.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 927
diff changeset
131 ;;;###autoload
5714
9f37f85000d8 (appt-display-interval, appt-display-duration)
Richard M. Stallman <rms@gnu.org>
parents: 5668
diff changeset
132 (defvar appt-message-warning-time 12
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 "*Time in minutes before an appointment that the warning begins.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 927
diff changeset
135 ;;;###autoload
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (defvar appt-audible t
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 "*Non-nil means beep to indicate appointment.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 927
diff changeset
139 ;;;###autoload
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (defvar appt-visible t
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 "*Non-nil means display appointment message in echo area.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 927
diff changeset
143 ;;;###autoload
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (defvar appt-display-mode-line t
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 "*Non-nil means display minutes to appointment and time on the mode line.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 927
diff changeset
147 ;;;###autoload
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (defvar appt-msg-window t
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 "*Non-nil means display appointment message in another window.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 927
diff changeset
151 ;;;###autoload
5714
9f37f85000d8 (appt-display-interval, appt-display-duration)
Richard M. Stallman <rms@gnu.org>
parents: 5668
diff changeset
152 (defvar appt-display-duration 10
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 "*The number of seconds an appointment message is displayed.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 927
diff changeset
155 ;;;###autoload
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (defvar appt-display-diary t
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 "*Non-nil means to display the next days diary on the screen.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 This will occur at midnight when the appointment list is updated.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (defvar appt-time-msg-list nil
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 "The list of appointments for today.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 Use `appt-add' and `appt-delete' to add and delete appointments from list.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 The original list is generated from the today's `diary-entries-list'.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 The number before each time/message is the time in minutes from midnight.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (defconst max-time 1439
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 "11:59pm in minutes - number of minutes in a day minus 1.")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168
5714
9f37f85000d8 (appt-display-interval, appt-display-duration)
Richard M. Stallman <rms@gnu.org>
parents: 5668
diff changeset
169 (defvar appt-display-interval 3
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
170 "*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
171
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
172 (defvar appt-buffer-name " *appt-buf*"
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
173 "Name of the appointments buffer.")
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-disp-window-function 'appt-disp-window
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
176 "Function called to display appointment window.")
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
177
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
178 (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
179 "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
180
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 (defun appt-check ()
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 "Check for an appointment and update the mode line.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 Note: the time must be the first thing in the line in the diary
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 for a warning to be issued.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 The format of the time can be either 24 hour or am/pm.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 Example:
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 02/23/89
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 18:00 Dinner
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 Thursday
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 11:45am Lunch meeting.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 The following variables control the action of the notification:
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 appt-issue-message
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
198 If T, the diary buffer is checked for appointments.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 appt-message-warning-time
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
201 Variable used to determine if appointment message
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
202 should be displayed.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 appt-audible
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
205 Variable used to determine if appointment is audible.
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
206 Default is t.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 appt-visible
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
209 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
210 displayed in the mini-buffer. Default is t.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 appt-msg-window
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
213 Variable used to determine if appointment message
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
214 should temporarily appear in another window. Mutually exclusive
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
215 to appt-visible.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 appt-display-duration
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
218 The number of seconds an appointment message
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
219 is displayed in another window.
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
220
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
221 appt-display-interval
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
222 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
223 list.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224
5668
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
225 appt-disp-window-function
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
226 Function called to display appointment window. You can customize
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
227 appt.el by setting this variable to a function different from the
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
228 one provided with this package.
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
229
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
230 appt-delete-window-function
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
231 Function called to remove appointment window and buffer. You can
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
232 customize appt.el by setting this variable to a function different
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
233 from the one provided with this package.
139b23d6a97b (appt-check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5659
diff changeset
234
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 This function is run from the loadst process for display time.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 Therefore, you need to have `(display-time)' in your .emacs file."
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
239 (if (or (= appt-display-interval 1)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
240 ;; This is true every appt-display-interval minutes.
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
241 (= 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
242 (let ((min-to-app -1)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
243 (new-time ""))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
244 (save-excursion
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 ;; 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
247 ;; from midnight. ie. 12:01am = 1, midnight = 0.
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
248
15679
4942f03c75f8 (appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
249 (let* ((now (decode-time))
4942f03c75f8 (appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
250 (cur-hour (nth 2 now))
4942f03c75f8 (appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
251 (cur-min (nth 1 now))
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
252 (cur-comp-time (+ (* cur-hour 60) cur-min)))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
253
8493
2bf3f2e9f107 (appt-check): Update on first wakeup after midnight
Richard M. Stallman <rms@gnu.org>
parents: 8440
diff changeset
254 ;; 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
255 ;; appointments to today's list.
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
256
8493
2bf3f2e9f107 (appt-check): Update on first wakeup after midnight
Richard M. Stallman <rms@gnu.org>
parents: 8440
diff changeset
257 (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
258 (<= cur-comp-time appt-display-interval))
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
259 (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
260 (diary)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
261 (let ((diary-display-hook 'appt-make-list))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
262 (diary))))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
263
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
264 ;; 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
265 ;; user wants a message issued
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
266 ;; get the first time off of the list
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
267 ;; and calculate the number of minutes until
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
268 ;; the appointment.
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
269
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
270 (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
271 (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
272 (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
273
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
274 (while (and appt-time-msg-list
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
275 (< appt-comp-time cur-comp-time))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
276 (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
277 (if appt-time-msg-list
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
278 (setq appt-comp-time
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
279 (car (car (car appt-time-msg-list))))))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
280
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
281 ;; If we have an appointment between midnight and
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
282 ;; 'appt-message-warning-time' minutes after midnight,
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
283 ;; 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
284 ;; 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
285 ;; 1439 minutes. Therefore we must recalculate the minutes
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
286 ;; 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
287 ;; minutes before midnight plus the number of
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
288 ;; minutes after midnight our appointment is.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
290 (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
291 (> (+ cur-comp-time appt-message-warning-time)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
292 max-time))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
293 (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
294 appt-comp-time))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
295
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
296 ;; issue warning if the appointment time is
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
297 ;; within appt-message-warning time
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
298
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
299 (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
300 (>= min-to-app 0))
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 (if appt-msg-window
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
303 (progn
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
304 (string-match
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
305 "[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
306 display-time-string)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
307
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
308 (setq new-time (substring display-time-string
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
309 (match-beginning 0)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
310 (match-end 0)))
5659
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
311 (funcall
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
312 appt-disp-window-function
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
313 min-to-app new-time
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
314 (car (cdr (car appt-time-msg-list))))
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
315
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
316 (run-at-time
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
317 (format "%d sec" appt-display-duration)
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
318 nil
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
319 appt-delete-window-function))
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
320 ;;; else
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
321
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
322 (if appt-visible
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
323 (message "%s"
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
324 (car (cdr (car appt-time-msg-list)))))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
325
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
326 (if appt-audible
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
327 (beep 1)))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
328
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
329 (if appt-display-mode-line
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
330 (progn
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
331 (string-match
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
332 "[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
333 display-time-string)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
334
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
335 (setq new-time (substring display-time-string
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
336 (match-beginning 0)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
337 (match-end 0)))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
338 (setq display-time-string
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
339 (concat "App't in "
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
340 min-to-app " min. " new-time " "))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
341
11592
030e5a06a38a (appt-check): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents: 9551
diff changeset
342 (force-mode-line-update t)
5034
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
343 (sit-for 0)))
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
344
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
345 (if (= min-to-app 0)
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
346 (setq appt-time-msg-list
c7badee38b64 (appt-display-interval): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
347 (cdr appt-time-msg-list))))))))))))
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 ;; Display appointment message in a separate buffer.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (defun appt-disp-window (min-to-app new-time appt-msg)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (require 'electric)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353
5659
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
354 ;; 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
355 ;; before splitting the window.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356
5659
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
357 (if (equal (selected-window) (minibuffer-window))
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
358 (if (other-window 1)
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
359 (select-window (other-window 1))
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
360 (if window-system
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
361 (select-frame (other-frame 1)))))
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
362
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
363 (let* ((this-buffer (current-buffer))
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
364 (this-window (selected-window))
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
365 (appt-disp-buf (set-buffer (get-buffer-create appt-buffer-name))))
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366
5659
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
367 (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
368 (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
369 ;; 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
370 (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
371 ;; 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
372 (split-window)
e54eede71446 (appt-delete-window): Look on all frames for the window.
Richard M. Stallman <rms@gnu.org>
parents: 8500
diff changeset
373 (pop-to-buffer appt-disp-buf))
5659
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
374 (setq mode-line-format
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
375 (concat "-------------------- Appointment in "
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
376 min-to-app " minutes. " new-time " %-"))
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
377 (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
378 (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
379 (set-buffer-modified-p nil)
13125
731ef06c5677 (appt-disp-window): Call raise-frame.
Richard M. Stallman <rms@gnu.org>
parents: 12549
diff changeset
380 (raise-frame (selected-frame))
5659
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
397 ;; Select the lowest window on the frame.
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (last-window (previous-window))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (window-search t))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 (while window-search
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 (let* ((this-window (next-window))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (next-bottom-edge (car (cdr (cdr (cdr
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 (window-edges this-window)))))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 (if (< bottom-edge next-bottom-edge)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 (progn
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 (setq bottom-edge next-bottom-edge)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (setq lowest-window this-window)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (select-window this-window)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (if (eq last-window this-window)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (progn
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (select-window lowest-window)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (setq window-search nil)))))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (defun appt-add (new-appt-time new-appt-msg)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 "Add an appointment for the day at TIME and issue MESSAGE.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 The time should be in either 24 hour format or am/pm format."
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 (interactive "sTime (hh:mm[am/pm]): \nsMessage: ")
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (if (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" new-appt-time)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 nil
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (error "Unacceptable time-string"))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 (let* ((appt-time-string (concat new-appt-time " " new-appt-msg))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (appt-time (list (appt-convert-time new-appt-time)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (time-msg (cons appt-time (list appt-time-string))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (setq appt-time-msg-list (append appt-time-msg-list
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (list time-msg)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (setq appt-time-msg-list (appt-sort-list appt-time-msg-list))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 (defun appt-delete ()
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 "Delete an appointment from the list of appointments."
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (interactive)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 (let* ((tmp-msg-list appt-time-msg-list))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (while tmp-msg-list
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (let* ((element (car tmp-msg-list))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 (prompt-string (concat "Delete "
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 (prin1-to-string (car (cdr element)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 " from list? "))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (test-input (y-or-n-p prompt-string)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (setq tmp-msg-list (cdr tmp-msg-list))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (message "")))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 ;; Create the appointments list from todays diary buffer.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 ;; The time must be at the beginning of a line for it to be
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 ;; put in the appointments list.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 ;; 02/23/89
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 ;; 12:00pm lunch
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461
927
587a08c3a70b *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
462 ;;;###autoload
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
15679
4942f03c75f8 (appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
532 (let* ((now (decode-time))
4942f03c75f8 (appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
533 (cur-hour (nth 2 now))
4942f03c75f8 (appt-check, appt-make-list): Avoid race condition
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
534 (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
535 (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
536 (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
537
863e05092c58 (appt-make-list): Do nothing unless range being processed
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
538 (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
539 (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
540 (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
541 (setq appt-comp-time (car (car (car appt-time-msg-list))))))))))
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 ;;Simple sort to put the appointments list in order.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 ;;Scan the list for the smallest element left in the list.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 ;;Append the smallest element left into the new list, and remove
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 ;;it from the original list.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 (defun appt-sort-list (appt-list)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (let ((order-list nil))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 (while appt-list
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (let* ((element (car appt-list))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 (element-time (car (car element)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (tmp-list (cdr appt-list)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 (while tmp-list
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 (if (< element-time (car (car (car tmp-list))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 nil
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (setq element (car tmp-list))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 (setq element-time (car (car element))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (setq tmp-list (cdr tmp-list)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (setq order-list (append order-list (list element)))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (setq appt-list (delq element appt-list))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 order-list))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 (defun appt-convert-time (time2conv)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 "Convert hour:min[am/pm] format to minutes from midnight."
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 (let ((conv-time 0)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 (hr 0)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 (min 0))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 (string-match ":[0-9][0-9]" time2conv)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (setq min (string-to-int
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 (substring time2conv
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 (+ (match-beginning 0) 1) (match-end 0))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 (string-match "[0-9]?[0-9]:" time2conv)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 (setq hr (string-to-int
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 (substring time2conv
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 (match-beginning 0)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 (match-end 0))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 ;; convert the time appointment time into 24 hour time
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (if (and (string-match "[p][m]" time2conv) (< hr 12))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (progn
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 (string-match "[0-9]?[0-9]:" time2conv)
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 (setq hr (+ 12 hr))))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 ;; convert the actual time
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 ;; into minutes for comparison
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 ;; against the actual time.
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (setq conv-time (+ (* hr 60) min))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 conv-time))
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596
6170
9a33af7247e2 Use add-hook instead of setq.
Karl Heuer <kwzh@gnu.org>
parents: 5714
diff changeset
597 (add-hook 'display-time-hook 'appt-check)
179
b88e2c9f0f5b Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 179
diff changeset
599 ;;; appt.el ends here
5659
32a02ab40d58 (appt-check): Use the new variables
Richard M. Stallman <rms@gnu.org>
parents: 5034
diff changeset
600