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