annotate lisp/calendar/appt.el @ 26436:8d7a976d7700

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