Document calendar-month-header
[bpt/emacs.git] / doc / emacs / cal-xtra.texi
CommitLineData
102f1b54
GM
1@c This is part of the Emacs manual. -*- coding: iso-latin-1 -*-
2@c Copyright (C) 2004-2012 Free Software Foundation, Inc.
6f585e44
EZ
3@c See file emacs.texi for copying conditions.
4@c
c5184807
EZ
5@c This file is included either in emacs-xtra.texi (when producing the
6@c printed version) or in the main Emacs manual (for the on-line version).
7
8@c Moved here from the Emacs Lisp Reference Manual, 2005-03-26.
9@node Advanced Calendar/Diary Usage
4695c850 10@section More advanced features of the Calendar and Diary
c5184807 11
4695c850
GM
12 This section describes some of the more advanced/specialized
13features of the calendar and diary. It starts with some of the
14many ways in which you can customize the calendar and diary to suit
15your personal tastes.
c5184807
EZ
16
17@menu
f9b4c05d 18* Calendar Customizing:: Calendar layout and hooks.
c5184807
EZ
19* Holiday Customizing:: Defining your own holidays.
20* Date Display Format:: Changing the format.
21* Time Display Format:: Changing the format.
22* Diary Customizing:: Defaults you can set.
f9b4c05d 23* Non-Gregorian Diary:: Diary entries based on other calendars.
cad04c66
GM
24* Diary Display:: A choice of ways to display the diary.
25* Fancy Diary Display:: Sorting diary entries, using included diary files.
26* Sexp Diary Entries:: More flexible diary entries.
c5184807
EZ
27@end menu
28
29@node Calendar Customizing
30@subsection Customizing the Calendar
a43a8a2e
GM
31
32@vindex calendar-intermonth-text
33@cindex calendar layout
f9b4c05d
GM
34@cindex calendar week numbers
35 The calendar display unfortunately cannot be changed from three
36months, but you can customize the whitespace used by setting the
37variables: @code{calendar-left-margin},
c1e67aad
GM
38@code{calendar-day-header-width}, @code{calendar-day-digit-width},
39@code{calendar-column-width}, and @code{calendar-intermonth-spacing}.
f9b4c05d
GM
40To display text @emph{between} the months, for example week numbers,
41customize the variables @code{calendar-intermonth-header} and
42@code{calendar-intermonth-text} as described in their documentation.
a43a8a2e 43
cad4f290
GM
44@vindex calendar-month-header
45 The variable @code{calendar-month-header} controls the text that
46appears above each month in the calendar. By default, it shows the
47month and year.
48
c5184807
EZ
49@vindex calendar-holiday-marker
50@vindex diary-entry-marker
301b181a 51@vindex calendar-today-marker
c5184807 52 The variable @code{calendar-holiday-marker} specifies how to mark a
a5987767 53date that is a holiday. Its value may be a single-character string to
f9b4c05d
GM
54insert next to the date, or a face name to use for displaying the date.
55Likewise, the variable @code{diary-entry-marker} specifies how to mark a
a5987767
GM
56date that has diary entries. The function @code{calendar-mark-today}
57uses @code{calendar-today-marker} to mark today's date. By default,
58the calendar uses faces named @code{holiday}, @code{diary}, and
f9b4c05d 59@code{calendar-today} for these purposes.
c5184807
EZ
60
61@vindex calendar-load-hook
62 The variable @code{calendar-load-hook} is a normal hook run when the
63calendar package is first loaded (before actually starting to display
64the calendar).
65
36c0514c 66@vindex calendar-initial-window-hook
c5184807 67 Starting the calendar runs the normal hook
36c0514c 68@code{calendar-initial-window-hook}. Recomputation of the calendar
c5184807
EZ
69display does not run this hook. But if you leave the calendar with the
70@kbd{q} command and reenter it, the hook runs again.@refill
71
36c0514c 72@vindex calendar-today-visible-hook
f9b4c05d 73@findex calendar-star-date
36c0514c 74 The variable @code{calendar-today-visible-hook} is a normal hook run
a5987767 75after the calendar buffer has been prepared with the calendar, when the
c5184807 76current date is visible in the window. One use of this hook is to
f9b4c05d
GM
77mark today's date; to do that use either of the functions
78@code{calendar-mark-today} or @code{calendar-star-date}:
c5184807
EZ
79
80@findex calendar-mark-today
f9b4c05d 81@smallexample
36c0514c 82(add-hook 'calendar-today-visible-hook 'calendar-mark-today)
f9b4c05d 83@end smallexample
c5184807 84
36c0514c 85@vindex calendar-today-invisible-hook
c5184807 86@noindent
36c0514c 87 A similar normal hook, @code{calendar-today-invisible-hook} is run if
c5184807
EZ
88the current date is @emph{not} visible in the window.
89
90@vindex calendar-move-hook
91 Each of the calendar cursor motion commands runs the hook
92@code{calendar-move-hook} after it moves the cursor.
93
94@node Holiday Customizing
95@subsection Customizing the Holidays
96
97@vindex calendar-holidays
f9b4c05d
GM
98@vindex holiday-oriental-holidays
99@vindex holiday-solar-holidays
a5987767
GM
100 There are several variables listing the default holidays that Emacs
101knows about. These are: @code{holiday-general-holidays},
102@code{holiday-local-holidays}, @code{holiday-solar-holidays},
103@code{holiday-bahai-holidays}, @code{holiday-christian-holidays},
104@code{holiday-hebrew-holidays}, @code{holiday-islamic-holidays},
105@code{holiday-oriental-holidays}, and @code{holiday-other-holidays}.
106The names should be self-explanatory; e.g.@: @code{holiday-solar-holidays}
107lists sun- and moon-related holidays.
36c0514c 108
f9b4c05d
GM
109You can customize these lists of holidays to your own needs, deleting or
110adding holidays as described below. Set any of them to @code{nil} to
a5987767 111not show the associated holidays.
f9b4c05d 112
36c0514c 113@vindex holiday-general-holidays
36c0514c 114@vindex holiday-local-holidays
a5987767
GM
115@vindex holiday-other-holidays
116 The general holidays are, by default, holidays common throughout the
117United States. In contrast, @code{holiday-local-holidays} and
118@code{holiday-other-holidays} are both empty by default. These are
119intended for system-wide settings and your individual use,
120respectively.
c5184807 121
f9b4c05d
GM
122@vindex holiday-bahai-holidays
123@vindex holiday-christian-holidays
124@vindex holiday-hebrew-holidays
125@vindex holiday-islamic-holidays
36c0514c
GM
126@vindex calendar-bahai-all-holidays-flag
127@vindex calendar-christian-all-holidays-flag
128@vindex calendar-hebrew-all-holidays-flag
129@vindex calendar-islamic-all-holidays-flag
c5184807
EZ
130 By default, Emacs does not include all the holidays of the religions
131that it knows, only those commonly found in secular calendars. For a
132more extensive collection of religious holidays, you can set any (or
36c0514c
GM
133all) of the variables @code{calendar-bahai-all-holidays-flag},
134@code{calendar-christian-all-holidays-flag},
135@code{calendar-hebrew-all-holidays-flag}, or
f9b4c05d 136@code{calendar-islamic-all-holidays-flag} to @code{t}.
c5184807 137
c5184807 138@cindex holiday forms
f9b4c05d 139 Each of the holiday variables is a list of @dfn{holiday forms}, each
a5987767
GM
140form describing a holiday (or sometimes a list of holidays). Here is
141a table of the possible kinds of holiday form. Day numbers and month
142numbers count starting from 1, but ``dayname'' numbers count Sunday as
1430. The argument @var{string} is always the description of the
144holiday, as a string.
c5184807
EZ
145
146@table @code
147@item (holiday-fixed @var{month} @var{day} @var{string})
148A fixed date on the Gregorian calendar.
149
f9b4c05d
GM
150@item (holiday-float @var{month} @var{dayname} @var{k} @var{string}
151 &optional @var{day})
152The @var{k}th @var{dayname} (@var{dayname}=0 for Sunday, and so on)
153after or before Gregorian date @var{month}, @var{day}. Negative @var{k}
154means count back from the end of the month. Optional @var{day} defaults
155to 1 if @var{k} is positive, and the last day of @var{month} otherwise.
c5184807 156
a43a8a2e
GM
157@item (holiday-chinese @var{month} @var{day} @var{string})
158A fixed date on the Chinese calendar.
159
c5184807
EZ
160@item (holiday-hebrew @var{month} @var{day} @var{string})
161A fixed date on the Hebrew calendar.
162
163@item (holiday-islamic @var{month} @var{day} @var{string})
164A fixed date on the Islamic calendar.
165
166@item (holiday-julian @var{month} @var{day} @var{string})
167A fixed date on the Julian calendar.
168
169@item (holiday-sexp @var{sexp} @var{string})
170A date calculated by the Lisp expression @var{sexp}. The expression
171should use the variable @code{year} to compute and return the date of a
f9b4c05d
GM
172holiday in the form of a list @code{(@var{month} @var{day} @var{year})},
173or @code{nil} if the holiday doesn't happen this year.
c5184807
EZ
174
175@item (if @var{condition} @var{holiday-form})
176A holiday that happens only if @var{condition} is true.
177
178@item (@var{function} @r{[}@var{args}@r{]})
179A list of dates calculated by the function @var{function}, called with
180arguments @var{args}.
181@end table
182
183 For example, suppose you want to add Bastille Day, celebrated in
f9b4c05d
GM
184France on July 14 (i.e., the fourteenth day of the seventh month). You
185can do this as follows:
c5184807
EZ
186
187@smallexample
98ad1bae 188(setq holiday-other-holidays '((holiday-fixed 7 14 "Bastille Day")))
c5184807
EZ
189@end smallexample
190
c5184807
EZ
191 Many holidays occur on a specific day of the week, at a specific time
192of month. Here is a holiday form describing Hurricane Supplication Day,
193celebrated in the Virgin Islands on the fourth Monday in August:
194
195@smallexample
196(holiday-float 8 1 4 "Hurricane Supplication Day")
197@end smallexample
198
199@noindent
200Here the 8 specifies August, the 1 specifies Monday (Sunday is 0,
201Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in
202the month (1 specifies the first occurrence, 2 the second occurrence,
203@minus{}1 the last occurrence, @minus{}2 the second-to-last occurrence, and
204so on).
205
102f1b54 206