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