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