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