annotate lisp/calendar/diary-lib.el @ 110502:10e44274dbb4

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