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