@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+@c Copyright (C) 1990, 1991, 1992, 1993, 1995, 1998 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
-@node Calendar, Tips, Display, Top
+@node Calendar, System Interface, Display, Top
@chapter Customizing the Calendar and Diary
There are many customizations that you can use to make the calendar and
* Daylight Savings:: Changing the default.
* Diary Customizing:: Defaults you can set.
* Hebrew/Islamic Entries:: How to obtain them.
-* Fancy Diary Display:: Enhancing the diary display, sorting entries,
+* Fancy Diary Display:: Enhancing the diary display, sorting entries,
using included diary files.
* Sexp Diary Entries:: Fancy things you can do.
* Appt Customizing:: Customizing appointment reminders.
@code{t}, calling up the calendar automatically displays the diary
entries for the current date as well. The diary dates appear only if
the current date is visible. If you add both of the following lines to
-your @file{.emacs} file:@refill
+your init file:@refill
@example
(setq view-diary-entries-initially t)
@end example
@noindent
-they display both the calendar and diary windows whenever you start Emacs.
+this displays both the calendar and diary windows whenever you start Emacs.
@vindex view-calendar-holidays-initially
Similarly, if you set the variable
@code{view-calendar-holidays-initially} to @code{t}, entering the
-calendar automatically displays a list of holidays for the current three
-month period. The holiday list appears in a separate window.@refill
+calendar automatically displays a list of holidays for the current
+three-month period. The holiday list appears in a separate
+window.
@vindex mark-diary-entries-in-calendar
You can set the variable @code{mark-diary-entries-in-calendar} to
@code{t} in order to mark any dates with diary entries. This takes
effect whenever the calendar window contents are recomputed. There are
two ways of marking these dates: by changing the face (@pxref{Faces}),
-if the display supports that, or by placing a plus sign (@samp{+})
-beside the date otherwise.
+or by placing a plus sign (@samp{+}) beside the date.
@vindex mark-holidays-in-calendar
Similarly, setting the variable @code{mark-holidays-in-calendar} to
date as being a holiday. Its value may be a character to insert next to
the date, or a face name to use for displaying the date. Likewise, the
variable @code{diary-entry-marker} specifies how to mark a date that has
-diary entries.
+diary entries. The calendar creates faces named @code{holiday-face} and
+@code{diary-face} for these purposes; those symbols are the default
+values of these variables.
@vindex calendar-load-hook
The variable @code{calendar-load-hook} is a normal hook run when the
@vindex calendar-today-marker
The variable @code{calendar-today-marker} specifies how to mark today's
date. Its value should be a character to insert next to the date or a
-face name to use for displaying the date.
+face name to use for displaying the date. A face named
+@code{calendar-today-face} is provided for this purpose; that symbol is
+the default for this variable.
@vindex today-invisible-calendar-hook
@noindent
A similar normal hook, @code{today-invisible-calendar-hook} is run if
the current date is @emph{not} visible in the window.
+@vindex calendar-move-hook
+ Starting in Emacs 21, each of the calendar cursor motion commands
+runs the hook @code{calendar-move-hook} after it moves the cursor.
+
@node Holiday Customizing
@section Customizing the Holidays
@vindex hebrew-holidays
@vindex islamic-holidays
Emacs knows about holidays defined by entries on one of several lists.
-You can customize theses lists of holidays to your own needs, adding
-holidays or deleting lists of holidays. The lists of holidays that
-Emacs uses are for general holidays (@code{general-holidays}), local
-holidays (@code{local-holidays}), Christian holidays
-(@code{christian-holidays}), Hebrew (Jewish) holidays
-(@code{hebrew-holidays}), Islamic (Moslem) holidays
-(@code{islamic-holidays}), and other holidays (@code{other-holidays}).
+You can customize these lists of holidays to your own needs, adding or
+deleting holidays. The lists of holidays that Emacs uses are for
+general holidays (@code{general-holidays}), local holidays
+(@code{local-holidays}), Christian holidays (@code{christian-holidays}),
+Hebrew (Jewish) holidays (@code{hebrew-holidays}), Islamic (Moslem)
+holidays (@code{islamic-holidays}), and other holidays
+(@code{other-holidays}).
@vindex general-holidays
The general holidays are, by default, holidays common throughout the
@vindex all-hebrew-calendar-holidays
@vindex all-islamic-calendar-holidays
By default, Emacs does not include all the holidays of the religions
-that it knows; only those commonly found in secular calendars. For a
+that it knows, only those commonly found in secular calendars. For a
more extensive collection of religious holidays, you can set any (or
all) of the variables @code{all-christian-calendar-holidays},
@code{all-hebrew-calendar-holidays}, or
sometimes a list of holidays).
Here is a table of the possible kinds of holiday form. Day numbers
-and month numbers count starting from 1, but day-within-week numbers
+and month numbers count starting from 1, but ``dayname'' numbers
count Sunday as 0. The element @var{string} is always the
name of the holiday, as a string.
@table @code
@item (holiday-fixed @var{month} @var{day} @var{string})
-A fixed date on the Gregorian calendar; @var{month} and
-@var{day} are numbers.
+A fixed date on the Gregorian calendar.
@item (holiday-float @var{month} @var{dayname} @var{k} @var{string})
The @var{k}th @var{dayname} in @var{month} on the Gregorian calendar
from the end of the month.
@item (holiday-hebrew @var{month} @var{day} @var{string})
-A fixed date on the Hebrew calendar; @var{month} and @var{day} are
-numbers.
+A fixed date on the Hebrew calendar.
@item (holiday-islamic @var{month} @var{day} @var{string})
-A fixed date on the Islamic calendar; @var{month} and @var{day} are
-numbers.
+A fixed date on the Islamic calendar.
@item (holiday-julian @var{month} @var{day} @var{string})
-A fixed date on the Julian calendar; @var{month} and @var{day} are
-numbers.
+A fixed date on the Julian calendar.
@item (holiday-sexp @var{sexp} @var{string})
A date calculated by the Lisp expression @var{sexp}. The expression
-should use the variable @code{year} to compute the date of a holiday, or
-@code{nil} if the holiday doesn't happen this year. The value of @var{sexp}
-must represent the date as a list of the form @code{(@var{month} @var{day}
-@var{year})}.
+should use the variable @code{year} to compute and return the date of a
+holiday, or @code{nil} if the holiday doesn't happen this year. The
+value of @var{sexp} must represent the date as a list of the form
+@code{(@var{month} @var{day} @var{year})}.
+
+@item (if @var{condition} @var{holiday-form})
+A holiday that happens only if @var{condition} is true.
@item (@var{function} @r{[}@var{args}@r{]})
-A date calculated by the function @var{function}, called with arguments
-@var{args}.
+A list of dates calculated by the function @var{function}, called with
+arguments @var{args}.
@end table
For example, suppose you want to add Bastille Day, celebrated in
@smallexample
(holiday-sexp (if (= 0 (% year 4))
(calendar-gregorian-from-absolute
- (1+ (calendar-dayname-on-or-before
- 1 (+ 6 (calendar-absolute-from-gregorian
- (list 11 1 year))))))
+ (1+ (calendar-dayname-on-or-before
+ 1 (+ 6 (calendar-absolute-from-gregorian
+ (list 11 1 year))))))
"US Presidential Election"))
@end smallexample
@section Date Display Format
@vindex calendar-date-display-form
- You can customize the manner of displaying dates in the diary,
-in mode lines, and in messages by setting
-@code{calendar-date-display-form}. This variable holds a list of
-expressions that can involve the variables @code{month}, @code{day}, and
-@code{year}, all numbers in string form, and @code{monthname} and
-@code{dayname}, both alphabetic strings. In the American style, the
-default value of this list is as follows:
+ You can customize the manner of displaying dates in the diary, in mode
+lines, and in messages by setting @code{calendar-date-display-form}.
+This variable holds a list of expressions that can involve the variables
+@code{month}, @code{day}, and @code{year}, which are all numbers in
+string form, and @code{monthname} and @code{dayname}, which are both
+alphabetic strings. In the American style, the default value of this
+list is as follows:
@smallexample
((if dayname (concat dayname ", ")) monthname " " day ", " year)
also known in the US as military, in which the hours go from 00 to 23,
you can alter the variable @code{calendar-time-display-form}. This
variable is a list of expressions that can involve the variables
-@code{12-hours}, @code{24-hours}, and @code{minutes}, all numbers in
-string form, and @code{am-pm} and @code{time-zone}, both alphabetic
-strings. The default value of @code{calendar-time-display-form} is as
-follows:
+@code{12-hours}, @code{24-hours}, and @code{minutes}, which are all
+numbers in string form, and @code{am-pm} and @code{time-zone}, which are
+both alphabetic strings. The default value of
+@code{calendar-time-display-form} is as follows:
@smallexample
(12-hours ":" minutes am-pm
where you are; on these systems, Emacs gets the information it needs
from the system automatically. If some or all of this information is
missing, Emacs fills in the gaps with the rules currently used in
-Cambridge, Massachusetts, which is the center of GNU's world. If the
-default choice of rules is not appropriate for your location, you can
-tell Emacs the rules to use by setting certain variables.
+Cambridge, Massachusetts, which is the center of GNU's world.
+
@vindex calendar-daylight-savings-starts
@vindex calendar-daylight-savings-ends
- These variables are @code{calendar-daylight-savings-starts} together
-with @code{calendar-daylight-savings-ends}. Their values should be Lisp
+ If the default choice of rules is not appropriate for your location,
+you can tell Emacs the rules to use by setting the variables
+@code{calendar-daylight-savings-starts} and
+@code{calendar-daylight-savings-ends}. Their values should be Lisp
expressions that refer to the variable @code{year}, and evaluate to the
Gregorian date on which daylight savings time starts or (respectively)
ends, in the form of a list @code{(@var{month} @var{day} @var{year})}.
The values should be @code{nil} if your area does not use daylight
savings time.
- Emacs uses these expressions to determine the starting date of
-daylight savings time for the holiday list and for correcting times of
-day in the solar and lunar calculations.
+ Emacs uses these expressions to determine the start and end dates of
+daylight savings time as holidays and for correcting times of day in the
+solar and lunar calculations.
The values for Cambridge, Massachusetts are as follows:
well as the command @kbd{M-x diary}. For example, the default value is
1, which says to display only the current day's diary entries. If the
value is 2, both the current day's and the next day's entries are
-displayed. The value can also be a vector of seven elements: if the
-value is @code{[0 2 2 2 2 4 1]} then no diary entries appear on Sunday,
-the current date's and the next day's diary entries appear Monday
-through Thursday, Friday through Monday's entries appear on Friday,
-while on Saturday only that day's entries appear.
+displayed. The value can also be a vector of seven elements: for
+example, if the value is @code{[0 2 2 2 2 4 1]} then no diary entries
+appear on Sunday, the current date's and the next day's diary entries
+appear Monday through Thursday, Friday through Monday's entries appear
+on Friday, while on Saturday only that day's entries appear.
@vindex print-diary-entries-hook
@findex print-diary-entries
well as entries based on the world-standard Gregorian calendar.
However, because recognition of such entries is time-consuming and most
people don't use them, you must explicitly enable their use. If you
-want the diary to recognize Hebrew-date diary entries, for example,
+want the diary to recognize Hebrew-date diary entries, for example,
you must do this:
@vindex nongregorian-diary-listing-hook
@noindent
and would appear in the diary for any date that corresponds to Heshvan 25
-on the Hebrew calendar. And here is Islamic-date diary entry that matches
+on the Hebrew calendar. And here is an Islamic-date diary entry that matches
Dhu al-Qada 25:
@smallexample
@item i h m
Add a diary entry for the day of the Hebrew month corresponding to the
selected date (@code{insert-monthly-hebrew-diary-entry}). This diary
-entry matches any date which has the same Hebrew day-within-month as the
+entry matches any date that has the same Hebrew day-within-month as the
selected date.
@item i h y
Add a diary entry for the day of the Hebrew year corresponding to the
-selected date (@code{insert-yearly-hebrew-diary-entry}). This diary
+selected date (@code{insert-yearly-hebrew-diary-entry}). This diary
entry matches any date which has the same Hebrew month and day-within-month
as the selected date.
@item i i d
@findex insert-monthly-islamic-diary-entry
@findex insert-yearly-islamic-diary-entry
These commands work much like the corresponding commands for ordinary
-diary entries: they apply to the date that point is on, in the calendar
+diary entries: they apply to the date that point is on in the calendar
window, and what they do is insert just the date portion of a diary entry
-at the end of your diary file. You must then insert the rest of the
+at the end of your diary file. You must then insert the rest of the
diary entry.
@node Fancy Diary Display
As with simple diary display, you can print a hard copy of the buffer
with @code{print-diary-entries}. To print a hard copy of a day-by-day
-diary for a week by positioning point on Sunday of that week, type
-@kbd{7 d} and then do @kbd{M-x print-diary-entries}. As usual, the
+diary for a week, position point on Sunday of that week, type
+@kbd{7 d}, and then do @kbd{M-x print-diary-entries}. As usual, the
inclusion of the holidays slows down the display slightly; you can speed
things up by setting the variable @code{holidays-in-diary-buffer} to
@code{nil}.
@cindex sorting diary entries
If you use the fancy diary display, you can use the normal hook
@code{list-diary-entries-hook} to sort each day's diary entries by their
-time of day. Here's how
+time of day. Here's how:
@findex sort-diary-entries
@example
-(add-hook 'list-diary-entries-hook 'sort-diary-entries)
+(add-hook 'list-diary-entries-hook 'sort-diary-entries t)
@end example
@noindent
@noindent
includes the diary entries from the file @var{filename} in the fancy
-diary buffer The include mechanism is recursive, so that included files
+diary buffer. The include mechanism is recursive, so that included files
can include other files, and so on; you must be careful not to have a
cycle of inclusions, of course. Here is how to enable the include
facility:
@noindent
in the fancy diary display on September 8, 1990.
- The generality of sexp diary entries lets you specify any diary entry
-that you can describe algorithmically. A sexp diary entry contains an
-expression that computes whether the entry applies to any given date.
-If its value is non-@code{nil}, the entry applies to that date;
-otherwise, it does not. The expression can use the variable @code{date}
-to find the date being considered; its value is a list (@var{month}
-@var{day} @var{year}) that refers to the Gregorian calendar.
+ There is an early reminder diary sexp that includes its entry in the
+diary not only on the date of occurrence, but also on earlier dates.
+For example, if you want a reminder a week before your anniversary, you
+can use
+
+@findex diary-remind
+@smallexample
+%%(diary-remind '(diary-anniversary 12 22 1968) 7) Ed's anniversary
+@end smallexample
+
+@noindent
+and the fancy diary will show
+@smallexample
+Ed's anniversary
+@end smallexample
+@noindent
+both on December 15 and on December 22.
+
+@findex diary-date
+ The function @code{diary-date} applies to dates described by a month,
+day, year combination, each of which can be an integer, a list of
+integers, or @code{t}. The value @code{t} means all values. For
+example,
+
+@smallexample
+%%(diary-date '(10 11 12) 22 t) Rake leaves
+@end smallexample
+
+@noindent
+causes the fancy diary to show
+
+@smallexample
+Rake leaves
+@end smallexample
+
+@noindent
+on October 22, November 22, and December 22 of every year.
+
+@findex diary-float
+ The function @code{diary-float} allows you to describe diary entries
+that apply to dates like the third Friday of November, or the last
+Tuesday in April. The parameters are the @var{month}, @var{dayname},
+and an index @var{n}. The entry appears on the @var{n}th @var{dayname}
+of @var{month}, where @var{dayname}=0 means Sunday, 1 means Monday, and
+so on. If @var{n} is negative it counts backward from the end of
+@var{month}. The value of @var{month} can be a list of months, a single
+month, or @code{t} to specify all months. You can also use an optional
+parameter @var{day} to specify the @var{n}th @var{dayname} of
+@var{month} on or after/before @var{day}; the value of @var{day} defaults
+to 1 if @var{n} is positive and to the last day of @var{month} if
+@var{n} is negative. For example,
+
+@smallexample
+%%(diary-float t 1 -1) Pay rent
+@end smallexample
+
+@noindent
+causes the fancy diary to show
+
+@smallexample
+Pay rent
+@end smallexample
+
+@noindent
+on the last Monday of every month.
+
+ The generality of sexp diary entries lets you specify any diary
+entry that you can describe algorithmically. A sexp diary entry
+contains an expression that computes whether the entry applies to any
+given date. If its value is non-@code{nil}, the entry applies to that
+date; otherwise, it does not. The expression can use the variable
+@code{date} to find the date being considered; its value is a list
+(@var{month} @var{day} @var{year}) that refers to the Gregorian
+calendar.
+
+ The sexp diary entry applies to a date when the expression's value
+is non-@code{nil}, but some values have more specific meanings. If
+the value is a string, that string is a description of the event which
+occurs on that date. The value can also have the form
+@code{(@var{mark} . @var{string})}; then @var{mark} specifies how to
+mark the date in the calendar, and @var{string} is the description of
+the event. If @var{mark} is a single-character string, that character
+appears next to the date in the calendar. If @var{mark} is a face
+name, the date is displayed in that face. If @var{mark} is
+@code{nil}, that specifies no particular highlighting for the date.
Suppose you get paid on the 21st of the month if it is a weekday, and
-to the Friday before if the 21st is on a weekend. Here is how to write
+on the Friday before if the 21st is on a weekend. Here is how to write
a sexp diary entry that matches those dates:
@smallexample
diary display, the line @samp{&%%(diary-hebrew-date)} appears in the
diary for any date, but does nothing particularly useful.)
- These functions can be used in sexp diary entries based on the Hebrew
-calendar in certain standard ways:
+ These functions can be used to construct sexp diary entries based on
+the Hebrew calendar in certain standard ways:
@cindex rosh hodesh
@findex diary-rosh-hodesh
@var{month}, @var{year}.)
@end table
+ All the functions documented above take an optional argument
+@var{mark} which specifies how to mark the date in the calendar display.
+If one of these functions decides that it applies to a certain date,
+it returns a value that contains @var{mark}.
+
@node Appt Customizing
@section Customizing Appointment Reminders
- You can specify exactly how Emacs reminds you of an appointment and
-how far in advance it begins doing so. Here are the variables that you
-can set:
+ You can specify exactly how Emacs reminds you of an appointment, and
+how far in advance it begins doing so, by setting these variables:
@vindex appt-message-warning-time
@vindex appt-audible
terminal bell for appointment reminders. The default is @code{t}.
@item appt-visible
If this is non-@code{nil}, Emacs displays the appointment
-message in echo area. The default is @code{t}.
+message in the echo area. The default is @code{t}.
@item appt-display-mode-line
If this is non-@code{nil}, Emacs displays the number of minutes
to the appointment on the mode line. The default is @code{t}.
The number of seconds to display an appointment message. The default
is 5 seconds.
@end table
+
+@ignore
+ arch-tag: 8e50c766-4703-4888-a421-af15244cca7e
+@end ignore