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