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