38422
|
1 ;;; diary-lib.el --- diary functions
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
2
|
67465
|
3 ;; Copyright (C) 1989, 1990, 1992, 1993, 1994, 1995, 2001, 2002, 2003,
|
79703
|
4 ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
5
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
|
65919
|
7 ;; Maintainer: Glenn Morris <rgm@gnu.org>
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
8 ;; Keywords: calendar
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
9
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
11
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by
|
78216
|
14 ;; the Free Software Foundation; either version 3, or (at your option)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
15 ;; any later version.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
16
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful,
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
21
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License
|
14169
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
64085
|
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
25 ;; Boston, MA 02110-1301, USA.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
26
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
27 ;;; Commentary:
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
28
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
29 ;; This collection of functions implements the diary features as described
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
30 ;; in calendar.el.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
31
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
32 ;;; Code:
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
33
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
34 (require 'calendar)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
35
|
51640
|
36 (defun diary-check-diary-file ()
|
|
37 "Check that the file specified by `diary-file' exists and is readable.
|
|
38 If so, return the expanded file name, otherwise signal an error."
|
|
39 (let ((d-file (substitute-in-file-name diary-file)))
|
|
40 (if (and d-file (file-exists-p d-file))
|
|
41 (if (file-readable-p d-file)
|
|
42 d-file
|
|
43 (error "Diary file `%s' is not readable" diary-file))
|
|
44 (error "Diary file `%s' does not exist" diary-file))))
|
|
45
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
46 ;;;###autoload
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
47 (defun diary (&optional arg)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
48 "Generate the diary window for ARG days starting with the current date.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
49 If no argument is provided, the number of days of diary entries is governed
|
53557
|
50 by the variable `number-of-diary-entries'. A value of ARG less than 1
|
|
51 does nothing. This function is suitable for execution in a `.emacs' file."
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
52 (interactive "P")
|
51640
|
53 (diary-check-diary-file)
|
|
54 (let ((date (calendar-current-date)))
|
65476
|
55 (diary-list-entries date (if arg (prefix-numeric-value arg)))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
56
|
65476
|
57 (define-obsolete-function-alias 'view-diary-entries 'diary-view-entries)
|
|
58 (defun diary-view-entries (&optional arg)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
59 "Prepare and display a buffer with diary entries.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
60 Searches the file named in `diary-file' for entries that
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
61 match ARG days starting with the date indicated by the cursor position
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
62 in the displayed three-month calendar."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
63 (interactive "p")
|
51640
|
64 (diary-check-diary-file)
|
65476
|
65 (diary-list-entries (calendar-cursor-to-date t) arg))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
66
|
22412
|
67 (defun view-other-diary-entries (arg d-file)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
68 "Prepare and display buffer of diary entries from an alternative diary file.
|
51640
|
69 Searches for entries that match ARG days, starting with the date indicated
|
|
70 by the cursor position in the displayed three-month calendar.
|
|
71 D-FILE specifies the file to use as the diary file."
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
72 (interactive
|
59043
5ddb0b71254b
(view-other-diary-entries): Use current-prefix-arg in interactive spec.
Glenn Morris <rgm@gnu.org>
diff
changeset
|
73 (list (prefix-numeric-value current-prefix-arg)
|
22412
|
74 (read-file-name "Enter diary file name: " default-directory nil t)))
|
|
75 (let ((diary-file d-file))
|
70183
|
76 (diary-view-entries arg)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
77
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
78 (autoload 'check-calendar-holidays "holidays"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
79 "Check the list of holidays for any that occur on DATE.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
80 The value returned is a list of strings of relevant holiday descriptions.
|
46620
|
81 The holidays are those in the list `calendar-holidays'.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
82
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
83 (autoload 'calendar-holiday-list "holidays"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
84 "Form the list of holidays that occur on dates in the calendar window.
|
46620
|
85 The holidays are those in the list `calendar-holidays'.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
86
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
87 (autoload 'diary-french-date "cal-french"
|
46620
|
88 "French calendar equivalent of date diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
89
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
90 (autoload 'diary-mayan-date "cal-mayan"
|
46620
|
91 "Mayan calendar equivalent of date diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
92
|
13688
|
93 (autoload 'diary-iso-date "cal-iso"
|
46620
|
94 "ISO calendar equivalent of date diary entry.")
|
13688
|
95
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
96 (autoload 'diary-julian-date "cal-julian"
|
46620
|
97 "Julian calendar equivalent of date diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
98
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
99 (autoload 'diary-astro-day-number "cal-julian"
|
46620
|
100 "Astronomical (Julian) day number diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
101
|
14687
|
102 (autoload 'diary-chinese-date "cal-china"
|
46620
|
103 "Chinese calendar equivalent of date diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
104
|
14687
|
105 (autoload 'diary-islamic-date "cal-islam"
|
46620
|
106 "Islamic calendar equivalent of date diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
107
|
14687
|
108 (autoload 'list-islamic-diary-entries "cal-islam"
|
46620
|
109 "Add any Islamic date entries from the diary file to `diary-entries-list'.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
110
|
14687
|
111 (autoload 'mark-islamic-diary-entries "cal-islam"
|
46620
|
112 "Mark days in the calendar window that have Islamic date diary entries.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
113
|
14687
|
114 (autoload 'mark-islamic-calendar-date-pattern "cal-islam"
|
46620
|
115 "Mark dates in calendar window that conform to Islamic date MONTH/DAY/YEAR.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
116
|
55431
|
117 (autoload 'diary-bahai-date "cal-bahai"
|
70728
|
118 "Baha'i calendar equivalent of date diary entry.")
|
55431
|
119
|
|
120 (autoload 'list-bahai-diary-entries "cal-bahai"
|
70728
|
121 "Add any Baha'i date entries from the diary file to `diary-entries-list'.")
|
55431
|
122
|
|
123 (autoload 'mark-bahai-diary-entries "cal-bahai"
|
70728
|
124 "Mark days in the calendar window that have Baha'i date diary entries.")
|
55431
|
125
|
|
126 (autoload 'mark-bahai-calendar-date-pattern "cal-bahai"
|
70728
|
127 "Mark dates in calendar window that conform to Baha'i date MONTH/DAY/YEAR.")
|
55431
|
128
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
129 (autoload 'diary-hebrew-date "cal-hebrew"
|
46620
|
130 "Hebrew calendar equivalent of date diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
131
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
132 (autoload 'diary-omer "cal-hebrew"
|
46620
|
133 "Omer count diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
134
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
135 (autoload 'diary-yahrzeit "cal-hebrew"
|
46620
|
136 "Yahrzeit diary entry--entry applies if date is yahrzeit or the day before.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
137
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
138 (autoload 'diary-parasha "cal-hebrew"
|
46620
|
139 "Parasha diary entry--entry applies if date is a Saturday.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
140
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
141 (autoload 'diary-rosh-hodesh "cal-hebrew"
|
46620
|
142 "Rosh Hodesh diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
143
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
144 (autoload 'list-hebrew-diary-entries "cal-hebrew"
|
46620
|
145 "Add any Hebrew date entries from the diary file to `diary-entries-list'.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
146
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
147 (autoload 'mark-hebrew-diary-entries "cal-hebrew"
|
46620
|
148 "Mark days in the calendar window that have Hebrew date diary entries.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
149
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
150 (autoload 'mark-hebrew-calendar-date-pattern "cal-hebrew"
|
46620
|
151 "Mark dates in calendar window that conform to Hebrew date MONTH/DAY/YEAR.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
152
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
153 (autoload 'diary-coptic-date "cal-coptic"
|
46620
|
154 "Coptic calendar equivalent of date diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
155
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
156 (autoload 'diary-ethiopic-date "cal-coptic"
|
46620
|
157 "Ethiopic calendar equivalent of date diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
158
|
15258
|
159 (autoload 'diary-persian-date "cal-persia"
|
46620
|
160 "Persian calendar equivalent of date diary entry.")
|
14954
|
161
|
46620
|
162 (autoload 'diary-phases-of-moon "lunar" "Moon phases diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
163
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
164 (autoload 'diary-sunrise-sunset "solar"
|
46620
|
165 "Local time of sunrise and sunset as a diary entry.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
166
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
167 (autoload 'diary-sabbath-candles "solar"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
168 "Local time of candle lighting diary entry--applies if date is a Friday.
|
46620
|
169 No diary entry if there is no sunset on that date.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
170
|
65476
|
171 (defvar diary-syntax-table
|
|
172 (let ((st (copy-syntax-table (standard-syntax-table))))
|
|
173 (modify-syntax-entry ?* "w" st)
|
|
174 (modify-syntax-entry ?: "w" st)
|
|
175 st)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
176 "The syntax table used when parsing dates in the diary file.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
177 It is the standard syntax table used in Fundamental mode, but with the
|
51640
|
178 syntax of `*' and `:' changed to be word constituents.")
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
179
|
46826
|
180 (defvar diary-entries-list)
|
|
181 (defvar displayed-year)
|
|
182 (defvar displayed-month)
|
|
183 (defvar entry)
|
|
184 (defvar date)
|
|
185 (defvar number)
|
|
186 (defvar date-string)
|
|
187 (defvar original-date)
|
|
188
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
189 (defun diary-attrtype-convert (attrvalue type)
|
51640
|
190 "Convert string ATTRVALUE to TYPE appropriate for a face description.
|
|
191 Valid TYPEs are: string, symbol, int, stringtnil, tnil."
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
192 (let (ret)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
193 (setq ret (cond ((eq type 'string) attrvalue)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
194 ((eq type 'symbol) (read attrvalue))
|
62402
|
195 ((eq type 'int) (string-to-number attrvalue))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
196 ((eq type 'stringtnil)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
197 (cond ((string= "t" attrvalue) t)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
198 ((string= "nil" attrvalue) nil)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
199 (t attrvalue)))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
200 ((eq type 'tnil)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
201 (cond ((string= "t" attrvalue) t)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
202 ((string= "nil" attrvalue) nil)))))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
203 ; (message "(%s)[%s]=[%s]" (print type) attrvalue ret)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
204 ret))
|
50699
|
205
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
206
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
207 (defun diary-pull-attrs (entry fileglobattrs)
|
50699
|
208 "Pull the face-related attributes off the entry, merge with the
|
|
209 fileglobattrs, and return the (possibly modified) entry and face
|
|
210 data in a list of attrname attrvalue values.
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
211 The entry will be modified to drop all tags that are used for face matching.
|
50699
|
212 If entry is nil, then the fileglobattrs are being searched for,
|
|
213 the fileglobattrs variable is ignored, and
|
|
214 diary-glob-file-regexp-prefix is prepended to the regexps before each
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
215 search."
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
216 (save-excursion
|
50904
|
217 (let (regexp regnum attrname attr-list attrname attrvalue type
|
|
218 ret-attr attr)
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
219 (if (null entry)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
220 (progn
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
221 (setq ret-attr '()
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
222 attr-list diary-face-attrs)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
223 (while attr-list
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
224 (goto-char (point-min))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
225 (setq attr (car attr-list)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
226 regexp (nth 0 attr)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
227 regnum (nth 1 attr)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
228 attrname (nth 2 attr)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
229 type (nth 3 attr)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
230 regexp (concat diary-glob-file-regexp-prefix regexp))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
231 (setq attrvalue nil)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
232 (if (re-search-forward regexp (point-max) t)
|
65476
|
233 (setq attrvalue (match-string-no-properties regnum)))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
234 (if (and attrvalue
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
235 (setq attrvalue (diary-attrtype-convert attrvalue type)))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
236 (setq ret-attr (append ret-attr (list attrname attrvalue))))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
237 (setq attr-list (cdr attr-list)))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
238 (setq fileglobattrs ret-attr))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
239 (progn
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
240 (setq ret-attr fileglobattrs
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
241 attr-list diary-face-attrs)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
242 (while attr-list
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
243 (goto-char (point-min))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
244 (setq attr (car attr-list)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
245 regexp (nth 0 attr)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
246 regnum (nth 1 attr)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
247 attrname (nth 2 attr)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
248 type (nth 3 attr))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
249 (setq attrvalue nil)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
250 (if (string-match regexp entry)
|
50699
|
251 (progn
|
65476
|
252 (setq attrvalue (match-string-no-properties regnum entry))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
253 (setq entry (replace-match "" t t entry))))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
254 (if (and attrvalue
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
255 (setq attrvalue (diary-attrtype-convert attrvalue type)))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
256 (setq ret-attr (append ret-attr (list attrname attrvalue))))
|
50904
|
257 (setq attr-list (cdr attr-list)))))
|
|
258 (list entry ret-attr))))
|
50699
|
259
|
77043
|
260 (defun diary-set-maybe-redraw (symbol value)
|
|
261 "Set SYMBOL's value to VALUE, and redraw the diary if necessary.
|
|
262 Redraws the diary if it is being displayed (note this is not the same as
|
|
263 just visiting the `diary-file'), and SYMBOL's value is to be changed."
|
|
264 (let ((oldvalue (eval symbol)))
|
|
265 (custom-set-default symbol value)
|
|
266 (and (not (equal value oldvalue))
|
|
267 (diary-live-p)
|
|
268 ;; Note this assumes diary was called without prefix arg.
|
|
269 (diary))))
|
50699
|
270
|
52412
|
271 ;; This can be removed once the kill/yank treatment of invisible text
|
|
272 ;; (see etc/TODO) is fixed. -- gm
|
|
273 (defcustom diary-header-line-flag t
|
76639
|
274 "If non-nil, `simple-diary-display' will show a header line.
|
52412
|
275 The format of the header is specified by `diary-header-line-format'."
|
|
276 :group 'diary
|
|
277 :type 'boolean
|
76639
|
278 :initialize 'custom-initialize-default
|
77292
|
279 ;; FIXME overkill.
|
76639
|
280 :set 'diary-set-maybe-redraw
|
59996
|
281 :version "22.1")
|
52412
|
282
|
65875
|
283 (defvar diary-selective-display nil)
|
|
284
|
52412
|
285 (defcustom diary-header-line-format
|
|
286 '(:eval (calendar-string-spread
|
65875
|
287 (list (if diary-selective-display
|
52412
|
288 "Selective display active - press \"s\" in calendar \
|
|
289 before edit/copy"
|
|
290 "Diary"))
|
63851
45ed77379ac6
(diary-header-line-format): Change space constants followed by a sexp to "?\s ".
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
291 ?\s (frame-width)))
|
76639
|
292 "Format of the header line displayed by `simple-diary-display'.
|
52412
|
293 Only used if `diary-header-line-flag' is non-nil."
|
|
294 :group 'diary
|
|
295 :type 'sexp
|
77292
|
296 :initialize 'custom-initialize-default
|
|
297 ;; FIXME overkill.
|
|
298 :set 'diary-set-maybe-redraw
|
59996
|
299 :version "22.1")
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
300
|
57255
|
301 (defvar diary-saved-point) ; internal
|
|
302
|
76754
|
303 ;; The first version of this also checked for diary-selective-display
|
|
304 ;; in the non-fancy case. This was an attempt to distinguish between
|
|
305 ;; displaying the diary and just visiting the diary file. However,
|
|
306 ;; when using fancy diary, calling diary when there are no entries to
|
|
307 ;; display does not create the fancy buffer, nor does it switch on
|
|
308 ;; selective-display in the diary buffer. This means some
|
|
309 ;; customizations will not take effect, eg:
|
|
310 ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-03/msg00466.html
|
|
311 ;; So the check for selective-display was dropped. This means the
|
|
312 ;; diary will be displayed if one customizes a diary variable while
|
|
313 ;; just visiting the diary-file. This is i) unlikely, and ii) no great loss.
|
76618
|
314 (defun diary-live-p ()
|
76754
|
315 "Return non-nil if the diary is being displayed."
|
76618
|
316 (or (get-buffer fancy-diary-buffer)
|
76754
|
317 (and diary-file
|
|
318 (find-buffer-visiting (substitute-in-file-name diary-file)))))
|
65476
|
319
|
|
320 (defcustom number-of-diary-entries 1
|
|
321 "Specifies how many days of diary entries are to be displayed initially.
|
|
322 This variable affects the diary display when the command \\[diary] is used,
|
|
323 or if the value of the variable `view-diary-entries-initially' is t. For
|
|
324 example, if the default value 1 is used, then only the current day's diary
|
|
325 entries will be displayed. If the value 2 is used, then both the current
|
|
326 day's and the next day's entries will be displayed.
|
|
327
|
|
328 The value can also be a vector such as [0 2 2 2 2 4 1]; this value
|
76478
|
329 says to display no diary entries on Sunday, the entries for
|
|
330 the current date and the day after on Monday through Thursday,
|
|
331 Friday through Monday's entries on Friday, and only Saturday's
|
|
332 entries on Saturday.
|
65476
|
333
|
|
334 This variable does not affect the diary display with the `d' command
|
|
335 from the calendar; in that case, the prefix argument controls the
|
|
336 number of days of diary entries displayed."
|
|
337 :type '(choice (integer :tag "Entries")
|
|
338 (vector :value [0 0 0 0 0 0 0]
|
|
339 (integer :tag "Sunday")
|
|
340 (integer :tag "Monday")
|
|
341 (integer :tag "Tuesday")
|
|
342 (integer :tag "Wednesday")
|
|
343 (integer :tag "Thursday")
|
|
344 (integer :tag "Friday")
|
|
345 (integer :tag "Saturday")))
|
76618
|
346 :initialize 'custom-initialize-default
|
76639
|
347 :set 'diary-set-maybe-redraw
|
65476
|
348 :group 'diary)
|
|
349
|
70728
|
350
|
|
351 (defvar diary-modify-entry-list-string-function nil
|
|
352 "Function applied to entry string before putting it into the entries list.
|
|
353 Can be used by programs integrating a diary list into other buffers (e.g.
|
|
354 org.el and planner.el) to modify the string or add properties to it.
|
|
355 The function takes a string argument and must return a string.")
|
|
356
|
|
357 (defun add-to-diary-list (date string specifier &optional marker
|
|
358 globcolor literal)
|
|
359 "Add an entry to `diary-entries-list'.
|
|
360 Do nothing if DATE or STRING is nil. DATE is the (MONTH DAY
|
|
361 YEAR) for which the entry applies; STRING is the text of the
|
|
362 entry as it will appear in the diary (i.e. with any format
|
70729
|
363 strings such as \"%d\" expanded); SPECIFIER is the date part of
|
70728
|
364 the entry as it appears in the diary-file; LITERAL is the entry
|
70729
|
365 as it appears in the diary-file (i.e. before expansion). If
|
70728
|
366 LITERAL is nil, it is taken to be the same as STRING.
|
|
367
|
|
368 The entry is added to the list as (DATE STRING SPECIFIER LOCATOR
|
|
369 GLOBCOLOR), where LOCATOR has the form (MARKER FILENAME LITERAL),
|
|
370 FILENAME being the file containing the diary entry."
|
|
371 (when (and date string)
|
|
372 (if diary-file-name-prefix
|
|
373 (let ((prefix (funcall diary-file-name-prefix-function
|
|
374 (buffer-file-name))))
|
|
375 (or (string= prefix "")
|
|
376 (setq string (format "[%s] %s" prefix string)))))
|
|
377 (and diary-modify-entry-list-string-function
|
|
378 (setq string (funcall diary-modify-entry-list-string-function
|
|
379 string)))
|
|
380 (setq diary-entries-list
|
|
381 (append diary-entries-list
|
|
382 (list (list date string specifier
|
|
383 (list marker (buffer-file-name) literal)
|
|
384 globcolor))))))
|
|
385
|
65476
|
386 (define-obsolete-function-alias 'list-diary-entries 'diary-list-entries)
|
65875
|
387 (defun diary-list-entries (date number &optional list-only)
|
65476
|
388 "Create and display a buffer containing the relevant lines in `diary-file'.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
389 The arguments are DATE and NUMBER; the entries selected are those
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
390 for NUMBER days starting with date DATE. The other entries are hidden
|
53557
|
391 using selective display. If NUMBER is less than 1, this function does nothing.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
392
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
393 Returns a list of all relevant diary entries found, if any, in order by date.
|
65875
|
394 The list entries have the form ((MONTH DAY YEAR) STRING SPECIFIER) where
|
|
395 \(MONTH DAY YEAR) is the date of the entry, STRING is the entry text, and
|
|
396 SPECIFIER is the applicability. If the variable `diary-list-include-blanks'
|
|
397 is t, this list includes a dummy diary entry consisting of the empty string
|
20269
|
398 for a date with no diary entries.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
399
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
400 After the list is prepared, the hooks `nongregorian-diary-listing-hook',
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
401 `list-diary-entries-hook', `diary-display-hook', and `diary-hook' are run.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
402 These hooks have the following distinct roles:
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
403
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
404 `nongregorian-diary-listing-hook' can cull dates from the diary
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
405 and each included file. Usually used for Hebrew or Islamic
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
406 diary entries in files. Applied to *each* file.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
407
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
408 `list-diary-entries-hook' adds or manipulates diary entries from
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
409 external sources. Used, for example, to include diary entries
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
410 from other files or to sort the diary entries. Invoked *once* only,
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
411 before the display hook is run.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
412
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
413 `diary-display-hook' does the actual display of information. If this is
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
414 nil, simple-diary-display will be used. Use add-hook to set this to
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
415 fancy-diary-display, if desired. If you want no diary display, use
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
416 add-hook to set this to ignore.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
417
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
418 `diary-hook' is run last. This can be used for an appointment
|
65875
|
419 notification function.
|
|
420
|
|
421 If LIST-ONLY is non-nil don't modify or display the buffer, only return a list."
|
65476
|
422 (unless number
|
|
423 (setq number (if (vectorp number-of-diary-entries)
|
|
424 (aref number-of-diary-entries (calendar-day-of-week date))
|
|
425 number-of-diary-entries)))
|
53557
|
426 (when (> number 0)
|
|
427 (let ((original-date date);; save for possible use in the hooks
|
|
428 diary-entries-list
|
|
429 file-glob-attrs
|
|
430 (date-string (calendar-date-string date))
|
|
431 (d-file (substitute-in-file-name diary-file)))
|
|
432 (message "Preparing diary...")
|
|
433 (save-excursion
|
|
434 (let ((diary-buffer (find-buffer-visiting d-file)))
|
|
435 (if (not diary-buffer)
|
|
436 (set-buffer (find-file-noselect d-file t))
|
|
437 (set-buffer diary-buffer)
|
|
438 (or (verify-visited-file-modtime diary-buffer)
|
|
439 (revert-buffer t t))))
|
65875
|
440 ;; Setup things like the header-line-format and invisibility-spec.
|
77292
|
441 (if (eq major-mode default-major-mode)
|
|
442 (diary-mode)
|
|
443 ;; This kludge is to make customizations to
|
|
444 ;; diary-header-line-flag after diary has been displayed
|
|
445 ;; take effect. Unconditionally calling (diary-mode)
|
|
446 ;; clobbers file local variables.
|
|
447 ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-03/msg00363.html
|
|
448 ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-04/msg00404.html
|
77293
e262afb73c6e
Improve previous fix by only setting header-line-format in diary-mode.
Glenn Morris <rgm@gnu.org>
diff
changeset
|
449 (if (eq major-mode 'diary-mode)
|
e262afb73c6e
Improve previous fix by only setting header-line-format in diary-mode.
Glenn Morris <rgm@gnu.org>
diff
changeset
|
450 (setq header-line-format (and diary-header-line-flag
|
e262afb73c6e
Improve previous fix by only setting header-line-format in diary-mode.
Glenn Morris <rgm@gnu.org>
diff
changeset
|
451 diary-header-line-format))))
|
57255
|
452 ;; d-s-p is passed to the diary display function.
|
|
453 (let ((diary-saved-point (point)))
|
|
454 (save-excursion
|
|
455 (setq file-glob-attrs (nth 1 (diary-pull-attrs nil "")))
|
65476
|
456 (with-syntax-table diary-syntax-table
|
65875
|
457 (let ((mark (regexp-quote diary-nonmarking-symbol)))
|
65476
|
458 (goto-char (point-min))
|
65875
|
459 (unless list-only
|
|
460 (let ((ol (make-overlay (point-min) (point-max) nil t nil)))
|
|
461 (set (make-local-variable 'diary-selective-display) t)
|
|
462 (overlay-put ol 'invisible 'diary)
|
|
463 (overlay-put ol 'evaporate t)))
|
65476
|
464 (calendar-for-loop
|
|
465 i from 1 to number do
|
|
466 (let ((month (extract-calendar-month date))
|
|
467 (day (extract-calendar-day date))
|
|
468 (year (extract-calendar-year date))
|
|
469 (entry-found (list-sexp-diary-entries date)))
|
|
470 (dolist (date-form diary-date-forms)
|
|
471 (let*
|
|
472 ((backup (when (eq (car date-form) 'backup)
|
|
473 (setq date-form (cdr date-form))
|
|
474 t))
|
|
475 (dayname
|
|
476 (format "%s\\|%s\\.?"
|
|
477 (calendar-day-name date)
|
|
478 (calendar-day-name date 'abbrev)))
|
|
479 (monthname
|
|
480 (format "\\*\\|%s\\|%s\\.?"
|
|
481 (calendar-month-name month)
|
|
482 (calendar-month-name month 'abbrev)))
|
|
483 (month (concat "\\*\\|0*" (int-to-string month)))
|
|
484 (day (concat "\\*\\|0*" (int-to-string day)))
|
|
485 (year
|
|
486 (concat
|
|
487 "\\*\\|0*" (int-to-string year)
|
|
488 (if abbreviated-calendar-year
|
|
489 (concat "\\|" (format "%02d" (% year 100)))
|
|
490 "")))
|
|
491 (regexp
|
|
492 (concat
|
|
493 "\\(\\`\\|\^M\\|\n\\)" mark "?\\("
|
65875
|
494 (mapconcat 'eval date-form "\\)\\(?:")
|
65476
|
495 "\\)"))
|
|
496 (case-fold-search t))
|
|
497 (goto-char (point-min))
|
|
498 (while (re-search-forward regexp nil t)
|
|
499 (if backup (re-search-backward "\\<" nil t))
|
|
500 (if (and (or (char-equal (preceding-char) ?\^M)
|
|
501 (char-equal (preceding-char) ?\n))
|
|
502 (not (looking-at " \\|\^I")))
|
|
503 ;; Diary entry that consists only of date.
|
|
504 (backward-char 1)
|
|
505 ;; Found a nonempty diary entry--make it
|
|
506 ;; visible and add it to the list.
|
|
507 (setq entry-found t)
|
|
508 (let ((entry-start (point))
|
|
509 date-start temp)
|
|
510 (re-search-backward "\^M\\|\n\\|\\`")
|
|
511 (setq date-start (point))
|
66429
|
512 ;; When selective display (rather than
|
|
513 ;; overlays) was used, diary file used to
|
|
514 ;; start in a blank line and end in a
|
|
515 ;; newline. Now that neither of these
|
|
516 ;; need be true, 'move handles the latter
|
|
517 ;; and 1/2 kludge the former.
|
|
518 (re-search-forward
|
|
519 "\^M\\|\n" nil 'move
|
|
520 (if (and (bobp) (not (looking-at "\^M\\|\n")))
|
|
521 1
|
|
522 2))
|
65476
|
523 (while (looking-at " \\|\^I")
|
66429
|
524 (re-search-forward "\^M\\|\n" nil 'move))
|
66929
35f26e779968
(diary-list-entries): Also hide the terminating newline.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
525 (unless (and (eobp) (not (bolp)))
|
35f26e779968
(diary-list-entries): Also hide the terminating newline.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
526 (backward-char 1))
|
65875
|
527 (unless list-only
|
|
528 (remove-overlays date-start (point)
|
|
529 'invisible 'diary))
|
65476
|
530 (setq entry (buffer-substring entry-start (point))
|
|
531 temp (diary-pull-attrs entry file-glob-attrs)
|
|
532 entry (nth 0 temp))
|
|
533 (add-to-diary-list
|
|
534 date
|
|
535 entry
|
|
536 (buffer-substring
|
|
537 (1+ date-start) (1- entry-start))
|
|
538 (copy-marker entry-start) (nth 1 temp)))))))
|
|
539 (or entry-found
|
|
540 (not diary-list-include-blanks)
|
70728
|
541 (add-to-diary-list date "" "" "" ""))
|
65476
|
542 (setq date
|
|
543 (calendar-gregorian-from-absolute
|
|
544 (1+ (calendar-absolute-from-gregorian date))))
|
65875
|
545 (setq entry-found nil)))))
|
57255
|
546 (goto-char (point-min))
|
|
547 (run-hooks 'nongregorian-diary-listing-hook
|
|
548 'list-diary-entries-hook)
|
65875
|
549 (unless list-only
|
|
550 (if diary-display-hook
|
|
551 (run-hooks 'diary-display-hook)
|
|
552 (simple-diary-display)))
|
57255
|
553 (run-hooks 'diary-hook)
|
|
554 diary-entries-list))))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
555
|
65476
|
556 (defun diary-unhide-everything ()
|
65875
|
557 (kill-local-variable 'diary-selective-display)
|
|
558 (remove-overlays (point-min) (point-max) 'invisible 'diary)
|
65476
|
559 (kill-local-variable 'mode-line-format))
|
|
560
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
561 (defun include-other-diary-files ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
562 "Include the diary entries from other diary files with those of diary-file.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
563 This function is suitable for use in `list-diary-entries-hook';
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
564 it enables you to use shared diary files together with your own.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
565 The files included are specified in the diaryfile by lines of this form:
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
566 #include \"filename\"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
567 This is recursive; that is, #include directives in diary files thus included
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
568 are obeyed. You can change the `#include' to some other string by
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
569 changing the variable `diary-include-string'."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
570 (goto-char (point-min))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
571 (while (re-search-forward
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
572 (concat
|
65476
|
573 "\\(?:\\`\\|\^M\\|\n\\)"
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
574 (regexp-quote diary-include-string)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
575 " \"\\([^\"]*\\)\"")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
576 nil t)
|
27842
|
577 (let* ((diary-file (substitute-in-file-name
|
65476
|
578 (match-string-no-properties 1)))
|
27842
|
579 (diary-list-include-blanks nil)
|
|
580 (list-diary-entries-hook 'include-other-diary-files)
|
|
581 (diary-display-hook 'ignore)
|
65476
|
582 (diary-hook nil))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
583 (if (file-exists-p diary-file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
584 (if (file-readable-p diary-file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
585 (unwind-protect
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
586 (setq diary-entries-list
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
587 (append diary-entries-list
|
70635
|
588 (diary-list-entries original-date number)))
|
65476
|
589 (with-current-buffer (find-buffer-visiting diary-file)
|
|
590 (diary-unhide-everything)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
591 (beep)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
592 (message "Can't read included diary file %s" diary-file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
593 (sleep-for 2))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
594 (beep)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
595 (message "Can't find included diary file %s" diary-file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
596 (sleep-for 2))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
597 (goto-char (point-min)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
598
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
599 (defun simple-diary-display ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
600 "Display the diary buffer if there are any relevant entries or holidays."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
601 (let* ((holiday-list (if holidays-in-diary-buffer
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
602 (check-calendar-holidays original-date)))
|
52319
|
603 (hol-string (format "%s%s%s"
|
|
604 date-string
|
|
605 (if holiday-list ": " "")
|
|
606 (mapconcat 'identity holiday-list "; ")))
|
|
607 (msg (format "No diary entries for %s" hol-string))
|
|
608 ;; If selected window is dedicated (to the calendar),
|
|
609 ;; need a new one to display the diary.
|
|
610 (pop-up-frames (window-dedicated-p (selected-window))))
|
|
611 (calendar-set-mode-line (format "Diary for %s" hol-string))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
612 (if (or (not diary-entries-list)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
613 (and (not (cdr diary-entries-list))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
614 (string-equal (car (cdr (car diary-entries-list))) "")))
|
52319
|
615 (if (< (length msg) (frame-width))
|
14308
0ce52b2f2bb5
(simple-diary-display, fancy-diary-display): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
616 (message "%s" msg)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
617 (set-buffer (get-buffer-create holiday-buffer))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
618 (setq buffer-read-only nil)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
619 (calendar-set-mode-line date-string)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
620 (erase-buffer)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
621 (insert (mapconcat 'identity holiday-list "\n"))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
622 (goto-char (point-min))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
623 (set-buffer-modified-p nil)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
624 (setq buffer-read-only t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
625 (display-buffer holiday-buffer)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
626 (message "No diary entries for %s" date-string))
|
57255
|
627 (with-current-buffer
|
|
628 (find-buffer-visiting (substitute-in-file-name diary-file))
|
|
629 (let ((window (display-buffer (current-buffer))))
|
|
630 ;; d-s-p is passed from list-diary-entries.
|
|
631 (set-window-point window diary-saved-point)
|
|
632 (set-window-start window (point-min))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
633 (message "Preparing diary...done"))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
634
|
63222
|
635 (defface diary-button '((((type pc) (class color))
|
|
636 (:foreground "lightblue")))
|
48372
|
637 "Default face used for buttons."
|
59996
|
638 :version "22.1"
|
48372
|
639 :group 'diary)
|
63222
|
640 ;; backward-compatibility alias
|
|
641 (put 'diary-button-face 'face-alias 'diary-button)
|
48365
|
642
|
|
643 (define-button-type 'diary-entry
|
|
644 'action #'diary-goto-entry
|
63222
|
645 'face 'diary-button)
|
48365
|
646
|
|
647 (defun diary-goto-entry (button)
|
70728
|
648 (let* ((locator (button-get button 'locator))
|
|
649 (marker (car locator))
|
|
650 markbuf file)
|
|
651 ;; If marker pointing to diary location is valid, use that.
|
|
652 (if (and marker (setq markbuf (marker-buffer marker)))
|
|
653 (progn
|
|
654 (pop-to-buffer markbuf)
|
|
655 (goto-char (marker-position marker)))
|
|
656 ;; Marker is invalid (eg buffer has been killed).
|
|
657 (or (and (setq file (cadr locator))
|
|
658 (file-exists-p file)
|
|
659 (find-file-other-window file)
|
|
660 (progn
|
|
661 (when (eq major-mode default-major-mode) (diary-mode))
|
|
662 (goto-char (point-min))
|
|
663 (if (re-search-forward (format "%s.*\\(%s\\)"
|
|
664 (regexp-quote (nth 2 locator))
|
|
665 (regexp-quote (nth 3 locator)))
|
|
666 nil t)
|
|
667 (goto-char (match-beginning 1)))))
|
|
668 (message "Unable to locate this diary entry")))))
|
48365
|
669
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
670 (defun fancy-diary-display ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
671 "Prepare a diary buffer with relevant entries in a fancy, noneditable form.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
672 This function is provided for optional use as the `diary-display-hook'."
|
65476
|
673 (with-current-buffer ;; Turn off selective-display in the diary file's buffer.
|
|
674 (find-buffer-visiting (substitute-in-file-name diary-file))
|
|
675 (diary-unhide-everything))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
676 (if (or (not diary-entries-list)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
677 (and (not (cdr diary-entries-list))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
678 (string-equal (car (cdr (car diary-entries-list))) "")))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
679 (let* ((holiday-list (if holidays-in-diary-buffer
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
680 (check-calendar-holidays original-date)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
681 (msg (format "No diary entries for %s %s"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
682 (concat date-string (if holiday-list ":" ""))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
683 (mapconcat 'identity holiday-list "; "))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
684 (if (<= (length msg) (frame-width))
|
14308
0ce52b2f2bb5
(simple-diary-display, fancy-diary-display): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
685 (message "%s" msg)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
686 (set-buffer (get-buffer-create holiday-buffer))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
687 (setq buffer-read-only nil)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
688 (erase-buffer)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
689 (insert (mapconcat 'identity holiday-list "\n"))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
690 (goto-char (point-min))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
691 (set-buffer-modified-p nil)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
692 (setq buffer-read-only t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
693 (display-buffer holiday-buffer)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
694 (message "No diary entries for %s" date-string)))
|
65875
|
695 (with-current-buffer;; Prepare the fancy diary buffer.
|
|
696 (make-fancy-diary-buffer)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
697 (setq buffer-read-only nil)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
698 (let ((entry-list diary-entries-list)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
699 (holiday-list)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
700 (holiday-list-last-month 1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
701 (holiday-list-last-year 1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
702 (date (list 0 0 0)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
703 (while entry-list
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
704 (if (not (calendar-date-equal date (car (car entry-list))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
705 (progn
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
706 (setq date (car (car entry-list)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
707 (and holidays-in-diary-buffer
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
708 (calendar-date-compare
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
709 (list (list holiday-list-last-month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
710 (calendar-last-day-of-month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
711 holiday-list-last-month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
712 holiday-list-last-year)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
713 holiday-list-last-year))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
714 (list date))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
715 ;; We need to get the holidays for the next 3 months.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
716 (setq holiday-list-last-month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
717 (extract-calendar-month date))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
718 (setq holiday-list-last-year
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
719 (extract-calendar-year date))
|
54127
|
720 (progn
|
|
721 (increment-calendar-month
|
|
722 holiday-list-last-month holiday-list-last-year 1)
|
|
723 t)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
724 (setq holiday-list
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
725 (let ((displayed-month holiday-list-last-month)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
726 (displayed-year holiday-list-last-year))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
727 (calendar-holiday-list)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
728 (increment-calendar-month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
729 holiday-list-last-month holiday-list-last-year 1))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
730 (let* ((date-string (calendar-date-string date))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
731 (date-holiday-list
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
732 (let ((h holiday-list)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
733 (d))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
734 ;; Make a list of all holidays for date.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
735 (while h
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
736 (if (calendar-date-equal date (car (car h)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
737 (setq d (append d (cdr (car h)))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
738 (setq h (cdr h)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
739 d)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
740 (insert (if (= (point) (point-min)) "" ?\n) date-string)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
741 (if date-holiday-list (insert ": "))
|
14954
|
742 (let* ((l (current-column))
|
|
743 (longest 0))
|
28615
|
744 (insert (mapconcat (lambda (x)
|
|
745 (if (< longest (length x))
|
|
746 (setq longest (length x)))
|
|
747 x)
|
14954
|
748 date-holiday-list
|
|
749 (concat "\n" (make-string l ? ))))
|
|
750 (insert ?\n (make-string (+ l longest) ?=) ?\n)))))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
751
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
752 (setq entry (car (cdr (car entry-list))))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
753 (if (< 0 (length entry))
|
70728
|
754 (let ((this-entry (car entry-list))
|
|
755 this-loc)
|
|
756 (if (setq this-loc (nth 3 this-entry))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
757 (insert-button (concat entry "\n")
|
70728
|
758 ;; (MARKER FILENAME SPECIFIER LITERAL)
|
|
759 'locator (list (car this-loc)
|
|
760 (cadr this-loc)
|
|
761 (nth 2 this-entry)
|
|
762 (or (nth 2 this-loc)
|
|
763 (nth 1 this-entry)))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
764 :type 'diary-entry)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
765 (insert entry ?\n))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
766 (save-excursion
|
70728
|
767 (let* ((marks (nth 4 this-entry))
|
|
768 (faceinfo marks)
|
|
769 temp-face)
|
|
770 (when marks
|
|
771 (setq temp-face (make-symbol
|
|
772 (apply
|
|
773 'concat "temp-face-"
|
|
774 (mapcar (lambda (sym)
|
|
775 (if (stringp sym)
|
|
776 sym
|
|
777 (symbol-name sym)))
|
|
778 marks))))
|
|
779 (make-face temp-face)
|
|
780 ;; Remove :face info from the marks,
|
|
781 ;; copy the face info into temp-face
|
|
782 (while (setq faceinfo (memq :face faceinfo))
|
|
783 (copy-face (read (nth 1 faceinfo)) temp-face)
|
|
784 (setcar faceinfo nil)
|
|
785 (setcar (cdr faceinfo) nil))
|
|
786 (setq marks (delq nil marks))
|
|
787 ;; Apply the font aspects.
|
|
788 (apply 'set-face-attribute temp-face nil marks)
|
|
789 (search-backward entry)
|
|
790 (overlay-put
|
|
791 (make-overlay (match-beginning 0) (match-end 0))
|
|
792 'face temp-face))))))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
793 (setq entry-list (cdr entry-list))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
794 (set-buffer-modified-p nil)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
795 (goto-char (point-min))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
796 (setq buffer-read-only t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
797 (display-buffer fancy-diary-buffer)
|
48365
|
798 (fancy-diary-display-mode)
|
54537
|
799 (calendar-set-mode-line date-string)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
800 (message "Preparing diary...done"))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
801
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
802 (defun make-fancy-diary-buffer ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
803 "Create and return the initial fancy diary buffer."
|
65875
|
804 (with-current-buffer (get-buffer-create fancy-diary-buffer)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
805 (setq buffer-read-only nil)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
806 (calendar-set-mode-line "Diary Entries")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
807 (erase-buffer)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
808 (set-buffer-modified-p nil)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
809 (setq buffer-read-only t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
810 (get-buffer fancy-diary-buffer)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
811
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
812 (defun print-diary-entries ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
813 "Print a hard copy of the diary display.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
814
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
815 If the simple diary display is being used, prepare a temp buffer with the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
816 visible lines of the diary buffer, add a heading line composed from the mode
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
817 line, print the temp buffer, and destroy it.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
818
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
819 If the fancy diary display is being used, just print the buffer.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
820
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
821 The hooks given by the variable `print-diary-entries-hook' are called to do
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
822 the actual printing."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
823 (interactive)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
824 (if (bufferp (get-buffer fancy-diary-buffer))
|
65875
|
825 (with-current-buffer (get-buffer fancy-diary-buffer)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
826 (run-hooks 'print-diary-entries-hook))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
827 (let ((diary-buffer
|
13877
44149f0bf44a
Replaced all uses of get-file-buffer with find-buffer-visiting.
Edward M. Reingold <reingold@emr.cs.iit.edu>
diff
changeset
|
828 (find-buffer-visiting (substitute-in-file-name diary-file))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
829 (if diary-buffer
|
65875
|
830 (let ((temp-buffer (get-buffer-create " *Printable Diary Entries*"))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
831 (heading))
|
65875
|
832 (with-current-buffer diary-buffer
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
833 (setq heading
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
834 (if (not (stringp mode-line-format))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
835 "All Diary Entries"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
836 (string-match "^-*\\([^-].*[^-]\\)-*$" mode-line-format)
|
65875
|
837 (match-string 1 mode-line-format)))
|
|
838 (let ((start (point-min))
|
|
839 end)
|
|
840 (while
|
|
841 (progn
|
|
842 (setq end (next-single-char-property-change
|
|
843 start 'invisible))
|
|
844 (if (get-char-property start 'invisible)
|
|
845 nil
|
|
846 (with-current-buffer temp-buffer
|
|
847 (insert-buffer-substring diary-buffer
|
|
848 start (or end (point-max)))))
|
|
849 (setq start end)
|
|
850 (and end (< end (point-max))))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
851 (set-buffer temp-buffer)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
852 (goto-char (point-min))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
853 (insert heading "\n"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
854 (make-string (length heading) ?=) "\n")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
855 (run-hooks 'print-diary-entries-hook)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
856 (kill-buffer temp-buffer)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
857 (error "You don't have a diary buffer!")))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
858
|
65476
|
859 (define-obsolete-function-alias 'show-all-diary-entries 'diary-show-all-entries)
|
|
860 (defun diary-show-all-entries ()
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
861 "Show all of the diary entries in the diary file.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
862 This function gets rid of the selective display of the diary file so that
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
863 all entries, not just some, are visible. If there is no diary buffer, one
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
864 is created."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
865 (interactive)
|
53557
|
866 (let ((d-file (diary-check-diary-file))
|
|
867 (pop-up-frames (window-dedicated-p (selected-window))))
|
65476
|
868 (with-current-buffer (or (find-buffer-visiting d-file)
|
|
869 (find-file-noselect d-file t))
|
66869
|
870 (when (eq major-mode default-major-mode) (diary-mode))
|
65509
|
871 (diary-unhide-everything)
|
|
872 (display-buffer (current-buffer)))))
|
20345
|
873
|
39615
|
874 (defcustom diary-mail-addr
|
51640
|
875 (if (boundp 'user-mail-address) user-mail-address "")
|
65875
|
876 "Email address that `diary-mail-entries' will send email to."
|
20345
|
877 :group 'diary
|
51640
|
878 :type 'string
|
21668
|
879 :version "20.3")
|
20345
|
880
|
|
881 (defcustom diary-mail-days 7
|
65875
|
882 "Default number of days for `diary-mail-entries' to check."
|
20345
|
883 :group 'diary
|
21668
|
884 :type 'integer
|
|
885 :version "20.3")
|
20345
|
886
|
21957
|
887 ;;;###autoload
|
20345
|
888 (defun diary-mail-entries (&optional ndays)
|
|
889 "Send a mail message showing diary entries for next NDAYS days.
|
|
890 If no prefix argument is given, NDAYS is set to `diary-mail-days'.
|
51640
|
891 Mail is sent to the address specified by `diary-mail-addr'.
|
20345
|
892
|
|
893 You can call `diary-mail-entries' every night using an at/cron job.
|
|
894 For example, this script will run the program at 2am daily. Since
|
|
895 `emacs -batch' does not load your `.emacs' file, you must ensure that
|
|
896 all relevant variables are set, as done here.
|
|
897
|
|
898 #!/bin/sh
|
|
899 # diary-rem.sh -- repeatedly run the Emacs diary-reminder
|
|
900 emacs -batch \\
|
|
901 -eval \"(setq diary-mail-days 3 \\
|
51640
|
902 diary-file \\\"/path/to/diary.file\\\" \\
|
20345
|
903 european-calendar-style t \\
|
|
904 diary-mail-addr \\\"user@host.name\\\" )\" \\
|
39615
|
905 -l diary-lib -f diary-mail-entries
|
20345
|
906 at -f diary-rem.sh 0200 tomorrow
|
|
907
|
|
908 You may have to tweak the syntax of the `at' command to suit your
|
|
909 system. Alternatively, you can specify a cron entry:
|
|
910 0 1 * * * diary-rem.sh
|
|
911 to run it every morning at 1am."
|
35500
|
912 (interactive "P")
|
51640
|
913 (if (string-equal diary-mail-addr "")
|
|
914 (error "You must set `diary-mail-addr' to use this command")
|
|
915 (let ((diary-display-hook 'fancy-diary-display))
|
70635
|
916 (diary-list-entries (calendar-current-date) (or ndays diary-mail-days)))
|
51640
|
917 (compose-mail diary-mail-addr
|
|
918 (concat "Diary entries generated "
|
|
919 (calendar-date-string (calendar-current-date))))
|
|
920 (insert
|
|
921 (if (get-buffer fancy-diary-buffer)
|
65476
|
922 (with-current-buffer fancy-diary-buffer (buffer-string))
|
51640
|
923 "No entries found"))
|
|
924 (call-interactively (get mail-user-agent 'sendfunc))))
|
20345
|
925
|
52117
|
926 (defun diary-name-pattern (string-array &optional abbrev-array paren)
|
|
927 "Return a regexp matching the strings in the array STRING-ARRAY.
|
|
928 If the optional argument ABBREV-ARRAY is present, then the function
|
|
929 `calendar-abbrev-construct' is used to construct abbreviations from the
|
|
930 two supplied arrays. The returned regexp will then also match these
|
|
931 abbreviations, with or without final `.' characters. If the optional
|
|
932 argument PAREN is non-nil, the regexp is surrounded by parentheses."
|
|
933 (regexp-opt (append string-array
|
|
934 (if abbrev-array
|
|
935 (calendar-abbrev-construct abbrev-array
|
|
936 string-array))
|
|
937 (if abbrev-array
|
|
938 (calendar-abbrev-construct abbrev-array
|
|
939 string-array
|
|
940 'period))
|
|
941 nil)
|
|
942 paren))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
943
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
944 (defvar marking-diary-entries nil
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
945 "True during the marking of diary entries, nil otherwise.")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
946
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
947 (defvar marking-diary-entry nil
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
948 "True during the marking of diary entries, if current entry is marking.")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
949
|
60650
|
950 (defun mark-diary-entries (&optional redraw)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
951 "Mark days in the calendar window that have diary entries.
|
60650
|
952 Each entry in the diary file visible in the calendar window is
|
|
953 marked. After the entries are marked, the hooks
|
|
954 `nongregorian-diary-marking-hook' and `mark-diary-entries-hook'
|
|
955 are run. If the optional argument REDRAW is non-nil (which is
|
|
956 the case interactively, for example) then any existing diary
|
65476
|
957 marks are first removed. This is intended to deal with deleted
|
60650
|
958 diary entries."
|
|
959 (interactive "p")
|
|
960 ;; To remove any deleted diary entries. Do not redraw when:
|
|
961 ;; i) processing #include diary files (else only get the marks from
|
|
962 ;; the last #include file processed).
|
|
963 ;; ii) called via calendar-redraw (since calendar has already been
|
|
964 ;; erased).
|
|
965 ;; Use of REDRAW handles both of these cases.
|
|
966 (when (and redraw mark-diary-entries-in-calendar)
|
60321
|
967 (setq mark-diary-entries-in-calendar nil)
|
|
968 (redraw-calendar))
|
51640
|
969 (let ((marking-diary-entries t)
|
|
970 file-glob-attrs marks)
|
65619
|
971 (with-current-buffer (find-file-noselect (diary-check-diary-file) t)
|
|
972 (save-excursion
|
66869
|
973 (when (eq major-mode default-major-mode) (diary-mode))
|
65552
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
974 (setq mark-diary-entries-in-calendar t)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
975 (message "Marking diary entries...")
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
976 (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '())))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
977 (with-syntax-table diary-syntax-table
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
978 (dolist (date-form diary-date-forms)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
979 (if (eq (car date-form) 'backup)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
980 (setq date-form (cdr date-form))) ;; ignore 'backup directive
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
981 (let* ((dayname
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
982 (diary-name-pattern calendar-day-name-array
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
983 calendar-day-abbrev-array))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
984 (monthname
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
985 (format "%s\\|\\*"
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
986 (diary-name-pattern calendar-month-name-array
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
987 calendar-month-abbrev-array)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
988 (month "[0-9]+\\|\\*")
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
989 (day "[0-9]+\\|\\*")
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
990 (year "[0-9]+\\|\\*")
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
991 (l (length date-form))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
992 (d-name-pos (- l (length (memq 'dayname date-form))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
993 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
994 (m-name-pos (- l (length (memq 'monthname date-form))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
995 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
996 (d-pos (- l (length (memq 'day date-form))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
997 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
998 (m-pos (- l (length (memq 'month date-form))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
999 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1000 (y-pos (- l (length (memq 'year date-form))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1001 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1002 (regexp
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1003 (concat
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1004 "\\(\\`\\|\^M\\|\n\\)\\("
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1005 (mapconcat 'eval date-form "\\)\\(")
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1006 "\\)"))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1007 (case-fold-search t))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1008 (goto-char (point-min))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1009 (while (re-search-forward regexp nil t)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1010 (let* ((dd-name
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1011 (if d-name-pos
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1012 (match-string-no-properties d-name-pos)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1013 (mm-name
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1014 (if m-name-pos
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1015 (match-string-no-properties m-name-pos)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1016 (mm (string-to-number
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1017 (if m-pos
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1018 (match-string-no-properties m-pos)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1019 "")))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1020 (dd (string-to-number
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1021 (if d-pos
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1022 (match-string-no-properties d-pos)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1023 "")))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1024 (y-str (if y-pos
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1025 (match-string-no-properties y-pos)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1026 (yy (if (not y-str)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1027 0
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1028 (if (and (= (length y-str) 2)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1029 abbreviated-calendar-year)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1030 (let* ((current-y
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1031 (extract-calendar-year
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1032 (calendar-current-date)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1033 (y (+ (string-to-number y-str)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1034 (* 100
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1035 (/ current-y 100)))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1036 (if (> (- y current-y) 50)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1037 (- y 100)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1038 (if (> (- current-y y) 50)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1039 (+ y 100)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1040 y)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1041 (string-to-number y-str)))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1042 (let ((tmp (diary-pull-attrs (buffer-substring-no-properties
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1043 (point) (line-end-position))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1044 file-glob-attrs)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1045 (setq entry (nth 0 tmp)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1046 marks (nth 1 tmp)))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1047 (if dd-name
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1048 (mark-calendar-days-named
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1049 (cdr (assoc-string
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1050 dd-name
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1051 (calendar-make-alist
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1052 calendar-day-name-array
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1053 0 nil calendar-day-abbrev-array) t)) marks)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1054 (if mm-name
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1055 (setq mm
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1056 (if (string-equal mm-name "*") 0
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1057 (cdr (assoc-string
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1058 mm-name
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1059 (calendar-make-alist
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1060 calendar-month-name-array
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1061 1 nil calendar-month-abbrev-array) t)))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1062 (mark-calendar-date-pattern mm dd yy marks))))))
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1063 (mark-sexp-diary-entries)
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1064 (run-hooks 'nongregorian-diary-marking-hook
|
2f26d67eea8d
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1065 'mark-diary-entries-hook))
|
51640
|
1066 (message "Marking diary entries...done")))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1067
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1068 (defun mark-sexp-diary-entries ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1069 "Mark days in the calendar window that have sexp diary entries.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1070 Each entry in the diary file (or included files) visible in the calendar window
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1071 is marked. See the documentation for the function `list-sexp-diary-entries'."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1072 (let* ((sexp-mark (regexp-quote sexp-diary-entry-symbol))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1073 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)\\("
|
51640
|
1074 sexp-mark "(\\)\\|\\("
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1075 (regexp-quote diary-nonmarking-symbol)
|
51640
|
1076 sexp-mark "(diary-remind\\)"))
|
|
1077 (file-glob-attrs (nth 1 (diary-pull-attrs nil '())))
|
|
1078 m y first-date last-date mark file-glob-attrs)
|
65476
|
1079 (with-current-buffer calendar-buffer
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1080 (setq m displayed-month)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1081 (setq y displayed-year))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1082 (increment-calendar-month m y -1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1083 (setq first-date
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1084 (calendar-absolute-from-gregorian (list m 1 y)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1085 (increment-calendar-month m y 2)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1086 (setq last-date
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1087 (calendar-absolute-from-gregorian
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1088 (list m (calendar-last-day-of-month m y) y)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1089 (goto-char (point-min))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1090 (while (re-search-forward s-entry nil t)
|
51640
|
1091 (setq marking-diary-entry (char-equal (preceding-char) ?\())
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1092 (re-search-backward "(")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1093 (let ((sexp-start (point))
|
50904
|
1094 sexp entry entry-start line-start marks)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1095 (forward-sexp)
|
13687
9a985bcde00e
Chnaged all occurrences of buffer-substring to buffer-substring-no-properties.
Edward M. Reingold <reingold@emr.cs.iit.edu>
diff
changeset
|
1096 (setq sexp (buffer-substring-no-properties sexp-start (point)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1097 (save-excursion
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1098 (re-search-backward "\^M\\|\n\\|\\`")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1099 (setq line-start (point)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1100 (forward-char 1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1101 (if (and (or (char-equal (preceding-char) ?\^M)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1102 (char-equal (preceding-char) ?\n))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1103 (not (looking-at " \\|\^I")))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1104 (progn;; Diary entry consists only of the sexp
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1105 (backward-char 1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1106 (setq entry ""))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1107 (setq entry-start (point))
|
23247
|
1108 ;; Find end of entry
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1109 (re-search-forward "\^M\\|\n" nil t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1110 (while (looking-at " \\|\^I")
|
23232
|
1111 (or (re-search-forward "\^M\\|\n" nil t)
|
|
1112 (re-search-forward "$" nil t)))
|
23247
|
1113 (if (or (char-equal (preceding-char) ?\^M)
|
|
1114 (char-equal (preceding-char) ?\n))
|
|
1115 (backward-char 1))
|
13687
9a985bcde00e
Chnaged all occurrences of buffer-substring to buffer-substring-no-properties.
Edward M. Reingold <reingold@emr.cs.iit.edu>
diff
changeset
|
1116 (setq entry (buffer-substring-no-properties entry-start (point)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1117 (while (string-match "[\^M]" entry)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1118 (aset entry (match-beginning 0) ?\n )))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1119 (calendar-for-loop date from first-date to last-date do
|
46620
|
1120 (if (setq mark (diary-sexp-entry sexp entry
|
|
1121 (calendar-gregorian-from-absolute date)))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1122 (progn
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1123 (setq marks (diary-pull-attrs entry file-glob-attrs)
|
50904
|
1124 marks (nth 1 (diary-pull-attrs entry file-glob-attrs)))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1125 (mark-visible-calendar-date
|
50699
|
1126 (calendar-gregorian-from-absolute date)
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1127 (if (< 0 (length marks))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1128 marks
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1129 (if (consp mark)
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1130 (car mark)))))))))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1131
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1132 (defun mark-included-diary-files ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1133 "Mark the diary entries from other diary files with those of the diary file.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1134 This function is suitable for use as the `mark-diary-entries-hook'; it enables
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1135 you to use shared diary files together with your own. The files included are
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1136 specified in the diary-file by lines of this form:
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1137 #include \"filename\"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1138 This is recursive; that is, #include directives in diary files thus included
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1139 are obeyed. You can change the `#include' to some other string by
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1140 changing the variable `diary-include-string'."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1141 (goto-char (point-min))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1142 (while (re-search-forward
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1143 (concat
|
65476
|
1144 "\\(?:\\`\\|\^M\\|\n\\)"
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1145 (regexp-quote diary-include-string)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1146 " \"\\([^\"]*\\)\"")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1147 nil t)
|
62901
555a704ce217
(mark-included-diary-files): Only kill included diary buffer if it was
Glenn Morris <rgm@gnu.org>
diff
changeset
|
1148 (let* ((diary-file (substitute-in-file-name
|
65476
|
1149 (match-string-no-properties 1)))
|
62901
555a704ce217
(mark-included-diary-files): Only kill included diary buffer if it was
Glenn Morris <rgm@gnu.org>
diff
changeset
|
1150 (mark-diary-entries-hook 'mark-included-diary-files)
|
555a704ce217
(mark-included-diary-files): Only kill included diary buffer if it was
Glenn Morris <rgm@gnu.org>
diff
changeset
|
1151 (dbuff (find-buffer-visiting diary-file)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1152 (if (file-exists-p diary-file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1153 (if (file-readable-p diary-file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1154 (progn
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1155 (mark-diary-entries)
|
62901
555a704ce217
(mark-included-diary-files): Only kill included diary buffer if it was
Glenn Morris <rgm@gnu.org>
diff
changeset
|
1156 (unless dbuff
|
555a704ce217
(mark-included-diary-files): Only kill included diary buffer if it was
Glenn Morris <rgm@gnu.org>
diff
changeset
|
1157 (kill-buffer (find-buffer-visiting diary-file))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1158 (beep)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1159 (message "Can't read included diary file %s" diary-file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1160 (sleep-for 2))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1161 (beep)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1162 (message "Can't find included diary file %s" diary-file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1163 (sleep-for 2))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1164 (goto-char (point-min)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1165
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1166 (defun mark-calendar-days-named (dayname &optional color)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1167 "Mark all dates in the calendar window that are day DAYNAME of the week.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1168 0 means all Sundays, 1 means all Mondays, and so on."
|
65476
|
1169 (with-current-buffer calendar-buffer
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1170 (let ((prev-month displayed-month)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1171 (prev-year displayed-year)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1172 (succ-month displayed-month)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1173 (succ-year displayed-year)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1174 (last-day)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1175 (day))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1176 (increment-calendar-month succ-month succ-year 1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1177 (increment-calendar-month prev-month prev-year -1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1178 (setq day (calendar-absolute-from-gregorian
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1179 (calendar-nth-named-day 1 dayname prev-month prev-year)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1180 (setq last-day (calendar-absolute-from-gregorian
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1181 (calendar-nth-named-day -1 dayname succ-month succ-year)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1182 (while (<= day last-day)
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1183 (mark-visible-calendar-date (calendar-gregorian-from-absolute day) color)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1184 (setq day (+ day 7))))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1185
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1186 (defun mark-calendar-date-pattern (month day year &optional color)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1187 "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1188 A value of 0 in any position is a wildcard."
|
65476
|
1189 (with-current-buffer calendar-buffer
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1190 (let ((m displayed-month)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1191 (y displayed-year))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1192 (increment-calendar-month m y -1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1193 (calendar-for-loop i from 0 to 2 do
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1194 (mark-calendar-month m y month day year color)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1195 (increment-calendar-month m y 1)))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1196
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1197 (defun mark-calendar-month (month year p-month p-day p-year &optional color)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1198 "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1199 A value of 0 in any position of the pattern is a wildcard."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1200 (if (or (and (= month p-month)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1201 (or (= p-year 0) (= year p-year)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1202 (and (= p-month 0)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1203 (or (= p-year 0) (= year p-year))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1204 (if (= p-day 0)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1205 (calendar-for-loop
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1206 i from 1 to (calendar-last-day-of-month month year) do
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1207 (mark-visible-calendar-date (list month i year) color))
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1208 (mark-visible-calendar-date (list month p-day year) color))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1209
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1210 (defun sort-diary-entries ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1211 "Sort the list of diary entries by time of day."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1212 (setq diary-entries-list (sort diary-entries-list 'diary-entry-compare)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1213
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1214 (defun diary-entry-compare (e1 e2)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1215 "Returns t if E1 is earlier than E2."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1216 (or (calendar-date-compare e1 e2)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1217 (and (calendar-date-equal (car e1) (car e2))
|
39615
|
1218 (let* ((ts1 (cadr e1)) (t1 (diary-entry-time ts1))
|
|
1219 (ts2 (cadr e2)) (t2 (diary-entry-time ts2)))
|
|
1220 (or (< t1 t2)
|
|
1221 (and (= t1 t2)
|
|
1222 (string-lessp ts1 ts2)))))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1223
|
20269
|
1224 (defcustom diary-unknown-time
|
|
1225 -9999
|
65875
|
1226 "Value returned by diary-entry-time when no time is found.
|
20269
|
1227 The default value -9999 causes entries with no recognizable time to be placed
|
|
1228 before those with times; 9999 would place entries with no recognizable time
|
|
1229 after those with times."
|
|
1230 :type 'integer
|
21669
|
1231 :group 'diary
|
|
1232 :version "20.3")
|
39615
|
1233
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1234 (defun diary-entry-time (s)
|
46620
|
1235 "Return time at the beginning of the string S as a military-style integer.
|
|
1236 For example, returns 1325 for 1:25pm.
|
53548
65fe9b0d6ac6
(diary-entry-time): Also accept time in the form XX[.XX][am/pm/AM/PM].
Thien-Thi Nguyen <ttn@gnuvola.org>
diff
changeset
|
1237
|
65fe9b0d6ac6
(diary-entry-time): Also accept time in the form XX[.XX][am/pm/AM/PM].
Thien-Thi Nguyen <ttn@gnuvola.org>
diff
changeset
|
1238 Returns `diary-unknown-time' (default value -9999) if no time is recognized.
|
65fe9b0d6ac6
(diary-entry-time): Also accept time in the form XX[.XX][am/pm/AM/PM].
Thien-Thi Nguyen <ttn@gnuvola.org>
diff
changeset
|
1239 The recognized forms are XXXX, X:XX, or XX:XX (military time), and XXam,
|
53557
|
1240 XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm, or XX:XXPM. A period (.) can
|
|
1241 be used instead of a colon (:) to separate the hour and minute parts."
|
19324
|
1242 (let ((case-fold-search nil))
|
39615
|
1243 (cond ((string-match ; Military time
|
53548
65fe9b0d6ac6
(diary-entry-time): Also accept time in the form XX[.XX][am/pm/AM/PM].
Thien-Thi Nguyen <ttn@gnuvola.org>
diff
changeset
|
1244 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)[:.]?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)"
|
65fe9b0d6ac6
(diary-entry-time): Also accept time in the form XX[.XX][am/pm/AM/PM].
Thien-Thi Nguyen <ttn@gnuvola.org>
diff
changeset
|
1245 s)
|
65476
|
1246 (+ (* 100 (string-to-number (match-string 1 s)))
|
|
1247 (string-to-number (match-string 2 s))))
|
39615
|
1248 ((string-match ; Hour only XXam or XXpm
|
34036
|
1249 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s)
|
65476
|
1250 (+ (* 100 (% (string-to-number (match-string 1 s)) 12))
|
19324
|
1251 (if (equal ?a (downcase (aref s (match-beginning 2))))
|
|
1252 0 1200)))
|
39615
|
1253 ((string-match ; Hour and minute XX:XXam or XX:XXpm
|
53613
|
1254 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)[:.]\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
|
65476
|
1255 (+ (* 100 (% (string-to-number (match-string 1 s)) 12))
|
|
1256 (string-to-number (match-string 2 s))
|
19324
|
1257 (if (equal ?a (downcase (aref s (match-beginning 3))))
|
|
1258 0 1200)))
|
39615
|
1259 (t diary-unknown-time)))) ; Unrecognizable
|
34036
|
1260
|
55431
|
1261 ;; Unrecognizable
|
|
1262
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1263 (defun list-sexp-diary-entries (date)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1264 "Add sexp entries for DATE from the diary file to `diary-entries-list'.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1265 Also, Make them visible in the diary file. Returns t if any entries were
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1266 found.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1267
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1268 Sexp diary entries must be prefaced by a `sexp-diary-entry-symbol' (normally
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1269 `%%'). The form of a sexp diary entry is
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1270
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1271 %%(SEXP) ENTRY
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1272
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1273 Both ENTRY and DATE are globally available when the SEXP is evaluated. If the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1274 SEXP yields the value nil, the diary entry does not apply. If it yields a
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1275 non-nil value, ENTRY will be taken to apply to DATE; if the non-nil value is a
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1276 string, that string will be the diary entry in the fancy diary display.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1277
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1278 For example, the following diary entry will apply to the 21st of the month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1279 if it is a weekday and the Friday before if the 21st is on a weekend:
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1280
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1281 &%%(let ((dayname (calendar-day-of-week date))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1282 (day (extract-calendar-day date)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1283 (or
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1284 (and (= day 21) (memq dayname '(1 2 3 4 5)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1285 (and (memq day '(19 20)) (= dayname 5)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1286 ) UIUC pay checks deposited
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1287
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1288 A number of built-in functions are available for this type of diary entry:
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1289
|
46620
|
1290 %%(diary-date MONTH DAY YEAR &optional MARK) text
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1291 Entry applies if date is MONTH, DAY, YEAR if
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1292 `european-calendar-style' is nil, and DAY, MONTH, YEAR if
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1293 `european-calendar-style' is t. DAY, MONTH, and YEAR
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1294 can be lists of integers, the constant t, or an integer.
|
46826
|
1295 The constant t means all values. An optional parameter
|
46620
|
1296 MARK specifies a face or single-character string to use
|
|
1297 when highlighting the day in the calendar.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1298
|
46620
|
1299 %%(diary-float MONTH DAYNAME N &optional DAY MARK) text
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1300 Entry will appear on the Nth DAYNAME of MONTH.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1301 (DAYNAME=0 means Sunday, 1 means Monday, and so on;
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1302 if N is negative it counts backward from the end of
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1303 the month. MONTH can be a list of months, a single
|
17892
|
1304 month, or t to specify all months. Optional DAY means
|
|
1305 Nth DAYNAME of MONTH on or after/before DAY. DAY defaults
|
46826
|
1306 to 1 if N>0 and the last day of the month if N<0. An
|
|
1307 optional parameter MARK specifies a face or single-character
|
46620
|
1308 string to use when highlighting the day in the calendar.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1309
|
46620
|
1310 %%(diary-block M1 D1 Y1 M2 D2 Y2 &optional MARK) text
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1311 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2,
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1312 inclusive. (If `european-calendar-style' is t, the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1313 order of the parameters should be changed to D1, M1, Y1,
|
46826
|
1314 D2, M2, Y2.) An optional parameter MARK specifies a face
|
|
1315 or single-character string to use when highlighting the
|
46620
|
1316 day in the calendar.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1317
|
46620
|
1318 %%(diary-anniversary MONTH DAY YEAR &optional MARK) text
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1319 Entry will appear on anniversary dates of MONTH DAY, YEAR.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1320 (If `european-calendar-style' is t, the order of the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1321 parameters should be changed to DAY, MONTH, YEAR.) Text
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1322 can contain %d or %d%s; %d will be replaced by the number
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1323 of years since the MONTH DAY, YEAR and %s will be replaced
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1324 by the ordinal ending of that number (that is, `st', `nd',
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1325 `rd' or `th', as appropriate. The anniversary of February
|
46826
|
1326 29 is considered to be March 1 in a non-leap year. An
|
|
1327 optional parameter MARK specifies a face or single-character
|
46620
|
1328 string to use when highlighting the day in the calendar.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1329
|
46620
|
1330 %%(diary-cyclic N MONTH DAY YEAR &optional MARK) text
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1331 Entry will appear every N days, starting MONTH DAY, YEAR.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1332 (If `european-calendar-style' is t, the order of the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1333 parameters should be changed to N, DAY, MONTH, YEAR.) Text
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1334 can contain %d or %d%s; %d will be replaced by the number
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1335 of repetitions since the MONTH DAY, YEAR and %s will
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1336 be replaced by the ordinal ending of that number (that is,
|
46826
|
1337 `st', `nd', `rd' or `th', as appropriate. An optional
|
|
1338 parameter MARK specifies a face or single-character string
|
46620
|
1339 to use when highlighting the day in the calendar.
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1340
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1341 %%(diary-remind SEXP DAYS &optional MARKING) text
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1342 Entry is a reminder for diary sexp SEXP. DAYS is either a
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1343 single number or a list of numbers indicating the number(s)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1344 of days before the event that the warning(s) should occur.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1345 If the current date is (one of) DAYS before the event
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1346 indicated by EXPR, then a suitable message (as specified
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1347 by `diary-remind-message') appears. In addition to the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1348 reminders beforehand, the diary entry also appears on
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1349 the date itself. If optional MARKING is non-nil then the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1350 *reminders* are marked on the calendar. Marking of
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1351 reminders is independent of whether the entry *itself* is
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1352 a marking or nonmarking one.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1353
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1354 %%(diary-day-of-year)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1355 Diary entries giving the day of the year and the number of
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1356 days remaining in the year will be made every day. Note
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1357 that since there is no text, it makes sense only if the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1358 fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1359
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1360 %%(diary-iso-date)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1361 Diary entries giving the corresponding ISO commercial date
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1362 will be made every day. Note that since there is no text,
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1363 it makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1364
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1365 %%(diary-french-date)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1366 Diary entries giving the corresponding French Revolutionary
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1367 date will be made every day. Note that since there is no
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1368 text, it makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1369
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1370 %%(diary-islamic-date)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1371 Diary entries giving the corresponding Islamic date will be
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1372 made every day. Note that since there is no text, it
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1373 makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1374
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1375 %%(diary-hebrew-date)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1376 Diary entries giving the corresponding Hebrew date will be
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1377 made every day. Note that since there is no text, it
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1378 makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1379
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1380 %%(diary-astro-day-number) Diary entries giving the corresponding
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1381 astronomical (Julian) day number will be made every day.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1382 Note that since there is no text, it makes sense only if the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1383 fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1384
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1385 %%(diary-julian-date) Diary entries giving the corresponding
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1386 Julian date will be made every day. Note that since
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1387 there is no text, it makes sense only if the fancy diary
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1388 display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1389
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1390 %%(diary-sunrise-sunset)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1391 Diary entries giving the local times of sunrise and sunset
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1392 will be made every day. Note that since there is no text,
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1393 it makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1394 Floating point required.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1395
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1396 %%(diary-phases-of-moon)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1397 Diary entries giving the times of the phases of the moon
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1398 will be when appropriate. Note that since there is no text,
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1399 it makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1400 Floating point required.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1401
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1402 %%(diary-yahrzeit MONTH DAY YEAR) text
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1403 Text is assumed to be the name of the person; the date is
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1404 the date of death on the *civil* calendar. The diary entry
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1405 will appear on the proper Hebrew-date anniversary and on the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1406 day before. (If `european-calendar-style' is t, the order
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1407 of the parameters should be changed to DAY, MONTH, YEAR.)
|
39615
|
1408
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1409 %%(diary-rosh-hodesh)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1410 Diary entries will be made on the dates of Rosh Hodesh on
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1411 the Hebrew calendar. Note that since there is no text, it
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1412 makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1413
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1414 %%(diary-parasha)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1415 Diary entries giving the weekly parasha will be made on
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1416 every Saturday. Note that since there is no text, it
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1417 makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1418
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1419 %%(diary-omer)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1420 Diary entries giving the omer count will be made every day
|
13670
|
1421 from Passover to Shavuot. Note that since there is no text,
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1422 it makes sense only if the fancy diary display is used.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1423
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1424 Marking these entries is *extremely* time consuming, so these entries are
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1425 best if they are nonmarking."
|
53548
65fe9b0d6ac6
(diary-entry-time): Also accept time in the form XX[.XX][am/pm/AM/PM].
Thien-Thi Nguyen <ttn@gnuvola.org>
diff
changeset
|
1426 (let ((s-entry (concat "\\(\\`\\|\^M\\|\n\\)"
|
51640
|
1427 (regexp-quote diary-nonmarking-symbol)
|
|
1428 "?"
|
|
1429 (regexp-quote sexp-diary-entry-symbol)
|
|
1430 "("))
|
|
1431 entry-found file-glob-attrs marks)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1432 (goto-char (point-min))
|
49737
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1433 (save-excursion
|
a8a5fd61aada
(diary-attrtype-convert): Convert an attribute value string to the desired type.
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1434 (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '()))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1435 (while (re-search-forward s-entry nil t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1436 (backward-char 1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1437 (let ((sexp-start (point))
|
51640
|
1438 sexp entry specifier entry-start line-start)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1439 (forward-sexp)
|
13687
9a985bcde00e
Chnaged all occurrences of buffer-substring to buffer-substring-no-properties.
Edward M. Reingold <reingold@emr.cs.iit.edu>
diff
changeset
|
1440 (setq sexp (buffer-substring-no-properties sexp-start (point)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1441 (save-excursion
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1442 (re-search-backward "\^M\\|\n\\|\\`")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1443 (setq line-start (point)))
|
20269
|
1444 (setq specifier
|
48365
|
1445 (buffer-substring-no-properties (1+ line-start) (point))
|
70728
|
1446 entry-start (1+ line-start))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1447 (forward-char 1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1448 (if (and (or (char-equal (preceding-char) ?\^M)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1449 (char-equal (preceding-char) ?\n))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1450 (not (looking-at " \\|\^I")))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1451 (progn;; Diary entry consists only of the sexp
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1452 (backward-char 1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1453 (setq entry ""))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1454 (setq entry-start (point))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1455 (re-search-forward "\^M\\|\n" nil t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1456 (while (looking-at " \\|\^I")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1457 (re-search-forward "\^M\\|\n" nil t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1458 (backward-char 1)
|
13687
9a985bcde00e
Chnaged all occurrences of buffer-substring to buffer-substring-no-properties.
Edward M. Reingold <reingold@emr.cs.iit.edu>
diff
changeset
|
1459 (setq entry (buffer-substring-no-properties entry-start (point)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1460 (while (string-match "[\^M]" entry)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1461 (aset entry (match-beginning 0) ?\n )))
|
50904
|
1462 (let ((diary-entry (diary-sexp-entry sexp entry date))
|
70728
|
1463 temp literal)
|
|
1464 (setq literal entry ; before evaluation
|
|
1465 entry (if (consp diary-entry)
|
|
1466 (cdr diary-entry)
|
|
1467 diary-entry))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1468 (if diary-entry
|
70728
|
1469 (progn
|
65875
|
1470 (remove-overlays line-start (point) 'invisible 'diary)
|
70728
|
1471 (if (< 0 (length entry))
|
|
1472 (setq temp (diary-pull-attrs entry file-glob-attrs)
|
|
1473 entry (nth 0 temp)
|
|
1474 marks (nth 1 temp)))))
|
|
1475 (add-to-diary-list date
|
|
1476 entry
|
|
1477 specifier
|
|
1478 (if entry-start (copy-marker entry-start)
|
|
1479 nil)
|
|
1480 marks
|
|
1481 literal)
|
|
1482 (setq entry-found (or entry-found diary-entry)))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1483 entry-found))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1484
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1485 (defun diary-sexp-entry (sexp entry date)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1486 "Process a SEXP diary ENTRY for DATE."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1487 (let ((result (if calendar-debug-sexp
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1488 (let ((stack-trace-on-error t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1489 (eval (car (read-from-string sexp))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1490 (condition-case nil
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1491 (eval (car (read-from-string sexp)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1492 (error
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1493 (beep)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1494 (message "Bad sexp at line %d in %s: %s"
|
65476
|
1495 (count-lines (point-min) (point))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1496 diary-file sexp)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1497 (sleep-for 2))))))
|
46620
|
1498 (cond ((stringp result) result)
|
|
1499 ((and (consp result)
|
|
1500 (stringp (cdr result))) result)
|
|
1501 (result entry)
|
|
1502 (t nil))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1503
|
46620
|
1504 (defun diary-date (month day year &optional mark)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1505 "Specific date(s) diary entry.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1506 Entry applies if date is MONTH, DAY, YEAR if `european-calendar-style' is nil,
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1507 and DAY, MONTH, YEAR if `european-calendar-style' is t. DAY, MONTH, and YEAR
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1508 can be lists of integers, the constant t, or an integer. The constant t means
|
46620
|
1509 all values.
|
|
1510
|
46826
|
1511 An optional parameter MARK specifies a face or single-character string to
|
46620
|
1512 use when highlighting the day in the calendar."
|
51640
|
1513 (let ((dd (if european-calendar-style
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1514 month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1515 day))
|
51640
|
1516 (mm (if european-calendar-style
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1517 day
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1518 month))
|
51640
|
1519 (m (extract-calendar-month date))
|
|
1520 (y (extract-calendar-year date))
|
|
1521 (d (extract-calendar-day date)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1522 (if (and
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1523 (or (and (listp dd) (memq d dd))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1524 (equal d dd)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1525 (eq dd t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1526 (or (and (listp mm) (memq m mm))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1527 (equal m mm)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1528 (eq mm t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1529 (or (and (listp year) (memq y year))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1530 (equal y year)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1531 (eq year t)))
|
48365
|
1532 (cons mark entry))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1533
|
46620
|
1534 (defun diary-block (m1 d1 y1 m2 d2 y2 &optional mark)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1535 "Block diary entry.
|
42513
|
1536 Entry applies if date is between, or on one of, two dates.
|
|
1537 The order of the parameters is
|
23122
|
1538 M1, D1, Y1, M2, D2, Y2 if `european-calendar-style' is nil, and
|
46620
|
1539 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t.
|
|
1540
|
46826
|
1541 An optional parameter MARK specifies a face or single-character string to
|
46620
|
1542 use when highlighting the day in the calendar."
|
|
1543
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1544 (let ((date1 (calendar-absolute-from-gregorian
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1545 (if european-calendar-style
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1546 (list d1 m1 y1)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1547 (list m1 d1 y1))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1548 (date2 (calendar-absolute-from-gregorian
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1549 (if european-calendar-style
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1550 (list d2 m2 y2)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1551 (list m2 d2 y2))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1552 (d (calendar-absolute-from-gregorian date)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1553 (if (and (<= date1 d) (<= d date2))
|
46620
|
1554 (cons mark entry))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1555
|
46620
|
1556 (defun diary-float (month dayname n &optional day mark)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1557 "Floating diary entry--entry applies if date is the nth dayname of month.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1558 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1559 t, or an integer. The constant t means all months. If N is negative, count
|
17892
|
1560 backward from the end of the month.
|
|
1561
|
46620
|
1562 An optional parameter DAY means the Nth DAYNAME on or after/before MONTH DAY.
|
46826
|
1563 Optional MARK specifies a face or single-character string to use when
|
46620
|
1564 highlighting the day in the calendar."
|
17892
|
1565 ;; This is messy because the diary entry may apply, but the date on which it
|
|
1566 ;; is based can be in a different month/year. For example, asking for the
|
|
1567 ;; first Monday after December 30. For large values of |n| the problem is
|
|
1568 ;; more grotesque.
|
|
1569 (and (= dayname (calendar-day-of-week date))
|
|
1570 (let* ((m (extract-calendar-month date))
|
|
1571 (d (extract-calendar-day date))
|
|
1572 (y (extract-calendar-year date))
|
|
1573 (limit; last (n>0) or first (n<0) possible base date for entry
|
|
1574 (calendar-nth-named-absday (- n) dayname m y d))
|
|
1575 (last-abs (if (> n 0) limit (+ limit 6)))
|
|
1576 (first-abs (if (> n 0) (- limit 6) limit))
|
|
1577 (last (calendar-gregorian-from-absolute last-abs))
|
|
1578 (first (calendar-gregorian-from-absolute first-abs))
|
|
1579 ; m1, d1 is first possible base date
|
|
1580 (m1 (extract-calendar-month first))
|
|
1581 (d1 (extract-calendar-day first))
|
|
1582 (y1 (extract-calendar-year first))
|
|
1583 ; m2, d2 is last possible base date
|
|
1584 (m2 (extract-calendar-month last))
|
|
1585 (d2 (extract-calendar-day last))
|
|
1586 (y2 (extract-calendar-year last)))
|
23908
|
1587 (if (or (and (= m1 m2) ; only possible base dates in one month
|
35500
|
1588 (or (eq month t)
|
|
1589 (if (listp month)
|
|
1590 (memq m1 month)
|
|
1591 (= m1 month)))
|
18590
|
1592 (let ((d (or day (if (> n 0)
|
|
1593 1
|
|
1594 (calendar-last-day-of-month m1 y1)))))
|
|
1595 (and (<= d1 d) (<= d d2))))
|
|
1596 ;; only possible base dates straddle two months
|
23998
|
1597 (and (or (< y1 y2)
|
|
1598 (and (= y1 y2) (< m1 m2)))
|
18590
|
1599 (or
|
23908
|
1600 ;; m1, d1 works as a base date
|
18590
|
1601 (and
|
35500
|
1602 (or (eq month t)
|
|
1603 (if (listp month)
|
|
1604 (memq m1 month)
|
|
1605 (= m1 month)))
|
18590
|
1606 (<= d1 (or day (if (> n 0)
|
|
1607 1
|
|
1608 (calendar-last-day-of-month m1 y1)))))
|
23908
|
1609 ;; m2, d2 works as a base date
|
35500
|
1610 (and (or (eq month t)
|
|
1611 (if (listp month)
|
|
1612 (memq m2 month)
|
|
1613 (= m2 month)))
|
18590
|
1614 (<= (or day (if (> n 0)
|
|
1615 1
|
|
1616 (calendar-last-day-of-month m2 y2)))
|
|
1617 d2)))))
|
46620
|
1618 (cons mark entry)))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1619
|
35500
|
1620
|
65875
|
1621 (defun diary-anniversary (month day &optional year mark)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1622 "Anniversary diary entry.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1623 Entry applies if date is the anniversary of MONTH, DAY, YEAR if
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1624 `european-calendar-style' is nil, and DAY, MONTH, YEAR if
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1625 `european-calendar-style' is t. Diary entry can contain `%d' or `%d%s'; the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1626 %d will be replaced by the number of years since the MONTH DAY, YEAR and the
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1627 %s will be replaced by the ordinal ending of that number (that is, `st', `nd',
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1628 `rd' or `th', as appropriate. The anniversary of February 29 is considered
|
46620
|
1629 to be March 1 in non-leap years.
|
|
1630
|
46826
|
1631 An optional parameter MARK specifies a face or single-character string to
|
46620
|
1632 use when highlighting the day in the calendar."
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1633 (let* ((d (if european-calendar-style
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1634 month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1635 day))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1636 (m (if european-calendar-style
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1637 day
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1638 month))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1639 (y (extract-calendar-year date))
|
65875
|
1640 (diff (if year (- y year) 100)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1641 (if (and (= m 2) (= d 29) (not (calendar-leap-year-p y)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1642 (setq m 3
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1643 d 1))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1644 (if (and (> diff 0) (calendar-date-equal (list m d y) date))
|
46620
|
1645 (cons mark (format entry diff (diary-ordinal-suffix diff))))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1646
|
46620
|
1647 (defun diary-cyclic (n month day year &optional mark)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1648 "Cycle diary entry--entry applies every N days starting at MONTH, DAY, YEAR.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1649 If `european-calendar-style' is t, parameters are N, DAY, MONTH, YEAR.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1650 ENTRY can contain `%d' or `%d%s'; the %d will be replaced by the number of
|
32415
|
1651 repetitions since the MONTH DAY, YEAR and %s will be replaced by the
|
|
1652 ordinal ending of that number (that is, `st', `nd', `rd' or `th', as
|
46620
|
1653 appropriate.
|
|
1654
|
46826
|
1655 An optional parameter MARK specifies a face or single-character string to
|
46620
|
1656 use when highlighting the day in the calendar."
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1657 (let* ((d (if european-calendar-style
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1658 month
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1659 day))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1660 (m (if european-calendar-style
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1661 day
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1662 month))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1663 (diff (- (calendar-absolute-from-gregorian date)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1664 (calendar-absolute-from-gregorian
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1665 (list m d year))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1666 (cycle (/ diff n)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1667 (if (and (>= diff 0) (zerop (% diff n)))
|
46620
|
1668 (cons mark (format entry cycle (diary-ordinal-suffix cycle))))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1669
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1670 (defun diary-ordinal-suffix (n)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1671 "Ordinal suffix for N. (That is, `st', `nd', `rd', or `th', as appropriate.)"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1672 (if (or (memq (% n 100) '(11 12 13))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1673 (< 3 (% n 10)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1674 "th"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1675 (aref ["th" "st" "nd" "rd"] (% n 10))))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1676
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1677 (defun diary-day-of-year ()
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1678 "Day of year and number of days remaining in the year of date diary entry."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1679 (calendar-day-of-year-string date))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1680
|
17626
|
1681 (defcustom diary-remind-message
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1682 '("Reminder: Only "
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1683 (if (= 0 (% days 7))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1684 (concat (int-to-string (/ days 7)) (if (= 7 days) " week" " weeks"))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1685 (concat (int-to-string days) (if (= 1 days) " day" " days")))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1686 " until "
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1687 diary-entry)
|
65875
|
1688 "Pseudo-pattern giving form of reminder messages in the fancy diary
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1689 display.
|
39615
|
1690
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1691 Used by the function `diary-remind', a pseudo-pattern is a list of
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1692 expressions that can involve the keywords `days' (a number), `date' (a list of
|
17626
|
1693 month, day, year), and `diary-entry' (a string)."
|
|
1694 :type 'sexp
|
|
1695 :group 'diary)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1696
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1697 (defun diary-remind (sexp days &optional marking)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1698 "Provide a reminder of a diary entry.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1699 SEXP is a diary-sexp. DAYS is either a single number or a list of numbers
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1700 indicating the number(s) of days before the event that the warning(s) should
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1701 occur on. If the current date is (one of) DAYS before the event indicated by
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1702 SEXP, then a suitable message (as specified by `diary-remind-message' is
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1703 returned.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1704
|
24684
|
1705 In addition to the reminders beforehand, the diary entry also appears on the
|
|
1706 date itself.
|
|
1707
|
|
1708 A `diary-nonmarking-symbol' at the beginning of the line of the diary-remind
|
|
1709 entry specifies that the diary entry (not the reminder) is non-marking.
|
|
1710 Marking of reminders is independent of whether the entry itself is a marking
|
|
1711 or nonmarking; if optional parameter MARKING is non-nil then the reminders are
|
|
1712 marked on the calendar."
|
|
1713 (let ((diary-entry (eval sexp)))
|
|
1714 (cond
|
|
1715 ;; Diary entry applies on date
|
|
1716 ((and diary-entry
|
|
1717 (or (not marking-diary-entries) marking-diary-entry))
|
|
1718 diary-entry)
|
|
1719 ;; Diary entry may apply to `days' before date
|
|
1720 ((and (integerp days)
|
|
1721 (not diary-entry); Diary entry does not apply to date
|
|
1722 (or (not marking-diary-entries) marking))
|
|
1723 (let ((date (calendar-gregorian-from-absolute
|
|
1724 (+ (calendar-absolute-from-gregorian date) days))))
|
60298
|
1725 (when (setq diary-entry (eval sexp)) ; re-evaluate with adjusted date
|
|
1726 ;; Discard any mark portion from diary-anniversary, etc.
|
|
1727 (if (consp diary-entry) (setq diary-entry (cdr diary-entry)))
|
|
1728 (mapconcat 'eval diary-remind-message ""))))
|
24684
|
1729 ;; Diary entry may apply to one of a list of days before date
|
|
1730 ((and (listp days) days)
|
|
1731 (or (diary-remind sexp (car days) marking)
|
|
1732 (diary-remind sexp (cdr days) marking))))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1733
|
60321
|
1734 (defun diary-redraw-calendar ()
|
|
1735 "If `calendar-buffer' is live and diary entries are marked, redraw it."
|
|
1736 (and mark-diary-entries-in-calendar
|
60650
|
1737 (save-excursion
|
|
1738 (redraw-calendar)))
|
60321
|
1739 ;; Return value suitable for `write-contents-functions'.
|
|
1740 nil)
|
|
1741
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1742 (defun make-diary-entry (string &optional nonmarking file)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1743 "Insert a diary entry STRING which may be NONMARKING in FILE.
|
60321
|
1744 If omitted, NONMARKING defaults to nil and FILE defaults to
|
65875
|
1745 `diary-file'."
|
52319
|
1746 (let ((pop-up-frames (window-dedicated-p (selected-window))))
|
|
1747 (find-file-other-window (substitute-in-file-name (or file diary-file))))
|
66869
|
1748 (when (eq major-mode default-major-mode) (diary-mode))
|
48312
67f6a633fe52
calendar/diary-lib.el (make-diary-entry): Allow for local variables at end of
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1749 (widen)
|
65476
|
1750 (diary-unhide-everything)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1751 (goto-char (point-max))
|
48312
67f6a633fe52
calendar/diary-lib.el (make-diary-entry): Allow for local variables at end of
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1752 (when (let ((case-fold-search t))
|
67f6a633fe52
calendar/diary-lib.el (make-diary-entry): Allow for local variables at end of
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1753 (search-backward "Local Variables:"
|
67f6a633fe52
calendar/diary-lib.el (make-diary-entry): Allow for local variables at end of
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1754 (max (- (point-max) 3000) (point-min))
|
67f6a633fe52
calendar/diary-lib.el (make-diary-entry): Allow for local variables at end of
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1755 t))
|
67f6a633fe52
calendar/diary-lib.el (make-diary-entry): Allow for local variables at end of
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1756 (beginning-of-line)
|
67f6a633fe52
calendar/diary-lib.el (make-diary-entry): Allow for local variables at end of
Juanma Barranquero <lekktu@gmail.com>
diff
changeset
|
1757 (insert "\n")
|
65476
|
1758 (forward-line -1))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1759 (insert
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1760 (if (bolp) "" "\n")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1761 (if nonmarking diary-nonmarking-symbol "")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1762 string " "))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1763
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1764 (defun insert-diary-entry (arg)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1765 "Insert a diary entry for the date indicated by point.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1766 Prefix arg will make the entry nonmarking."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1767 (interactive "P")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1768 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1769 arg))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1770
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1771 (defun insert-weekly-diary-entry (arg)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1772 "Insert a weekly diary entry for the day of the week indicated by point.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1773 Prefix arg will make the entry nonmarking."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1774 (interactive "P")
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1775 (make-diary-entry (calendar-day-name (calendar-cursor-to-date t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1776 arg))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1777
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1778 (defun insert-monthly-diary-entry (arg)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1779 "Insert a monthly diary entry for the day of the month indicated by point.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1780 Prefix arg will make the entry nonmarking."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1781 (interactive "P")
|
51640
|
1782 (let ((calendar-date-display-form
|
|
1783 (if european-calendar-style
|
|
1784 '(day " * ")
|
|
1785 '("* " day))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1786 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1787 arg)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1788
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1789 (defun insert-yearly-diary-entry (arg)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1790 "Insert an annual diary entry for the day of the year indicated by point.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1791 Prefix arg will make the entry nonmarking."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1792 (interactive "P")
|
51640
|
1793 (let ((calendar-date-display-form
|
|
1794 (if european-calendar-style
|
|
1795 '(day " " monthname)
|
|
1796 '(monthname " " day))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1797 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1798 arg)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1799
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1800 (defun insert-anniversary-diary-entry (arg)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1801 "Insert an anniversary diary entry for the date given by point.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1802 Prefix arg will make the entry nonmarking."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1803 (interactive "P")
|
51640
|
1804 (let ((calendar-date-display-form
|
|
1805 (if european-calendar-style
|
|
1806 '(day " " month " " year)
|
|
1807 '(month " " day " " year))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1808 (make-diary-entry
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1809 (format "%s(diary-anniversary %s)"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1810 sexp-diary-entry-symbol
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1811 (calendar-date-string (calendar-cursor-to-date t) nil t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1812 arg)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1813
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1814 (defun insert-block-diary-entry (arg)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1815 "Insert a block diary entry for the days between the point and marked date.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1816 Prefix arg will make the entry nonmarking."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1817 (interactive "P")
|
51640
|
1818 (let ((calendar-date-display-form
|
|
1819 (if european-calendar-style
|
|
1820 '(day " " month " " year)
|
|
1821 '(month " " day " " year)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1822 (cursor (calendar-cursor-to-date t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1823 (mark (or (car calendar-mark-ring)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1824 (error "No mark set in this buffer")))
|
51640
|
1825 start end)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1826 (if (< (calendar-absolute-from-gregorian mark)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1827 (calendar-absolute-from-gregorian cursor))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1828 (setq start mark
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1829 end cursor)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1830 (setq start cursor
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1831 end mark))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1832 (make-diary-entry
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1833 (format "%s(diary-block %s %s)"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1834 sexp-diary-entry-symbol
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1835 (calendar-date-string start nil t)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1836 (calendar-date-string end nil t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1837 arg)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1838
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1839 (defun insert-cyclic-diary-entry (arg)
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1840 "Insert a cyclic diary entry starting at the date given by point.
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1841 Prefix arg will make the entry nonmarking."
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1842 (interactive "P")
|
51640
|
1843 (let ((calendar-date-display-form
|
|
1844 (if european-calendar-style
|
|
1845 '(day " " month " " year)
|
|
1846 '(month " " day " " year))))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1847 (make-diary-entry
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1848 (format "%s(diary-cyclic %d %s)"
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1849 sexp-diary-entry-symbol
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1850 (calendar-read "Repeat every how many days: "
|
28615
|
1851 (lambda (x) (> x 0)))
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1852 (calendar-date-string (calendar-cursor-to-date t) nil t))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1853 arg)))
|
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
1854
|
65476
|
1855 (defvar diary-mode-map
|
|
1856 (let ((map (make-sparse-keymap)))
|
|
1857 (define-key map "\C-c\C-s" 'diary-show-all-entries)
|
|
1858 (define-key map "\C-c\C-q" 'quit-window)
|
|
1859 map)
|
|
1860 "Keymap for `diary-mode'.")
|
|
1861
|
48365
|
1862 ;;;###autoload
|
65476
|
1863 (define-derived-mode diary-mode fundamental-mode "Diary"
|
48365
|
1864 "Major mode for editing the diary file."
|
|
1865 (set (make-local-variable 'font-lock-defaults)
|
65476
|
1866 '(diary-font-lock-keywords t))
|
|
1867 (add-to-invisibility-spec '(diary . nil))
|
|
1868 (add-hook 'after-save-hook 'diary-redraw-calendar nil t)
|
|
1869 (if diary-header-line-flag
|
|
1870 (setq header-line-format diary-header-line-format)))
|
48365
|
1871
|
70728
|
1872
|
|
1873 (defvar diary-fancy-date-pattern
|
|
1874 (concat
|
|
1875 (let ((dayname (diary-name-pattern calendar-day-name-array nil t))
|
|
1876 (monthname (diary-name-pattern calendar-month-name-array nil t))
|
|
1877 (day "[0-9]+")
|
|
1878 (month "[0-9]+")
|
|
1879 (year "-?[0-9]+"))
|
|
1880 (mapconcat 'eval calendar-date-display-form ""))
|
|
1881 ;; Optional ": holiday name" after the date.
|
|
1882 "\\(: .*\\)?")
|
|
1883 "Regular expression matching a date header in Fancy Diary.")
|
|
1884
|
|
1885 (defconst diary-time-regexp
|
|
1886 ;; Accepted formats: 10:00 10.00 10h00 10h 10am 10:00am 10.00am
|
|
1887 ;; Use of "." as a separator annoyingly matches numbers, eg "123.45".
|
|
1888 ;; Hence often prefix this with "\\(^\\|\\s-\\)."
|
|
1889 (concat "[0-9]?[0-9]\\([AaPp][mM]\\|\\("
|
|
1890 "[Hh]\\([0-9][0-9]\\)?\\|[:.][0-9][0-9]"
|
|
1891 "\\)\\([AaPp][Mm]\\)?\\)")
|
|
1892 "Regular expression matching a time of day.")
|
|
1893
|
|
1894 (defface diary-anniversary '((t :inherit font-lock-keyword-face))
|
|
1895 "Face used for anniversaries in the diary."
|
|
1896 :version "22.1"
|
|
1897 :group 'diary)
|
|
1898
|
|
1899 (defface diary-time '((t :inherit font-lock-variable-name-face))
|
|
1900 "Face used for times of day in the diary."
|
|
1901 :version "22.1"
|
|
1902 :group 'diary)
|
|
1903
|
|
1904 (defvar fancy-diary-font-lock-keywords
|
|
1905 (list
|
|
1906 (list
|
|
1907 ;; Any number of " other holiday name" lines, followed by "==" line.
|
|
1908 (concat diary-fancy-date-pattern "\\(\n +.*\\)*\n=+$")
|
|
1909 '(0 (progn (put-text-property (match-beginning 0) (match-end 0)
|
|
1910 'font-lock-multiline t)
|
|
1911 diary-face)))
|
|
1912 '("^.*\\([aA]nniversary\\|[bB]irthday\\).*$" . 'diary-anniversary)
|
|
1913 '("^.*Yahrzeit.*$" . font-lock-reference-face)
|
|
1914 '("^\\(Erev \\)?Rosh Hodesh.*" . font-lock-function-name-face)
|
|
1915 '("^Day.*omer.*$" . font-lock-builtin-face)
|
|
1916 '("^Parashat.*$" . font-lock-comment-face)
|
|
1917 `(,(format "\\(^\\|\\s-\\)%s\\(-%s\\)?" diary-time-regexp
|
|
1918 diary-time-regexp) . 'diary-time))
|
|
1919 "Keywords to highlight in fancy diary display")
|
|
1920
|
|
1921 ;; If region looks like it might start or end in the middle of a
|
|
1922 ;; multiline pattern, extend the region to encompass the whole pattern.
|
|
1923 (defun diary-fancy-font-lock-fontify-region-function (beg end &optional verbose)
|
|
1924 "Function to use for `font-lock-fontify-region-function' in Fancy Diary.
|
|
1925 Needed to handle multiline keyword in `fancy-diary-font-lock-keywords'."
|
|
1926 (goto-char beg)
|
|
1927 (forward-line 0)
|
|
1928 (if (looking-at "=+$") (forward-line -1))
|
|
1929 (while (and (looking-at " +[^ ]")
|
|
1930 (zerop (forward-line -1))))
|
|
1931 ;; This check not essential.
|
|
1932 (if (looking-at diary-fancy-date-pattern)
|
|
1933 (setq beg (line-beginning-position)))
|
|
1934 (goto-char end)
|
|
1935 (forward-line 0)
|
|
1936 (while (and (looking-at " +[^ ]")
|
|
1937 (zerop (forward-line 1))))
|
|
1938 (if (looking-at "=+$")
|
|
1939 (setq end (line-beginning-position 2)))
|
|
1940 (font-lock-default-fontify-region beg end verbose))
|
|
1941
|
54757
|
1942 (define-derived-mode fancy-diary-display-mode fundamental-mode
|
48365
|
1943 "Diary"
|
|
1944 "Major mode used while displaying diary entries using Fancy Display."
|
|
1945 (set (make-local-variable 'font-lock-defaults)
|
70728
|
1946 '(fancy-diary-font-lock-keywords
|
|
1947 t nil nil nil
|
|
1948 (font-lock-fontify-region-function
|
|
1949 . diary-fancy-font-lock-fontify-region-function)))
|
65476
|
1950 (local-set-key "q" 'quit-window))
|
48365
|
1951
|
|
1952
|
65476
|
1953 (defun diary-font-lock-sexps (limit)
|
48365
|
1954 "Recognize sexp diary entry for font-locking."
|
|
1955 (if (re-search-forward
|
|
1956 (concat "^" (regexp-quote diary-nonmarking-symbol)
|
|
1957 "?\\(" (regexp-quote sexp-diary-entry-symbol) "\\)")
|
|
1958 limit t)
|
|
1959 (condition-case nil
|
|
1960 (save-restriction
|
|
1961 (narrow-to-region (point-min) limit)
|
|
1962 (let ((start (point)))
|
|
1963 (forward-sexp 1)
|
|
1964 (store-match-data (list start (point)))
|
|
1965 t))
|
|
1966 (error t))))
|
|
1967
|
65476
|
1968 (defun diary-font-lock-date-forms (month-array &optional symbol abbrev-array)
|
52117
|
1969 "Create font-lock patterns for `diary-date-forms' using MONTH-ARRAY.
|
48365
|
1970 If given, optional SYMBOL must be a prefix to entries.
|
52117
|
1971 If optional ABBREV-ARRAY is present, the abbreviations constructed
|
|
1972 from this array by the function `calendar-abbrev-construct' are
|
|
1973 matched (with or without a final `.'), in addition to the full month
|
|
1974 names."
|
|
1975 (let ((dayname (diary-name-pattern calendar-day-name-array
|
|
1976 calendar-day-abbrev-array t))
|
|
1977 (monthname (format "\\(%s\\|\\*\\)"
|
|
1978 (diary-name-pattern month-array abbrev-array)))
|
51640
|
1979 (month "\\([0-9]+\\|\\*\\)")
|
|
1980 (day "\\([0-9]+\\|\\*\\)")
|
|
1981 (year "-?\\([0-9]+\\|\\*\\)"))
|
65476
|
1982 (mapcar (lambda (x)
|
48365
|
1983 (cons
|
|
1984 (concat "^" (regexp-quote diary-nonmarking-symbol) "?"
|
|
1985 (if symbol (regexp-quote symbol) "") "\\("
|
|
1986 (mapconcat 'eval
|
|
1987 ;; If backup, omit first item (backup)
|
|
1988 ;; and last item (not part of date)
|
|
1989 (if (equal (car x) 'backup)
|
65476
|
1990 (nreverse (cdr (reverse (cdr x))))
|
48365
|
1991 x)
|
|
1992 "")
|
|
1993 ;; With backup, last item is not part of date
|
|
1994 (if (equal (car x) 'backup)
|
|
1995 (concat "\\)" (eval (car (reverse x))))
|
|
1996 "\\)"))
|
|
1997 '(1 diary-face)))
|
|
1998 diary-date-forms)))
|
|
1999
|
52117
|
2000 (eval-when-compile (require 'cal-hebrew)
|
|
2001 (require 'cal-islam))
|
|
2002
|
77043
|
2003 (defun diary-font-lock-keywords ()
|
|
2004 "Return a value for the variable `diary-font-lock-keywords'."
|
|
2005 (append
|
|
2006 (diary-font-lock-date-forms calendar-month-name-array
|
|
2007 nil calendar-month-abbrev-array)
|
|
2008 (when (or (memq 'mark-hebrew-diary-entries
|
|
2009 nongregorian-diary-marking-hook)
|
|
2010 (memq 'list-hebrew-diary-entries
|
|
2011 nongregorian-diary-listing-hook))
|
|
2012 (require 'cal-hebrew)
|
|
2013 (diary-font-lock-date-forms
|
|
2014 calendar-hebrew-month-name-array-leap-year
|
|
2015 hebrew-diary-entry-symbol))
|
|
2016 (when (or (memq 'mark-islamic-diary-entries
|
|
2017 nongregorian-diary-marking-hook)
|
|
2018 (memq 'list-islamic-diary-entries
|
|
2019 nongregorian-diary-listing-hook))
|
|
2020 (require 'cal-islam)
|
|
2021 (diary-font-lock-date-forms
|
|
2022 calendar-islamic-month-name-array
|
|
2023 islamic-diary-entry-symbol))
|
|
2024 (list
|
|
2025 (cons
|
|
2026 (concat "^" (regexp-quote diary-include-string) ".*$")
|
|
2027 'font-lock-keyword-face)
|
|
2028 (cons
|
|
2029 (concat "^" (regexp-quote diary-nonmarking-symbol)
|
|
2030 "?\\(" (regexp-quote sexp-diary-entry-symbol) "\\)")
|
|
2031 '(1 font-lock-reference-face))
|
|
2032 (cons
|
|
2033 (concat "^" (regexp-quote diary-nonmarking-symbol))
|
|
2034 'font-lock-reference-face)
|
|
2035 (cons
|
|
2036 (concat "^" (regexp-quote diary-nonmarking-symbol)
|
|
2037 "?\\(" (regexp-quote hebrew-diary-entry-symbol) "\\)")
|
|
2038 '(1 font-lock-reference-face))
|
|
2039 (cons
|
|
2040 (concat "^" (regexp-quote diary-nonmarking-symbol)
|
|
2041 "?\\(" (regexp-quote islamic-diary-entry-symbol) "\\)")
|
|
2042 '(1 font-lock-reference-face))
|
|
2043 '(diary-font-lock-sexps . font-lock-keyword-face)
|
|
2044 `(,(concat "\\(^\\|\\s-\\)"
|
|
2045 diary-time-regexp "\\(-" diary-time-regexp "\\)?")
|
|
2046 . 'diary-time))))
|
49598
|
2047
|
77043
|
2048 (defvar diary-font-lock-keywords (diary-font-lock-keywords)
|
|
2049 "Forms to highlight in `diary-mode'.")
|
48365
|
2050
|
55249
|
2051 ;; Following code from Dave Love <fx@gnu.org>.
|
|
2052 ;; Import Outlook-format appointments from mail messages in Gnus or
|
|
2053 ;; Rmail using command `diary-from-outlook'. This, or the specialized
|
|
2054 ;; functions `diary-from-outlook-gnus' and `diary-from-outlook-rmail',
|
|
2055 ;; could be run from hooks to notice appointments automatically (in
|
|
2056 ;; which case they will prompt about adding to the diary). The
|
|
2057 ;; message formats recognized are customizable through
|
|
2058 ;; `diary-outlook-formats'.
|
|
2059
|
|
2060 (defcustom diary-outlook-formats
|
|
2061 '(
|
|
2062 ;; When: 11 October 2001 12:00-14:00 (GMT) Greenwich Mean Time : Dublin, ...
|
|
2063 ;; [Current UK format? The timezone is meaningless. Sometimes the
|
|
2064 ;; Where is missing.]
|
|
2065 ("When: \\([0-9]+ [[:alpha:]]+ [0-9]+\\) \
|
|
2066 \\([^ ]+\\) [^\n]+
|
|
2067 \[^\n]+
|
|
2068 \\(?:Where: \\([^\n]+\\)\n+\\)?
|
|
2069 \\*~\\*~\\*~\\*~\\*~\\*~\\*~\\*~\\*~\\*"
|
|
2070 . "\\1\n \\2 %s, \\3")
|
|
2071 ;; When: Tuesday, April 30, 2002 03:00 PM-03:30 PM (GMT) Greenwich Mean ...
|
|
2072 ;; [Old UK format?]
|
|
2073 ("^When: [[:alpha:]]+, \\([[:alpha:]]+\\) \\([0-9][0-9]*\\), \\([0-9]\\{4\\}\\) \
|
|
2074 \\([^ ]+\\) [^\n]+
|
|
2075 \[^\n]+
|
|
2076 \\(?:Where: \\([^\n]+\\)\\)?\n+"
|
|
2077 . "\\2 \\1 \\3\n \\4 %s, \\5")
|
|
2078 (
|
|
2079 ;; German format, apparently.
|
|
2080 "^Zeit: [^ ]+, +\\([0-9]+\\)\. +\\([[:upper:]][[:lower:]][[:lower:]]\\)[^ ]* +\\([0-9]+\\) +\\([^ ]+\\).*$"
|
|
2081 . "\\1 \\2 \\3\n \\4 %s"))
|
|
2082 "Alist of regexps matching message text and replacement text.
|
|
2083
|
|
2084 The regexp must match the start of the message text containing an
|
|
2085 appointment, but need not include a leading `^'. If it matches the
|
|
2086 current message, a diary entry is made from the corresponding
|
|
2087 template. If the template is a string, it should be suitable for
|
|
2088 passing to `replace-match', and so will have occurrences of `\\D' to
|
|
2089 substitute the match for the Dth subexpression. It must also contain
|
|
2090 a single `%s' which will be replaced with the text of the message's
|
|
2091 Subject field. Any other `%' characters must be doubled, so that the
|
|
2092 template can be passed to `format'.
|
|
2093
|
|
2094 If the template is actually a function, it is called with the message
|
|
2095 body text as argument, and may use `match-string' etc. to make a
|
|
2096 template following the rules above."
|
|
2097 :type '(alist :key-type (regexp :tag "Regexp matching time/place")
|
|
2098 :value-type (choice
|
|
2099 (string :tag "Template for entry")
|
|
2100 (function :tag "Unary function providing template")))
|
59996
|
2101 :version "22.1"
|
55249
|
2102 :group 'diary)
|
|
2103
|
|
2104
|
|
2105 ;; Dynamically bound.
|
|
2106 (defvar body)
|
|
2107 (defvar subject)
|
|
2108
|
|
2109 (defun diary-from-outlook-internal (&optional test-only)
|
|
2110 "Snarf a diary entry from a message assumed to be from MS Outlook.
|
|
2111 Assumes `body' is bound to a string comprising the body of the message and
|
|
2112 `subject' is bound to a string comprising its subject.
|
|
2113 Arg TEST-ONLY non-nil means return non-nil if and only if the
|
|
2114 message contains an appointment, don't make a diary entry."
|
|
2115 (catch 'finished
|
|
2116 (let (format-string)
|
|
2117 (dotimes (i (length diary-outlook-formats))
|
|
2118 (when (eq 0 (string-match (car (nth i diary-outlook-formats))
|
|
2119 body))
|
|
2120 (unless test-only
|
|
2121 (setq format-string (cdr (nth i diary-outlook-formats)))
|
|
2122 (save-excursion
|
|
2123 (save-window-excursion
|
|
2124 ;; Fixme: References to optional fields in the format
|
|
2125 ;; are treated literally, not replaced by the empty
|
|
2126 ;; string. I think this is an Emacs bug.
|
|
2127 (make-diary-entry
|
|
2128 (format (replace-match (if (functionp format-string)
|
|
2129 (funcall format-string body)
|
|
2130 format-string)
|
|
2131 t nil (match-string 0 body))
|
|
2132 subject))
|
|
2133 (save-buffer))))
|
|
2134 (throw 'finished t))))
|
|
2135 nil))
|
|
2136
|
58101
|
2137 (defun diary-from-outlook (&optional noconfirm)
|
55249
|
2138 "Maybe snarf diary entry from current Outlook-generated message.
|
58099
|
2139 Currently knows about Gnus and Rmail modes. Unless the optional
|
58101
|
2140 argument NOCONFIRM is non-nil (which is the case when this
|
58099
|
2141 function is called interactively), then if an entry is found the
|
|
2142 user is asked to confirm its addition."
|
|
2143 (interactive "p")
|
55249
|
2144 (let ((func (cond
|
|
2145 ((eq major-mode 'rmail-mode)
|
|
2146 #'diary-from-outlook-rmail)
|
|
2147 ((memq major-mode '(gnus-summary-mode gnus-article-mode))
|
|
2148 #'diary-from-outlook-gnus)
|
|
2149 (t (error "Don't know how to snarf in `%s'" major-mode)))))
|
58101
|
2150 (funcall func noconfirm)))
|
55249
|
2151
|
|
2152
|
|
2153 (defvar gnus-article-mime-handles)
|
|
2154 (defvar gnus-article-buffer)
|
|
2155
|
|
2156 (autoload 'gnus-fetch-field "gnus-util")
|
|
2157 (autoload 'gnus-narrow-to-body "gnus")
|
|
2158 (autoload 'mm-get-part "mm-decode")
|
|
2159
|
58101
|
2160 (defun diary-from-outlook-gnus (&optional noconfirm)
|
55249
|
2161 "Maybe snarf diary entry from Outlook-generated message in Gnus.
|
58101
|
2162 Unless the optional argument NOCONFIRM is non-nil (which is the case when
|
58099
|
2163 this function is called interactively), then if an entry is found the
|
|
2164 user is asked to confirm its addition.
|
|
2165 Add this function to `gnus-article-prepare-hook' to notice appointments
|
55249
|
2166 automatically."
|
58099
|
2167 (interactive "p")
|
55249
|
2168 (with-current-buffer gnus-article-buffer
|
|
2169 (let ((subject (gnus-fetch-field "subject"))
|
|
2170 (body (if gnus-article-mime-handles
|
|
2171 ;; We're multipart. Don't get confused by part
|
|
2172 ;; buttons &c. Assume info is in first part.
|
|
2173 (mm-get-part (nth 1 gnus-article-mime-handles))
|
|
2174 (save-restriction
|
|
2175 (gnus-narrow-to-body)
|
|
2176 (buffer-string)))))
|
|
2177 (when (diary-from-outlook-internal t)
|
58101
|
2178 (when (or noconfirm (y-or-n-p "Snarf diary entry? "))
|
55249
|
2179 (diary-from-outlook-internal)
|
|
2180 (message "Diary entry added"))))))
|
|
2181
|
|
2182 (custom-add-option 'gnus-article-prepare-hook 'diary-from-outlook-gnus)
|
|
2183
|
|
2184
|
|
2185 (defvar rmail-buffer)
|
|
2186
|
58101
|
2187 (defun diary-from-outlook-rmail (&optional noconfirm)
|
58099
|
2188 "Maybe snarf diary entry from Outlook-generated message in Rmail.
|
58101
|
2189 Unless the optional argument NOCONFIRM is non-nil (which is the case when
|
58099
|
2190 this function is called interactively), then if an entry is found the
|
|
2191 user is asked to confirm its addition."
|
|
2192 (interactive "p")
|
55249
|
2193 (with-current-buffer rmail-buffer
|
|
2194 (let ((subject (mail-fetch-field "subject"))
|
|
2195 (body (buffer-substring (save-excursion
|
|
2196 (rfc822-goto-eoh)
|
|
2197 (point))
|
|
2198 (point-max))))
|
|
2199 (when (diary-from-outlook-internal t)
|
58101
|
2200 (when (or noconfirm (y-or-n-p "Snarf diary entry? "))
|
55249
|
2201 (diary-from-outlook-internal)
|
|
2202 (message "Diary entry added"))))))
|
|
2203
|
|
2204
|
13650
|
2205 (provide 'diary-lib)
|
13053
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff
changeset
|
2206
|
65476
|
2207 ;; arch-tag: 22dd506e-2e33-410d-9ae1-095a0c1b2010
|
13650
|
2208 ;;; diary-lib.el ends here
|