Commit | Line | Data |
---|---|---|
6f585e44 | 1 | @c This is part of the Emacs manual. |
5df4f04c | 2 | @c Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
d21d2618 | 3 | @c Free Software Foundation, Inc. |
6f585e44 EZ |
4 | @c See file emacs.texi for copying conditions. |
5 | @c | |
c5184807 EZ |
6 | @c This file is included either in emacs-xtra.texi (when producing the |
7 | @c printed version) or in the main Emacs manual (for the on-line version). | |
8 | ||
9 | @c Moved here from the Emacs Lisp Reference Manual, 2005-03-26. | |
10 | @node Advanced Calendar/Diary Usage | |
11 | @section Customizing the Calendar and Diary | |
12 | ||
13 | There are many customizations that you can use to make the calendar and | |
14 | diary suit your personal tastes. | |
15 | ||
16 | @menu | |
f9b4c05d | 17 | * Calendar Customizing:: Calendar layout and hooks. |
c5184807 EZ |
18 | * Holiday Customizing:: Defining your own holidays. |
19 | * Date Display Format:: Changing the format. | |
20 | * Time Display Format:: Changing the format. | |
21 | * Diary Customizing:: Defaults you can set. | |
f9b4c05d | 22 | * Non-Gregorian Diary:: Diary entries based on other calendars. |
cad04c66 GM |
23 | * Diary Display:: A choice of ways to display the diary. |
24 | * Fancy Diary Display:: Sorting diary entries, using included diary files. | |
25 | * Sexp Diary Entries:: More flexible diary entries. | |
c5184807 EZ |
26 | @end menu |
27 | ||
28 | @node Calendar Customizing | |
29 | @subsection Customizing the Calendar | |
a43a8a2e GM |
30 | |
31 | @vindex calendar-intermonth-text | |
32 | @cindex calendar layout | |
f9b4c05d GM |
33 | @cindex calendar week numbers |
34 | The calendar display unfortunately cannot be changed from three | |
35 | months, but you can customize the whitespace used by setting the | |
36 | variables: @code{calendar-left-margin}, | |
c1e67aad GM |
37 | @code{calendar-day-header-width}, @code{calendar-day-digit-width}, |
38 | @code{calendar-column-width}, and @code{calendar-intermonth-spacing}. | |
f9b4c05d GM |
39 | To display text @emph{between} the months, for example week numbers, |
40 | customize the variables @code{calendar-intermonth-header} and | |
41 | @code{calendar-intermonth-text} as described in their documentation. | |
a43a8a2e | 42 | |
c5184807 EZ |
43 | @vindex calendar-holiday-marker |
44 | @vindex diary-entry-marker | |
f9b4c05d | 45 | @vindex calenday-today-marker |
c5184807 | 46 | The variable @code{calendar-holiday-marker} specifies how to mark a |
f9b4c05d GM |
47 | date as being a holiday. Its value may be a single-character string to |
48 | insert next to the date, or a face name to use for displaying the date. | |
49 | Likewise, the variable @code{diary-entry-marker} specifies how to mark a | |
50 | date that has diary entries, and @code{calenday-today-marker} is used by | |
51 | the function @code{calendar-mark-today} to mark today's date. By | |
52 | default, the calendar uses faces named @code{holiday}, @code{diary}, and | |
53 | @code{calendar-today} for these purposes. | |
c5184807 EZ |
54 | |
55 | @vindex calendar-load-hook | |
56 | The variable @code{calendar-load-hook} is a normal hook run when the | |
57 | calendar package is first loaded (before actually starting to display | |
58 | the calendar). | |
59 | ||
36c0514c | 60 | @vindex calendar-initial-window-hook |
c5184807 | 61 | Starting the calendar runs the normal hook |
36c0514c | 62 | @code{calendar-initial-window-hook}. Recomputation of the calendar |
c5184807 EZ |
63 | display does not run this hook. But if you leave the calendar with the |
64 | @kbd{q} command and reenter it, the hook runs again.@refill | |
65 | ||
36c0514c | 66 | @vindex calendar-today-visible-hook |
f9b4c05d | 67 | @findex calendar-star-date |
36c0514c | 68 | The variable @code{calendar-today-visible-hook} is a normal hook run |
c5184807 EZ |
69 | after the calendar buffer has been prepared with the calendar when the |
70 | current date is visible in the window. One use of this hook is to | |
f9b4c05d GM |
71 | mark today's date; to do that use either of the functions |
72 | @code{calendar-mark-today} or @code{calendar-star-date}: | |
c5184807 EZ |
73 | |
74 | @findex calendar-mark-today | |
f9b4c05d | 75 | @smallexample |
36c0514c | 76 | (add-hook 'calendar-today-visible-hook 'calendar-mark-today) |
f9b4c05d | 77 | @end smallexample |
c5184807 | 78 | |
36c0514c | 79 | @vindex calendar-today-invisible-hook |
c5184807 | 80 | @noindent |
36c0514c | 81 | A similar normal hook, @code{calendar-today-invisible-hook} is run if |
c5184807 EZ |
82 | the current date is @emph{not} visible in the window. |
83 | ||
84 | @vindex calendar-move-hook | |
85 | Each of the calendar cursor motion commands runs the hook | |
86 | @code{calendar-move-hook} after it moves the cursor. | |
87 | ||
88 | @node Holiday Customizing | |
89 | @subsection Customizing the Holidays | |
90 | ||
91 | @vindex calendar-holidays | |
f9b4c05d GM |
92 | @vindex holiday-oriental-holidays |
93 | @vindex holiday-solar-holidays | |
c5184807 | 94 | Emacs knows about holidays defined by entries on one of several lists. |
c1e67aad GM |
95 | The lists of holidays that Emacs uses are for |
96 | general holidays (@code{holiday-general-holidays}), | |
97 | local holidays (@code{holiday-local-holidays}), | |
98 | sun- and moon-related holidays (@code{holiday-solar-holidays}), | |
99 | Baha'i holidays (@code{holiday-bahai-holidays}), | |
100 | Christian holidays (@code{holiday-christian-holidays}), | |
101 | Hebrew (Jewish) holidays (@code{holiday-hebrew-holidays}), | |
102 | Islamic (Muslim) holidays (@code{holiday-islamic-holidays}), | |
103 | Oriental holidays (@code{holiday-oriental-holidays}), | |
104 | and other holidays (@code{holiday-other-holidays}). | |
36c0514c | 105 | |
f9b4c05d GM |
106 | You can customize these lists of holidays to your own needs, deleting or |
107 | adding holidays as described below. Set any of them to @code{nil} to | |
108 | eliminate the associated holidays. | |
109 | ||
36c0514c | 110 | @vindex holiday-general-holidays |
c5184807 | 111 | The general holidays are, by default, holidays common throughout the |
f9b4c05d | 112 | United States. |
c5184807 | 113 | |
36c0514c | 114 | @vindex holiday-local-holidays |
f9b4c05d | 115 | There are no default local holidays, but your site may supply some. |
c5184807 | 116 | |
f9b4c05d GM |
117 | @vindex holiday-bahai-holidays |
118 | @vindex holiday-christian-holidays | |
119 | @vindex holiday-hebrew-holidays | |
120 | @vindex holiday-islamic-holidays | |
36c0514c GM |
121 | @vindex calendar-bahai-all-holidays-flag |
122 | @vindex calendar-christian-all-holidays-flag | |
123 | @vindex calendar-hebrew-all-holidays-flag | |
124 | @vindex calendar-islamic-all-holidays-flag | |
c5184807 EZ |
125 | By default, Emacs does not include all the holidays of the religions |
126 | that it knows, only those commonly found in secular calendars. For a | |
127 | more extensive collection of religious holidays, you can set any (or | |
36c0514c GM |
128 | all) of the variables @code{calendar-bahai-all-holidays-flag}, |
129 | @code{calendar-christian-all-holidays-flag}, | |
130 | @code{calendar-hebrew-all-holidays-flag}, or | |
f9b4c05d | 131 | @code{calendar-islamic-all-holidays-flag} to @code{t}. |
c5184807 | 132 | |
36c0514c GM |
133 | @vindex holiday-other-holidays |
134 | You can set the variable @code{holiday-other-holidays} to any list of | |
c5184807 EZ |
135 | holidays. This list, normally empty, is intended for individual use. |
136 | ||
137 | @cindex holiday forms | |
f9b4c05d GM |
138 | Each of the holiday variables is a list of @dfn{holiday forms}, each |
139 | form describing a holiday (or sometimes a list of holidays). | |
c5184807 EZ |
140 | |
141 | Here is a table of the possible kinds of holiday form. Day numbers | |
142 | and month numbers count starting from 1, but ``dayname'' numbers | |
143 | count Sunday as 0. The element @var{string} is always the | |
f9b4c05d | 144 | description of the holiday, as a string. |
c5184807 EZ |
145 | |
146 | @table @code | |
147 | @item (holiday-fixed @var{month} @var{day} @var{string}) | |
148 | A fixed date on the Gregorian calendar. | |
149 | ||
f9b4c05d GM |
150 | @item (holiday-float @var{month} @var{dayname} @var{k} @var{string} |
151 | &optional @var{day}) | |
152 | The @var{k}th @var{dayname} (@var{dayname}=0 for Sunday, and so on) | |
153 | after or before Gregorian date @var{month}, @var{day}. Negative @var{k} | |
154 | means count back from the end of the month. Optional @var{day} defaults | |
155 | to 1 if @var{k} is positive, and the last day of @var{month} otherwise. | |
c5184807 | 156 | |
a43a8a2e GM |
157 | @item (holiday-chinese @var{month} @var{day} @var{string}) |
158 | A fixed date on the Chinese calendar. | |
159 | ||
c5184807 EZ |
160 | @item (holiday-hebrew @var{month} @var{day} @var{string}) |
161 | A fixed date on the Hebrew calendar. | |
162 | ||
163 | @item (holiday-islamic @var{month} @var{day} @var{string}) | |
164 | A fixed date on the Islamic calendar. | |
165 | ||
166 | @item (holiday-julian @var{month} @var{day} @var{string}) | |
167 | A fixed date on the Julian calendar. | |
168 | ||
169 | @item (holiday-sexp @var{sexp} @var{string}) | |
170 | A date calculated by the Lisp expression @var{sexp}. The expression | |
171 | should use the variable @code{year} to compute and return the date of a | |
f9b4c05d GM |
172 | holiday in the form of a list @code{(@var{month} @var{day} @var{year})}, |
173 | or @code{nil} if the holiday doesn't happen this year. | |
c5184807 EZ |
174 | |
175 | @item (if @var{condition} @var{holiday-form}) | |
176 | A holiday that happens only if @var{condition} is true. | |
177 | ||
178 | @item (@var{function} @r{[}@var{args}@r{]}) | |
179 | A list of dates calculated by the function @var{function}, called with | |
180 | arguments @var{args}. | |
181 | @end table | |
182 | ||
183 | For example, suppose you want to add Bastille Day, celebrated in | |
f9b4c05d GM |
184 | France on July 14 (i.e., the fourteenth day of the seventh month). You |
185 | can do this as follows: | |
c5184807 EZ |
186 | |
187 | @smallexample | |
98ad1bae | 188 | (setq holiday-other-holidays '((holiday-fixed 7 14 "Bastille Day"))) |
c5184807 EZ |
189 | @end smallexample |
190 | ||
c5184807 EZ |
191 | Many holidays occur on a specific day of the week, at a specific time |
192 | of month. Here is a holiday form describing Hurricane Supplication Day, | |
193 | celebrated in the Virgin Islands on the fourth Monday in August: | |
194 | ||
195 | @smallexample | |
196 | (holiday-float 8 1 4 "Hurricane Supplication Day") | |
197 | @end smallexample | |
198 | ||
199 | @noindent | |
200 | Here the 8 specifies August, the 1 specifies Monday (Sunday is 0, | |
201 | Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in | |
202 | the month (1 specifies the first occurrence, 2 the second occurrence, | |
203 | @minus{}1 the last occurrence, @minus{}2 the second-to-last occurrence, and | |
204 | so on). | |
205 | ||
36c0514c | 206 | You can specify holidays that occur on fixed days of the Baha'i, |
a43a8a2e | 207 | Chinese, Hebrew, Islamic, and Julian calendars too. For example, |
c5184807 EZ |
208 | |
209 | @smallexample | |
98ad1bae | 210 | (setq holiday-other-holidays |
c5184807 EZ |
211 | '((holiday-hebrew 10 2 "Last day of Hanukkah") |
212 | (holiday-islamic 3 12 "Mohammed's Birthday") | |
213 | (holiday-julian 4 2 "Jefferson's Birthday"))) | |
214 | @end smallexample | |
215 | ||
216 | @noindent | |
217 | adds the last day of Hanukkah (since the Hebrew months are numbered with | |
218 | 1 starting from Nisan), the Islamic feast celebrating Mohammed's | |
219 | birthday (since the Islamic months are numbered from 1 starting with | |
220 | Muharram), and Thomas Jefferson's birthday, which is 2 April 1743 on the | |
221 | Julian calendar. | |
222 | ||
f9b4c05d GM |
223 | To include a holiday conditionally, use either Emacs Lisp's @code{if} |
224 | or the @code{holiday-sexp} form. For example, American presidential | |
225 | elections occur on the first Tuesday after the first Monday in November | |
226 | of years divisible by 4: | |
c5184807 EZ |
227 | |
228 | @smallexample | |
f9b4c05d | 229 | (holiday-sexp '(if (zerop (% year 4)) |
c5184807 EZ |
230 | (calendar-gregorian-from-absolute |
231 | (1+ (calendar-dayname-on-or-before | |
232 | 1 (+ 6 (calendar-absolute-from-gregorian | |
233 | (list 11 1 year))))))) | |
234 | "US Presidential Election") | |
235 | @end smallexample | |
236 | ||
237 | @noindent | |
238 | or | |
239 | ||
240 | @smallexample | |
f9b4c05d GM |
241 | (if (zerop (% displayed-year 4)) |
242 | (holiday-fixed 11 | |
36c0514c | 243 | (calendar-extract-day |
c5184807 EZ |
244 | (calendar-gregorian-from-absolute |
245 | (1+ (calendar-dayname-on-or-before | |
246 | 1 (+ 6 (calendar-absolute-from-gregorian | |
247 | (list 11 1 displayed-year))))))) | |
248 | "US Presidential Election")) | |
249 | @end smallexample | |
250 | ||
251 | Some holidays just don't fit into any of these forms because special | |
252 | calculations are involved in their determination. In such cases you | |
253 | must write a Lisp function to do the calculation. To include eclipses, | |
36c0514c | 254 | for example, add @code{(eclipses)} to @code{holiday-other-holidays} |
c5184807 EZ |
255 | and write an Emacs Lisp function @code{eclipses} that returns a |
256 | (possibly empty) list of the relevant Gregorian dates among the range | |
257 | visible in the calendar window, with descriptive strings, like this: | |
258 | ||
259 | @smallexample | |
260 | (((6 27 1991) "Lunar Eclipse") ((7 11 1991) "Solar Eclipse") ... ) | |
261 | @end smallexample | |
262 | ||
263 | @node Date Display Format | |
264 | @subsection Date Display Format | |
265 | @vindex calendar-date-display-form | |
266 | ||
267 | You can customize the manner of displaying dates in the diary, in mode | |
268 | lines, and in messages by setting @code{calendar-date-display-form}. | |
269 | This variable holds a list of expressions that can involve the variables | |
270 | @code{month}, @code{day}, and @code{year}, which are all numbers in | |
271 | string form, and @code{monthname} and @code{dayname}, which are both | |
272 | alphabetic strings. In the American style, the default value of this | |
273 | list is as follows: | |
274 | ||
275 | @smallexample | |
276 | ((if dayname (concat dayname ", ")) monthname " " day ", " year) | |
277 | @end smallexample | |
278 | ||
279 | @noindent | |
280 | while in the European style this value is the default: | |
281 | ||
282 | @smallexample | |
283 | ((if dayname (concat dayname ", ")) day " " monthname " " year) | |
284 | @end smallexample | |
285 | ||
286 | @noindent | |
f9b4c05d | 287 | The default ISO date representation is: |
c5184807 EZ |
288 | |
289 | @smallexample | |
f9b4c05d GM |
290 | ((format "%s-%.2d-%.2d" year (string-to-number month) |
291 | (string-to-number day))) | |
c5184807 EZ |
292 | @end smallexample |
293 | ||
294 | @noindent | |
295 | This specifies a typical American format: | |
296 | ||
297 | @smallexample | |
298 | (month "/" day "/" (substring year -2)) | |
299 | @end smallexample | |
300 | ||
301 | @node Time Display Format | |
302 | @subsection Time Display Format | |
303 | @vindex calendar-time-display-form | |
304 | ||
305 | The calendar and diary by default display times of day in the | |
306 | conventional American style with the hours from 1 through 12, minutes, | |
307 | and either @samp{am} or @samp{pm}. If you prefer the European style, | |
308 | also known in the US as military, in which the hours go from 00 to 23, | |
309 | you can alter the variable @code{calendar-time-display-form}. This | |
310 | variable is a list of expressions that can involve the variables | |
311 | @code{12-hours}, @code{24-hours}, and @code{minutes}, which are all | |
312 | numbers in string form, and @code{am-pm} and @code{time-zone}, which are | |
f9b4c05d | 313 | both alphabetic strings. The default value is: |
c5184807 EZ |
314 | |
315 | @smallexample | |
316 | (12-hours ":" minutes am-pm | |
317 | (if time-zone " (") time-zone (if time-zone ")")) | |
318 | @end smallexample | |
319 | ||
320 | @noindent | |
321 | Here is a value that provides European style times: | |
322 | ||
323 | @smallexample | |
324 | (24-hours ":" minutes | |
325 | (if time-zone " (") time-zone (if time-zone ")")) | |
326 | @end smallexample | |
327 | ||
f9b4c05d GM |
328 | Note that few calendar functions return a time of day (at present, only |
329 | solar functions). | |
330 | ||
c5184807 EZ |
331 | @node Diary Customizing |
332 | @subsection Customizing the Diary | |
333 | ||
36c0514c | 334 | @vindex diary-show-holidays-flag |
cad04c66 GM |
335 | Ordinarily, the diary window indicates any holidays that fall on the |
336 | date of the diary entries, either in the mode line or the buffer itself. | |
337 | The process of checking for holidays can be slow, depending on the | |
338 | defined holidays. In that case, setting @code{diary-show-holidays-flag} | |
339 | to @code{nil} will speed up the diary display. | |
c5184807 | 340 | |
36c0514c GM |
341 | @vindex diary-number-of-entries |
342 | The variable @code{diary-number-of-entries} controls the number of | |
c5184807 | 343 | days of diary entries to be displayed at one time. It affects the |
36c0514c | 344 | initial display when @code{calendar-view-diary-initially-flag} is |
f9b4c05d GM |
345 | @code{t}, as well as the command @kbd{M-x diary}. For example, a value |
346 | of 1 (the default) displays only the current day's diary entries, | |
347 | whereas a value of 2 will also show the next day's entries. The value | |
348 | can also be a vector of seven integers: for example, if the value is | |
349 | @code{[0 2 2 2 2 4 1]} then no diary entries appear on Sunday, the | |
350 | current date's and the next day's diary entries appear Monday through | |
351 | Thursday, Friday through Monday's entries appear on Friday, while on | |
352 | Saturday only that day's entries appear. | |
36c0514c | 353 | |
c5184807 | 354 | @vindex diary-date-forms |
f9b4c05d | 355 | You can customize the form of dates in your diary file by setting the |
c5184807 EZ |
356 | variable @code{diary-date-forms}. This variable is a list of patterns |
357 | for recognizing a date. Each date pattern is a list whose elements may | |
358 | be regular expressions (@pxref{Regular Expressions,,, elisp, the Emacs | |
359 | Lisp Reference Manual}) or the symbols @code{month}, @code{day}, | |
360 | @code{year}, @code{monthname}, and @code{dayname}. All these elements | |
361 | serve as patterns that match certain kinds of text in the diary file. | |
362 | In order for the date pattern, as a whole, to match, all of its elements | |
363 | must match consecutively. | |
364 | ||
365 | A regular expression in a date pattern matches in its usual fashion, | |
366 | using the standard syntax table altered so that @samp{*} is a word | |
367 | constituent. | |
368 | ||
369 | The symbols @code{month}, @code{day}, @code{year}, @code{monthname}, | |
370 | and @code{dayname} match the month number, day number, year number, | |
371 | month name, and day name of the date being considered. The symbols that | |
372 | match numbers allow leading zeros; those that match names allow | |
f9b4c05d GM |
373 | capitalization and abbreviation (as specified by |
374 | @code{calendar-month-abbrev-array} and | |
375 | @code{calendar-day-abbrev-array}). All the symbols can match @samp{*}; | |
376 | since @samp{*} in a diary entry means ``any day'', ``any month'', and so | |
377 | on, it should match regardless of the date being considered. | |
c5184807 EZ |
378 | |
379 | The default value of @code{diary-date-forms} in the American style is | |
f9b4c05d | 380 | provided by @code{diary-american-date-forms}: |
c5184807 EZ |
381 | |
382 | @example | |
383 | ((month "/" day "[^/0-9]") | |
384 | (month "/" day "/" year "[^0-9]") | |
385 | (monthname " *" day "[^,0-9]") | |
386 | (monthname " *" day ", *" year "[^0-9]") | |
387 | (dayname "\\W")) | |
388 | @end example | |
389 | ||
f9b4c05d GM |
390 | @noindent |
391 | Other default styles are provided by @code{diary-european-date-forms} | |
392 | and @code{diary-iso-date-forms}. | |
393 | ||
c5184807 EZ |
394 | The date patterns in the list must be @emph{mutually exclusive} and |
395 | must not match any portion of the diary entry itself, just the date and | |
396 | one character of whitespace. If, to be mutually exclusive, the pattern | |
397 | must match a portion of the diary entry text---beyond the whitespace | |
398 | that ends the date---then the first element of the date pattern | |
399 | @emph{must} be @code{backup}. This causes the date recognizer to back | |
400 | up to the beginning of the current word of the diary entry, after | |
401 | finishing the match. Even if you use @code{backup}, the date pattern | |
402 | must absolutely not match more than a portion of the first word of the | |
f9b4c05d GM |
403 | diary entry. For example, the default value of |
404 | @code{diary-european-date-forms} is: | |
c5184807 EZ |
405 | |
406 | @example | |
407 | ((day "/" month "[^/0-9]") | |
408 | (day "/" month "/" year "[^0-9]") | |
f9b4c05d | 409 | (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)") |
c5184807 EZ |
410 | (day " *" monthname " *" year "[^0-9]") |
411 | (dayname "\\W")) | |
412 | @end example | |
413 | ||
414 | @noindent | |
415 | Notice the use of @code{backup} in the third pattern, because it needs | |
416 | to match part of a word beyond the date itself to distinguish it from | |
417 | the fourth pattern. | |
418 | ||
f9b4c05d | 419 | @node Non-Gregorian Diary |
c216ec2b | 420 | @subsection Diary Entries Using non-Gregorian Calendars |
c5184807 | 421 | |
f9b4c05d GM |
422 | As well as entries based on the standard Gregorian calendar, your |
423 | diary can have entries based on Baha'i, Hebrew, or Islamic dates. | |
424 | Recognition of such entries can be time-consuming, however, and since | |
425 | most people don't use them, you must explicitly enable their use. If | |
426 | you want the diary to recognize Hebrew-date diary entries, for example, | |
427 | you must do this: | |
36c0514c GM |
428 | |
429 | @vindex diary-nongregorian-listing-hook | |
430 | @vindex diary-nongregorian-marking-hook | |
431 | @findex diary-hebrew-list-entries | |
432 | @findex diary-hebrew-mark-entries | |
f9b4c05d GM |
433 | @findex diary-islamic-list-entries |
434 | @findex diary-islamic-mark-entries | |
435 | @findex diary-bahai-list-entries | |
436 | @findex diary-bahai-mark-entries | |
c5184807 | 437 | @smallexample |
36c0514c GM |
438 | (add-hook 'diary-nongregorian-listing-hook 'diary-hebrew-list-entries) |
439 | (add-hook 'diary-nongregorian-marking-hook 'diary-hebrew-mark-entries) | |
c5184807 EZ |
440 | @end smallexample |
441 | ||
442 | @noindent | |
f9b4c05d GM |
443 | Similarly, for Islamic and Baha'i entries, add |
444 | @code{diary-islamic-list-entries} and @code{diary-islamic-mark-entries}, or | |
445 | @code{diary-bahai-list-entries} and @code{diary-bahai-mark-entries}. | |
446 | ||
447 | @vindex diary-bahai-entry-symbol | |
448 | @vindex diary-hebrew-entry-symbol | |
449 | @vindex diary-islamic-entry-symbol | |
450 | These diary entries have the same formats as Gregorian-date diary | |
451 | entries; except that @code{diary-bahai-entry-symbol} (default @samp{B}) | |
452 | must precede a Baha'i date, @code{diary-hebrew-entry-symbol} (default | |
453 | @samp{H}) a Hebrew date, and @code{diary-islamic-entry-symbol} (default | |
454 | @samp{I}) an Islamic date. Moreover, non-Gregorian month names may not | |
455 | be abbreviated (because the first three letters are often not unique). | |
fb89fad9 GM |
456 | (Note also that you must use ``Adar I'' if you want Adar of a common |
457 | Hebrew year.) For example, a diary entry for the Hebrew date Heshvan 25 | |
458 | could look like this: | |
c5184807 EZ |
459 | |
460 | @smallexample | |
461 | HHeshvan 25 Happy Hebrew birthday! | |
462 | @end smallexample | |
463 | ||
464 | @noindent | |
465 | and would appear in the diary for any date that corresponds to Heshvan 25 | |
466 | on the Hebrew calendar. And here is an Islamic-date diary entry that matches | |
467 | Dhu al-Qada 25: | |
468 | ||
469 | @smallexample | |
470 | IDhu al-Qada 25 Happy Islamic birthday! | |
471 | @end smallexample | |
472 | ||
f9b4c05d GM |
473 | As with Gregorian-date diary entries, non-Gregorian entries are |
474 | nonmarking if preceded by @code{diary-nonmarking-symbol} (default | |
475 | @samp{&}). | |
c5184807 | 476 | |
f9b4c05d GM |
477 | Here is a table of commands used in the calendar to create diary |
478 | entries that match the selected date and other dates that are similar in | |
479 | the Baha'i, Hebrew, or Islamic calendars: | |
c5184807 EZ |
480 | |
481 | @table @kbd | |
482 | @item i h d | |
f9b4c05d | 483 | @code{diary-hebrew-insert-entry} |
c5184807 | 484 | @item i h m |
f9b4c05d | 485 | @code{diary-hebrew-insert-monthly-entry} |
c5184807 | 486 | @item i h y |
f9b4c05d | 487 | @code{diary-hebrew-insert-yearly-entry} |
c5184807 | 488 | @item i i d |
f9b4c05d | 489 | @code{diary-islamic-insert-entry} |
c5184807 | 490 | @item i i m |
f9b4c05d | 491 | @code{diary-islamic-insert-monthly-entry} |
c5184807 | 492 | @item i i y |
f9b4c05d GM |
493 | @code{diary-islamic-insert-yearly-entry} |
494 | @item i B d | |
495 | @code{diary-bahai-insert-entry} | |
496 | @item i B m | |
497 | @code{diary-bahai-insert-monthly-entry} | |
498 | @item i B y | |
499 | @code{diary-bahai-insert-yearly-entry} | |
c5184807 EZ |
500 | @end table |
501 | ||
36c0514c GM |
502 | @findex diary-hebrew-insert-entry |
503 | @findex diary-hebrew-insert-monthly-entry | |
504 | @findex diary-hebrew-insert-yearly-entry | |
505 | @findex diary-islamic-insert-entry | |
506 | @findex diary-islamic-insert-monthly-entry | |
507 | @findex diary-islamic-insert-yearly-entry | |
f9b4c05d GM |
508 | @findex diary-bahai-insert-entry |
509 | @findex diary-bahai-insert-monthly-entry | |
510 | @findex diary-bahai-insert-yearly-entry | |
c5184807 EZ |
511 | These commands work much like the corresponding commands for ordinary |
512 | diary entries: they apply to the date that point is on in the calendar | |
f9b4c05d GM |
513 | window, and what they do is insert just the date portion of a diary |
514 | entry at the end of your diary file. You must then insert the rest of | |
515 | the diary entry. The basic commands add an entry for the specific | |
516 | non-Gregorian date, the @samp{monthly} commands for the given | |
517 | non-Gregorian day-within-month in every month, and the @samp{yearly} | |
518 | commands for the given non-Gregorian day and month in every year. | |
c5184807 | 519 | |
cad04c66 GM |
520 | @node Diary Display |
521 | @subsection Diary Display | |
d21d2618 | 522 | @vindex diary-display-function |
36c0514c | 523 | @findex diary-simple-display |
daf7e339 GM |
524 | @findex diary-fancy-display |
525 | @cindex diary buffer | |
c5184807 | 526 | |
cad04c66 GM |
527 | Diary display works by preparing the list of diary entries and then |
528 | running the function specified by the variable | |
529 | @code{diary-display-function}. The default value | |
daf7e339 GM |
530 | @code{diary-fancy-display} displays diary entries and holidays by |
531 | copying them into a special buffer that exists only for the sake of | |
cad04c66 GM |
532 | display. Copying diary entries to a separate buffer provides an |
533 | opportunity to change the displayed text to make it prettier---for | |
534 | example, to sort the entries by the dates they apply to. | |
c5184807 EZ |
535 | |
536 | @vindex diary-list-include-blanks | |
cad04c66 GM |
537 | Ordinarily, the fancy diary buffer does not show days for which there |
538 | are no diary entries, even if that day is a holiday. If you want such | |
539 | days to be shown in the fancy diary buffer, set the variable | |
c5184807 EZ |
540 | @code{diary-list-include-blanks} to @code{t}.@refill |
541 | ||
e11adbd8 GM |
542 | @c View mode does not seem to be described in the manual. |
543 | @c buffers.texi has a brief mention. | |
544 | The fancy diary buffer enables View mode, a minor mode that provides | |
545 | commands for scrolling and searching the text. For example, @key{SPC} | |
546 | and @key{DEL} scroll forward and backward, and @key{s} starts an | |
547 | incremental search. See the documentation of the function | |
548 | @code{view-mode} for more information. | |
549 | ||
550 | The alternative display method @code{diary-simple-display} shows the | |
551 | actual diary buffer, and uses invisible text to hide entries that don't | |
552 | apply. Holidays are shown in the mode line. The advantage of this | |
553 | method is that you can edit the buffer and save your changes directly to | |
554 | the diary file. This method is not as flexible as the fancy method, | |
555 | however. For example, it cannot sort entries. Another disadvantage is | |
556 | that invisible text can be confusing. For example, if you copy a region | |
557 | of text in order to paste it elsewhere, invisible text may be included. | |
558 | Similarly, since the diary buffer as you see it is an illusion, simply | |
559 | printing the buffer may not print what you see on your screen. | |
cad04c66 GM |
560 | |
561 | @vindex diary-print-entries-hook | |
562 | @findex diary-print-entries | |
563 | For this reason, there is a special command to print hard copy of the | |
564 | diary buffer @emph{as it appears}; this command is @kbd{M-x | |
565 | diary-print-entries}. It works with either display method, although | |
566 | with the fancy display you can also print the buffer like any other. To | |
567 | print a hard copy of a day-by-day diary for a week, position point on | |
568 | the first day of the week, type @kbd{7 d}, and then do @kbd{M-x | |
569 | diary-print-entries}. As usual, the inclusion of the holidays slows | |
570 | down the display slightly; you can speed things up by setting the | |
571 | variable @code{diary-show-holidays-flag} to @code{nil}. | |
572 | ||
573 | This command prepares a temporary buffer that contains only the diary | |
574 | entries currently visible in the diary buffer. Unlike with the simple | |
575 | display, the other irrelevant entries are really absent, not just | |
576 | hidden. After preparing the buffer, it runs the hook | |
577 | @code{diary-print-entries-hook}. The default value of this hook sends | |
578 | the data directly to the printer with the command @code{lpr-buffer} | |
579 | (@pxref{Printing}). If you want to use a different command to do the | |
580 | printing, just change the value of this hook. Other uses might include, | |
581 | for example, rearranging the lines into order by day and time. | |
582 | ||
583 | You can edit the diary entries as they appear in the simple diary | |
584 | window, but it is important to remember that the buffer displayed | |
585 | contains the @emph{entire} diary file, with portions of it concealed | |
586 | from view. This means, for instance, that the @kbd{C-f} | |
587 | (@code{forward-char}) command can put point at what appears to be the | |
588 | end of the line, but what is in reality the middle of some concealed | |
589 | line. | |
590 | ||
591 | @emph{Be careful when editing the diary entries in the simple display!} | |
592 | Inserting additional lines or adding/deleting characters in the middle | |
593 | of a visible line cannot cause problems, but editing at the end of a | |
594 | line may not do what you expect. Deleting a line may delete other | |
595 | invisible entries that follow it. Before editing the simple diary | |
596 | buffer, it is best to display the entire file with @kbd{s} | |
597 | (@code{diary-show-all-entries}). | |
598 | ||
599 | @node Fancy Diary Display | |
600 | @subsection Fancy Diary Display | |
601 | ||
602 | The following features only work with the fancy diary display. | |
603 | ||
c5184807 | 604 | @cindex sorting diary entries |
cad04c66 GM |
605 | You can use the normal hook @code{diary-list-entries-hook} to sort |
606 | each day's diary entries by their time of day. Here's how: | |
c5184807 | 607 | |
36c0514c | 608 | @findex diary-sort-entries |
c5184807 | 609 | @example |
36c0514c | 610 | (add-hook 'diary-list-entries-hook 'diary-sort-entries t) |
c5184807 EZ |
611 | @end example |
612 | ||
613 | @noindent | |
614 | For each day, this sorts diary entries that begin with a recognizable | |
615 | time of day according to their times. Diary entries without times come | |
67ae9766 GM |
616 | first within each day. Note how the sort command is placed at the end |
617 | of the hook list, in case earlier members of the list change the order | |
618 | of the diary entries, or add items. | |
c5184807 | 619 | |
f9b4c05d | 620 | @vindex diary-include-string |
cad04c66 GM |
621 | Your main diary file can include other files. This permits a group of |
622 | people to share a diary file for events that apply to all of them. | |
623 | Lines in the diary file starting with @code{diary-include-string}: | |
c5184807 EZ |
624 | |
625 | @smallexample | |
626 | #include "@var{filename}" | |
627 | @end smallexample | |
628 | ||
629 | @noindent | |
f9b4c05d GM |
630 | include the diary entries from the file @var{filename} in the fancy |
631 | diary buffer. The include mechanism is recursive, so that included | |
632 | files can include other files, and so on (you must be careful not to | |
633 | have a cycle of inclusions, of course). Here is how to enable the | |
634 | include facility: | |
c5184807 | 635 | |
36c0514c GM |
636 | @vindex diary-list-entries-hook |
637 | @vindex diary-mark-entries-hook | |
638 | @findex diary-include-other-diary-files | |
639 | @findex diary-mark-included-diary-files | |
c5184807 | 640 | @smallexample |
36c0514c GM |
641 | (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files) |
642 | (add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files) | |
c5184807 EZ |
643 | @end smallexample |
644 | ||
645 | The include mechanism works only with the fancy diary display, because | |
cad04c66 | 646 | simple diary display shows the entries directly from your diary file. |
c5184807 EZ |
647 | |
648 | @node Sexp Diary Entries | |
649 | @subsection Sexp Entries and the Fancy Diary Display | |
650 | @cindex sexp diary entries | |
651 | ||
f9b4c05d | 652 | @vindex diary-sexp-entry-symbol |
c5184807 | 653 | Sexp diary entries allow you to do more than just have complicated |
f9b4c05d GM |
654 | conditions under which a diary entry applies. Sexp entries should be |
655 | preceded by @code{diary-sexp-entry-symbol} (default @samp{%%}) in the | |
cad04c66 GM |
656 | diary file. With the fancy diary display, sexp entries can generate the |
657 | text of the entry depending on the date itself. | |
f9b4c05d GM |
658 | |
659 | For example, an anniversary diary entry can insert | |
c5184807 | 660 | the number of years since the anniversary date into the text of the |
5de4980c | 661 | diary entry. Thus the @samp{%d} in this diary entry: |
c5184807 EZ |
662 | |
663 | @findex diary-anniversary | |
664 | @smallexample | |
665 | %%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old) | |
666 | @end smallexample | |
667 | ||
668 | @noindent | |
669 | gets replaced by the age, so on October 31, 1990 the entry appears in | |
670 | the fancy diary buffer like this: | |
671 | ||
672 | @smallexample | |
673 | Arthur's birthday (42 years old) | |
674 | @end smallexample | |
675 | ||
676 | @noindent | |
677 | If the diary file instead contains this entry: | |
678 | ||
679 | @smallexample | |
680 | %%(diary-anniversary 10 31 1948) Arthur's %d%s birthday | |
681 | @end smallexample | |
682 | ||
683 | @noindent | |
684 | the entry in the fancy diary buffer for October 31, 1990 appears like this: | |
685 | ||
686 | @smallexample | |
687 | Arthur's 42nd birthday | |
688 | @end smallexample | |
689 | ||
690 | Similarly, cyclic diary entries can interpolate the number of repetitions | |
691 | that have occurred: | |
692 | ||
693 | @findex diary-cyclic | |
694 | @smallexample | |
695 | %%(diary-cyclic 50 1 1 1990) Renew medication (%d%s time) | |
696 | @end smallexample | |
697 | ||
698 | @noindent | |
699 | looks like this: | |
700 | ||
701 | @smallexample | |
702 | Renew medication (5th time) | |
703 | @end smallexample | |
704 | ||
705 | @noindent | |
706 | in the fancy diary display on September 8, 1990. | |
707 | ||
708 | There is an early reminder diary sexp that includes its entry in the | |
709 | diary not only on the date of occurrence, but also on earlier dates. | |
710 | For example, if you want a reminder a week before your anniversary, you | |
711 | can use | |
712 | ||
713 | @findex diary-remind | |
714 | @smallexample | |
715 | %%(diary-remind '(diary-anniversary 12 22 1968) 7) Ed's anniversary | |
716 | @end smallexample | |
717 | ||
718 | @noindent | |
f9b4c05d GM |
719 | and the fancy diary will show @samp{Ed's anniversary} both on December |
720 | 15 and on December 22. | |
c5184807 EZ |
721 | |
722 | @findex diary-date | |
723 | The function @code{diary-date} applies to dates described by a month, | |
724 | day, year combination, each of which can be an integer, a list of | |
f9b4c05d | 725 | integers, or @code{t} (meaning all values). For example, |
c5184807 EZ |
726 | |
727 | @smallexample | |
728 | %%(diary-date '(10 11 12) 22 t) Rake leaves | |
729 | @end smallexample | |
730 | ||
731 | @noindent | |
732 | causes the fancy diary to show | |
733 | ||
734 | @smallexample | |
735 | Rake leaves | |
736 | @end smallexample | |
737 | ||
738 | @noindent | |
739 | on October 22, November 22, and December 22 of every year. | |
740 | ||
741 | @findex diary-float | |
742 | The function @code{diary-float} allows you to describe diary entries | |
743 | that apply to dates like the third Friday of November, or the last | |
744 | Tuesday in April. The parameters are the @var{month}, @var{dayname}, | |
f9b4c05d | 745 | and an index @var{n}. The entry appears on the @var{n}th @var{dayname} |
ff2c14fc GM |
746 | after the first day of @var{month}, where @var{dayname}=0 means Sunday, |
747 | 1 means Monday, and so on. If @var{n} is negative it counts backward | |
748 | from the end of @var{month}. The value of @var{month} can be a list of | |
749 | months, a single month, or @code{t} to specify all months. You can also | |
750 | use an optional parameter @var{day} to specify the @var{n}th | |
751 | @var{dayname} on or after/before @var{day} of @var{month}; the value of | |
752 | @var{day} defaults to 1 if @var{n} is positive and to the last day of | |
753 | @var{month} if @var{n} is negative. For example, | |
c5184807 EZ |
754 | |
755 | @smallexample | |
756 | %%(diary-float t 1 -1) Pay rent | |
757 | @end smallexample | |
758 | ||
759 | @noindent | |
760 | causes the fancy diary to show | |
761 | ||
762 | @smallexample | |
763 | Pay rent | |
764 | @end smallexample | |
765 | ||
766 | @noindent | |
767 | on the last Monday of every month. | |
768 | ||
769 | The generality of sexp diary entries lets you specify any diary | |
770 | entry that you can describe algorithmically. A sexp diary entry | |
771 | contains an expression that computes whether the entry applies to any | |
772 | given date. If its value is non-@code{nil}, the entry applies to that | |
773 | date; otherwise, it does not. The expression can use the variable | |
774 | @code{date} to find the date being considered; its value is a list | |
775 | (@var{month} @var{day} @var{year}) that refers to the Gregorian | |
776 | calendar. | |
777 | ||
778 | The sexp diary entry applies to a date when the expression's value | |
779 | is non-@code{nil}, but some values have more specific meanings. If | |
780 | the value is a string, that string is a description of the event which | |
781 | occurs on that date. The value can also have the form | |
782 | @code{(@var{mark} . @var{string})}; then @var{mark} specifies how to | |
783 | mark the date in the calendar, and @var{string} is the description of | |
784 | the event. If @var{mark} is a single-character string, that character | |
785 | appears next to the date in the calendar. If @var{mark} is a face | |
786 | name, the date is displayed in that face. If @var{mark} is | |
787 | @code{nil}, that specifies no particular highlighting for the date. | |
788 | ||
789 | Suppose you get paid on the 21st of the month if it is a weekday, and | |
790 | on the Friday before if the 21st is on a weekend. Here is how to write | |
791 | a sexp diary entry that matches those dates: | |
792 | ||
793 | @smallexample | |
794 | &%%(let ((dayname (calendar-day-of-week date)) | |
f9b4c05d | 795 | (day (cadr date))) |
c5184807 EZ |
796 | (or (and (= day 21) (memq dayname '(1 2 3 4 5))) |
797 | (and (memq day '(19 20)) (= dayname 5))) | |
798 | ) Pay check deposited | |
799 | @end smallexample | |
800 | ||
801 | The following sexp diary entries take advantage of the ability (in the fancy | |
802 | diary display) to concoct diary entries whose text varies based on the date: | |
803 | ||
804 | @findex diary-sunrise-sunset | |
8ce2c66f | 805 | @findex diary-lunar-phases |
c5184807 EZ |
806 | @findex diary-day-of-year |
807 | @findex diary-iso-date | |
808 | @findex diary-julian-date | |
809 | @findex diary-astro-day-number | |
36c0514c | 810 | @findex diary-bahai-date |
f9b4c05d GM |
811 | @findex diary-chinese-date |
812 | @findex diary-coptic-date | |
813 | @findex diary-ethiopic-date | |
c5184807 EZ |
814 | @findex diary-hebrew-date |
815 | @findex diary-islamic-date | |
816 | @findex diary-french-date | |
817 | @findex diary-mayan-date | |
f9b4c05d | 818 | @findex diary-persian-date |
c5184807 EZ |
819 | @table @code |
820 | @item %%(diary-sunrise-sunset) | |
f9b4c05d | 821 | Make a diary entry for today's local times of sunrise and sunset. |
8ce2c66f | 822 | @item %%(diary-lunar-phases) |
c5184807 EZ |
823 | Make a diary entry for the phases (quarters) of the moon. |
824 | @item %%(diary-day-of-year) | |
825 | Make a diary entry with today's day number in the current year and the number | |
826 | of days remaining in the current year. | |
827 | @item %%(diary-iso-date) | |
828 | Make a diary entry with today's equivalent ISO commercial date. | |
829 | @item %%(diary-julian-date) | |
f9b4c05d | 830 | Make a diary entry with today's equivalent Julian calendar date. |
c5184807 EZ |
831 | @item %%(diary-astro-day-number) |
832 | Make a diary entry with today's equivalent astronomical (Julian) day number. | |
36c0514c | 833 | @item %%(diary-bahai-date) |
f9b4c05d GM |
834 | Make a diary entry with today's equivalent Baha'i calendar date. |
835 | @item %%(diary-chinese-date) | |
836 | Make a diary entry with today's equivalent Chinese calendar date. | |
837 | @item %%(diary-coptic-date) | |
838 | Make a diary entry with today's equivalent Coptic calendar date. | |
839 | @item %%(diary-ethiopic-date) | |
840 | Make a diary entry with today's equivalent Ethiopic calendar date. | |
c5184807 EZ |
841 | @item %%(diary-french-date) |
842 | Make a diary entry with today's equivalent date on the French Revolutionary | |
843 | calendar. | |
f9b4c05d GM |
844 | @item %%(diary-hebrew-date) |
845 | Make a diary entry with today's equivalent Hebrew calendar date. | |
846 | @item %%(diary-islamic-date) | |
847 | Make a diary entry with today's equivalent Islamic calendar date. | |
c5184807 | 848 | @item %%(diary-mayan-date) |
f9b4c05d GM |
849 | Make a diary entry with today's equivalent Mayan calendar date. |
850 | @item %%(diary-persian-date) | |
851 | Make a diary entry with today's equivalent Persian calendar date. | |
c5184807 EZ |
852 | @end table |
853 | ||
854 | @noindent | |
f9b4c05d | 855 | For example, including the diary entry |
c5184807 | 856 | |
f9b4c05d | 857 | @smallexample |
c5184807 | 858 | &%%(diary-hebrew-date) |
f9b4c05d | 859 | @end smallexample |
c5184807 EZ |
860 | |
861 | @noindent | |
862 | causes every day's diary display to contain the equivalent date on the | |
863 | Hebrew calendar, if you are using the fancy diary display. (With simple | |
f9b4c05d GM |
864 | diary display, the literal line @samp{&%%(diary-hebrew-date)} appears in |
865 | the diary for any date.) | |
c5184807 | 866 | |
f9b4c05d GM |
867 | This function has been used to construct certain standard Hebrew sexp |
868 | diary entries: | |
c5184807 EZ |
869 | |
870 | @cindex rosh hodesh | |
36c0514c | 871 | @findex diary-hebrew-rosh-hodesh |
c5184807 | 872 | @cindex parasha, weekly |
36c0514c | 873 | @findex diary-hebrew-parasha |
c5184807 | 874 | @cindex candle lighting times |
36c0514c | 875 | @findex diary-hebrew-sabbath-candles |
c5184807 | 876 | @cindex omer count |
36c0514c | 877 | @findex diary-hebrew-omer |
c5184807 | 878 | @cindex yahrzeits |
36c0514c | 879 | @findex diary-hebrew-yahrzeit |
c5184807 | 880 | @table @code |
36c0514c | 881 | @item %%(diary-hebrew-rosh-hodesh) |
c5184807 EZ |
882 | Make a diary entry that tells the occurrence and ritual announcement of each |
883 | new Hebrew month. | |
36c0514c | 884 | @item %%(diary-hebrew-parasha) |
c5184807 | 885 | Make a Saturday diary entry that tells the weekly synagogue scripture reading. |
36c0514c | 886 | @item %%(diary-hebrew-sabbath-candles) |
c5184807 EZ |
887 | Make a Friday diary entry that tells the @emph{local time} of Sabbath |
888 | candle lighting. | |
36c0514c | 889 | @item %%(diary-hebrew-omer) |
c5184807 | 890 | Make a diary entry that gives the omer count, when appropriate. |
36c0514c | 891 | @item %%(diary-hebrew-yahrzeit @var{month} @var{day} @var{year}) @var{name} |
c5184807 EZ |
892 | Make a diary entry marking the anniversary of a date of death. The date |
893 | is the @emph{Gregorian} (civil) date of death. The diary entry appears | |
f9b4c05d GM |
894 | on the proper Hebrew calendar anniversary and on the day before. (The |
895 | order of the parameters changes according to the calendar date style; | |
896 | for example in the European style to @var{day}, @var{month}, @var{year}.) | |
c5184807 EZ |
897 | @end table |
898 | ||
899 | All the functions documented above take an optional argument | |
900 | @var{mark} which specifies how to mark the date in the calendar display. | |
901 | If one of these functions decides that it applies to a certain date, | |
f9b4c05d | 902 | it returns a value that contains @var{mark}, as described above. |
14831d20 MB |
903 | |
904 | @ignore | |
905 | arch-tag: 52cb299f-fd1f-4616-bfe6-91b988669431 | |
906 | @end ignore |