Commit | Line | Data |
---|---|---|
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 |
13 | features of the calendar and diary. It starts with some of the | |
14 | many ways in which you can customize the calendar and diary to suit | |
15 | your 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 | |
36 | months, but you can customize the whitespace used by setting the | |
37 | variables: @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 |
40 | To display text @emph{between} the months, for example week numbers, |
41 | customize 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 | |
46 | appears above each month in the calendar. By default, it shows the | |
47 | month 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 | 53 | date that is a holiday. Its value may be a single-character string to |
f9b4c05d GM |
54 | insert next to the date, or a face name to use for displaying the date. |
55 | Likewise, the variable @code{diary-entry-marker} specifies how to mark a | |
a5987767 GM |
56 | date that has diary entries. The function @code{calendar-mark-today} |
57 | uses @code{calendar-today-marker} to mark today's date. By default, | |
58 | the 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 | |
63 | calendar package is first loaded (before actually starting to display | |
64 | the 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 |
69 | display 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 | 75 | after the calendar buffer has been prepared with the calendar, when the |
c5184807 | 76 | current date is visible in the window. One use of this hook is to |
f9b4c05d GM |
77 | mark 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 |
88 | the 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 |
101 | knows 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}. | |
106 | The names should be self-explanatory; e.g.@: @code{holiday-solar-holidays} | |
107 | lists sun- and moon-related holidays. | |
36c0514c | 108 | |
f9b4c05d GM |
109 | You can customize these lists of holidays to your own needs, deleting or |
110 | adding holidays as described below. Set any of them to @code{nil} to | |
a5987767 | 111 | not 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 | |
117 | United States. In contrast, @code{holiday-local-holidays} and | |
118 | @code{holiday-other-holidays} are both empty by default. These are | |
119 | intended for system-wide settings and your individual use, | |
120 | respectively. | |
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 |
131 | that it knows, only those commonly found in secular calendars. For a | |
132 | more extensive collection of religious holidays, you can set any (or | |
36c0514c GM |
133 | all) 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 |
140 | form describing a holiday (or sometimes a list of holidays). Here is |
141 | a table of the possible kinds of holiday form. Day numbers and month | |
142 | numbers count starting from 1, but ``dayname'' numbers count Sunday as | |
143 | 0. The argument @var{string} is always the description of the | |
144 | holiday, as a string. | |
c5184807 EZ |
145 | |
146 | @table @code | |
147 | @item (holiday-fixed @var{month} @var{day} @var{string}) | |
148 | A 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}) | |
152 | The @var{k}th @var{dayname} (@var{dayname}=0 for Sunday, and so on) | |
153 | after or before Gregorian date @var{month}, @var{day}. Negative @var{k} | |
154 | means count back from the end of the month. Optional @var{day} defaults | |
155 | to 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}) |
158 | A fixed date on the Chinese calendar. | |
159 | ||
c5184807 EZ |
160 | @item (holiday-hebrew @var{month} @var{day} @var{string}) |
161 | A fixed date on the Hebrew calendar. | |
162 | ||
163 | @item (holiday-islamic @var{month} @var{day} @var{string}) | |
164 | A fixed date on the Islamic calendar. | |
165 | ||
166 | @item (holiday-julian @var{month} @var{day} @var{string}) | |
167 | A fixed date on the Julian calendar. | |
168 | ||
169 | @item (holiday-sexp @var{sexp} @var{string}) | |
170 | A date calculated by the Lisp expression @var{sexp}. The expression | |
171 | should use the variable @code{year} to compute and return the date of a | |
f9b4c05d GM |
172 | holiday in the form of a list @code{(@var{month} @var{day} @var{year})}, |
173 | or @code{nil} if the holiday doesn't happen this year. | |
c5184807 EZ |
174 | |
175 | @item (if @var{condition} @var{holiday-form}) | |
176 | A holiday that happens only if @var{condition} is true. | |
177 | ||
178 | @item (@var{function} @r{[}@var{args}@r{]}) | |
179 | A list of dates calculated by the function @var{function}, called with | |
180 | arguments @var{args}. | |
181 | @end table | |
182 | ||
183 | For example, suppose you want to add Bastille Day, celebrated in | |
f9b4c05d GM |
184 | France on July 14 (i.e., the fourteenth day of the seventh month). You |
185 | can 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 |
192 | of month. Here is a holiday form describing Hurricane Supplication Day, | |
193 | celebrated 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 | |
200 | Here the 8 specifies August, the 1 specifies Monday (Sunday is 0, | |
201 | Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in | |
202 | the month (1 specifies the first occurrence, 2 the second occurrence, | |
203 | @minus{}1 the last occurrence, @minus{}2 the second-to-last occurrence, and | |
204 | so on). | |
205 | ||
102f1b54 | 206 |