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