Hyphen and dash fixes in texinfo files.
[bpt/emacs.git] / doc / emacs / calendar.texi
CommitLineData
102f1b54 1@c This is part of the Emacs manual. -*- coding: iso-latin-1 -*-
acaf905b 2@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2012
a8a1f60e 3@c Free Software Foundation, Inc.
8cf51b2c 4@c See file emacs.texi for copying conditions.
856ce114 5@node Calendar/Diary
8cf51b2c
GM
6@chapter The Calendar and the Diary
7@cindex calendar
8@findex calendar
9
10 Emacs provides the functions of a desk calendar, with a diary of
11planned or past events. It also has facilities for managing your
12appointments, and keeping track of how much time you spend working on
13certain projects.
14
15 To enter the calendar, type @kbd{M-x calendar}; this displays a
16three-month calendar centered on the current month, with point on the
17current date. With a numeric argument, as in @kbd{C-u M-x calendar}, it
18prompts you for the month and year to be the center of the three-month
19calendar. The calendar uses its own buffer, whose major mode is
20Calendar mode.
21
b597d348
GM
22 @kbd{Mouse-3} in the calendar brings up a menu of operations on a
23particular date; @kbd{Mouse-2} brings up a menu of commonly used
8cf51b2c
GM
24calendar features that are independent of any particular date. To exit
25the calendar, type @kbd{q}.
26
27@iftex
28 This chapter describes the basic calendar features.
eceeb5fc
CY
29For more advanced topics,
30@pxref{Advanced Calendar/Diary Usage,,, emacs-xtra, Specialized Emacs Features}.
8cf51b2c
GM
31@end iftex
32
33@menu
34* Calendar Motion:: Moving through the calendar; selecting a date.
35* Scroll Calendar:: Bringing earlier or later months onto the screen.
36* Counting Days:: How many days are there between two dates?
37* General Calendar:: Exiting or recomputing the calendar.
38* Writing Calendar Files:: Writing calendars to files of various formats.
39* Holidays:: Displaying dates of holidays.
40* Sunrise/Sunset:: Displaying local times of sunrise and sunset.
41* Lunar Phases:: Displaying phases of the moon.
42* Other Calendars:: Converting dates to other calendar systems.
43* Diary:: Displaying events from your diary.
8838673e 44* Appointments:: Reminders when it's time to do something.
8cf51b2c
GM
45* Importing Diary:: Converting diary events to/from other formats.
46* Daylight Saving:: How to specify when daylight saving time is active.
47* Time Intervals:: Keeping track of time intervals.
48@ifnottex
49* Advanced Calendar/Diary Usage:: Advanced Calendar/Diary customization.
50@end ifnottex
51@end menu
52
53@node Calendar Motion
54@section Movement in the Calendar
55
56@cindex moving inside the calendar
57 Calendar mode provides commands to move through the calendar in
58logical units of time such as days, weeks, months, and years. If you
59move outside the three months originally displayed, the calendar
60display ``scrolls'' automatically through time to make the selected
61date visible. Moving to a date lets you view its holidays or diary
62entries, or convert it to other calendars; moving by long time periods
63is also useful simply to scroll the calendar.
64
65@menu
66* Calendar Unit Motion:: Moving by days, weeks, months, and years.
67* Move to Beginning or End:: Moving to start/end of weeks, months, and years.
68* Specified Dates:: Moving to the current date or another
69 specific date.
70@end menu
71
72@node Calendar Unit Motion
73@subsection Motion by Standard Lengths of Time
74
75 The commands for movement in the calendar buffer parallel the
76commands for movement in text. You can move forward and backward by
77days, weeks, months, and years.
78
79@table @kbd
80@item C-f
81Move point one day forward (@code{calendar-forward-day}).
82@item C-b
83Move point one day backward (@code{calendar-backward-day}).
84@item C-n
85Move point one week forward (@code{calendar-forward-week}).
86@item C-p
87Move point one week backward (@code{calendar-backward-week}).
88@item M-@}
89Move point one month forward (@code{calendar-forward-month}).
90@item M-@{
91Move point one month backward (@code{calendar-backward-month}).
92@item C-x ]
93Move point one year forward (@code{calendar-forward-year}).
94@item C-x [
95Move point one year backward (@code{calendar-backward-year}).
96@end table
97
98@kindex C-f @r{(Calendar mode)}
99@findex calendar-forward-day
100@kindex C-b @r{(Calendar mode)}
101@findex calendar-backward-day
102@kindex C-n @r{(Calendar mode)}
103@findex calendar-forward-week
104@kindex C-p @r{(Calendar mode)}
105@findex calendar-backward-week
106 The day and week commands are natural analogues of the usual Emacs
107commands for moving by characters and by lines. Just as @kbd{C-n}
108usually moves to the same column in the following line, in Calendar
109mode it moves to the same day in the following week. And @kbd{C-p}
110moves to the same day in the previous week.
111
112 The arrow keys are equivalent to @kbd{C-f}, @kbd{C-b}, @kbd{C-n} and
113@kbd{C-p}, just as they normally are in other modes.
114
115@kindex M-@} @r{(Calendar mode)}
116@findex calendar-forward-month
117@kindex M-@{ @r{(Calendar mode)}
118@findex calendar-backward-month
119@kindex C-x ] @r{(Calendar mode)}
120@findex calendar-forward-year
121@kindex C-x [ @r{(Calendar mode)}
122@findex calendar-forward-year
123 The commands for motion by months and years work like those for
124weeks, but move a larger distance. The month commands @kbd{M-@}} and
125@kbd{M-@{} move forward or backward by an entire month. The year
126commands @kbd{C-x ]} and @w{@kbd{C-x [}} move forward or backward a
127whole year.
128
129 The easiest way to remember these commands is to consider months and
130years analogous to paragraphs and pages of text, respectively. But
131the commands themselves are not quite analogous. The ordinary Emacs
132paragraph commands move to the beginning or end of a paragraph,
133whereas these month and year commands move by an entire month or an
134entire year, keeping the same date within the month or year.
135
136 All these commands accept a numeric argument as a repeat count.
137For convenience, the digit keys and the minus sign specify numeric
138arguments in Calendar mode even without the Meta modifier. For example,
139@kbd{100 C-f} moves point 100 days forward from its present location.
140
141@node Move to Beginning or End
142@subsection Beginning or End of Week, Month or Year
143
144 A week (or month, or year) is not just a quantity of days; we think of
145weeks (months, years) as starting on particular dates. So Calendar mode
d1354af0 146provides commands to move to the start or end of a week, month or year:
8cf51b2c
GM
147
148@table @kbd
149@kindex C-a @r{(Calendar mode)}
150@findex calendar-beginning-of-week
151@item C-a
152Move point to start of week (@code{calendar-beginning-of-week}).
153@kindex C-e @r{(Calendar mode)}
154@findex calendar-end-of-week
155@item C-e
156Move point to end of week (@code{calendar-end-of-week}).
157@kindex M-a @r{(Calendar mode)}
158@findex calendar-beginning-of-month
159@item M-a
160Move point to start of month (@code{calendar-beginning-of-month}).
161@kindex M-e @r{(Calendar mode)}
162@findex calendar-end-of-month
163@item M-e
164Move point to end of month (@code{calendar-end-of-month}).
165@kindex M-< @r{(Calendar mode)}
166@findex calendar-beginning-of-year
167@item M-<
168Move point to start of year (@code{calendar-beginning-of-year}).
169@kindex M-> @r{(Calendar mode)}
170@findex calendar-end-of-year
171@item M->
172Move point to end of year (@code{calendar-end-of-year}).
173@end table
174
175 These commands also take numeric arguments as repeat counts, with the
176repeat count indicating how many weeks, months, or years to move
177backward or forward.
178
179@vindex calendar-week-start-day
180@cindex weeks, which day they start on
181@cindex calendar, first day of week
182 By default, weeks begin on Sunday. To make them begin on Monday
183instead, set the variable @code{calendar-week-start-day} to 1.
184
185@node Specified Dates
186@subsection Specified Dates
187
188 Calendar mode provides commands for moving to a particular date
189specified in various ways.
190
191@table @kbd
192@item g d
193Move point to specified date (@code{calendar-goto-date}).
194@item g D
195Move point to specified day of year (@code{calendar-goto-day-of-year}).
196@item g w
373cb509 197Move point to specified week of year (@code{calendar-iso-goto-week}).
8cf51b2c
GM
198@item o
199Center calendar around specified month (@code{calendar-other-month}).
200@item .
201Move point to today's date (@code{calendar-goto-today}).
202@end table
203
204@kindex g d @r{(Calendar mode)}
205@findex calendar-goto-date
206 @kbd{g d} (@code{calendar-goto-date}) prompts for a year, a month, and a day
207of the month, and then moves to that date. Because the calendar includes all
208dates from the beginning of the current era, you must type the year in its
209entirety; that is, type @samp{1990}, not @samp{90}.
210
211@kindex g D @r{(Calendar mode)}
212@findex calendar-goto-day-of-year
213@kindex g w @r{(Calendar mode)}
373cb509 214@findex calendar-iso-goto-week
8cf51b2c
GM
215 @kbd{g D} (@code{calendar-goto-day-of-year}) prompts for a year and
216day number, and moves to that date. Negative day numbers count
217backward from the end of the year. @kbd{g w}
373cb509 218(@code{calendar-iso-goto-week}) prompts for a year and week number,
8cf51b2c
GM
219and moves to that week.
220
221@kindex o @r{(Calendar mode)}
222@findex calendar-other-month
223 @kbd{o} (@code{calendar-other-month}) prompts for a month and year,
224then centers the three-month calendar around that month.
225
226@kindex . @r{(Calendar mode)}
227@findex calendar-goto-today
228 You can return to today's date with @kbd{.}@:
229(@code{calendar-goto-today}).
230
231@node Scroll Calendar
232@section Scrolling in the Calendar
233
234@cindex scrolling in the calendar
235 The calendar display scrolls automatically through time when you
236move out of the visible portion. You can also scroll it manually.
237Imagine that the calendar window contains a long strip of paper with
238the months on it. Scrolling the calendar means moving the strip
239horizontally, so that new months become visible in the window.
240
241@table @kbd
242@item >
36c0514c 243Scroll calendar one month forward (@code{calendar-scroll-left}).
8cf51b2c 244@item <
36c0514c 245Scroll calendar one month backward (@code{calendar-scroll-right}).
8cf51b2c 246@item C-v
b5700de6 247@itemx @key{next}
84f4a531 248Scroll forward by three months (@code{calendar-scroll-left-three-months}).
8cf51b2c 249@item M-v
b5700de6 250@itemx @key{prior}
84f4a531 251Scroll backward by three months (@code{calendar-scroll-right-three-months}).
8cf51b2c
GM
252@end table
253
254@kindex > @r{(Calendar mode)}
36c0514c 255@findex calendar-scroll-left
8cf51b2c 256@kindex < @r{(Calendar mode)}
36c0514c 257@findex calendar-scroll-right
8cf51b2c
GM
258 The most basic calendar scroll commands scroll by one month at a
259time. This means that there are two months of overlap between the
260display before the command and the display after. @kbd{>} scrolls the
261calendar contents one month forward in time. @kbd{<} scrolls the
262contents one month backwards in time.
263
264@kindex C-v @r{(Calendar mode)}
36c0514c 265@findex calendar-scroll-left-three-months
8cf51b2c 266@kindex M-v @r{(Calendar mode)}
36c0514c 267@findex calendar-scroll-right-three-months
8cf51b2c
GM
268 The commands @kbd{C-v} and @kbd{M-v} scroll the calendar by an entire
269``screenful''---three months---in analogy with the usual meaning of
270these commands. @kbd{C-v} makes later dates visible and @kbd{M-v} makes
271earlier dates visible. These commands take a numeric argument as a
272repeat count; in particular, since @kbd{C-u} multiplies the next command
273by four, typing @kbd{C-u C-v} scrolls the calendar forward by a year and
274typing @kbd{C-u M-v} scrolls the calendar backward by a year.
275
b5700de6 276 The function keys @key{next} and @key{prior} are equivalent to
8cf51b2c
GM
277@kbd{C-v} and @kbd{M-v}, just as they are in other modes.
278
279@node Counting Days
280@section Counting Days
281
282@table @kbd
283@item M-=
284Display the number of days in the current region
285(@code{calendar-count-days-region}).
286@end table
287
288@kindex M-= @r{(Calendar mode)}
289@findex calendar-count-days-region
d1354af0
GM
290 To determine the number of days in a range, set the mark on one
291date using @kbd{C-SPC}, move point to another date, and type @kbd{M-=}
8cf51b2c
GM
292(@code{calendar-count-days-region}). The numbers of days shown is
293@emph{inclusive}; that is, it includes the days specified by mark and
294point.
295
296@node General Calendar
297@section Miscellaneous Calendar Commands
298
299@table @kbd
300@item p d
301Display day-in-year (@code{calendar-print-day-of-year}).
302@item C-c C-l
36c0514c 303Regenerate the calendar window (@code{calendar-redraw}).
8cf51b2c
GM
304@item SPC
305Scroll the next window up (@code{scroll-other-window}).
306@item DEL
307Scroll the next window down (@code{scroll-other-window-down}).
308@item q
36c0514c 309Exit from calendar (@code{calendar-exit}).
8cf51b2c
GM
310@end table
311
312@kindex p d @r{(Calendar mode)}
313@cindex day of year
314@findex calendar-print-day-of-year
315 To display the number of days elapsed since the start of the year, or
316the number of days remaining in the year, type the @kbd{p d} command
317(@code{calendar-print-day-of-year}). This displays both of those
318numbers in the echo area. The count of days elapsed includes the
319selected date. The count of days remaining does not include that
320date.
321
322@kindex C-c C-l @r{(Calendar mode)}
36c0514c 323@findex calendar-redraw
8cf51b2c 324 If the calendar window text gets corrupted, type @kbd{C-c C-l}
36c0514c 325(@code{calendar-redraw}) to redraw it. (This can only happen if you use
8cf51b2c
GM
326non-Calendar-mode editing commands.)
327
328@kindex SPC @r{(Calendar mode)}
329 In Calendar mode, you can use @kbd{SPC} (@code{scroll-other-window})
330and @kbd{DEL} (@code{scroll-other-window-down}) to scroll the other
373cb509
GM
331window (if there is one) up or down, respectively. This is handy when
332you display a list of holidays or diary entries in another window.
8cf51b2c
GM
333
334@kindex q @r{(Calendar mode)}
335@findex exit-calendar
36c0514c
GM
336@vindex calendar-remove-frame-by-deleting
337 To exit from the calendar, type @kbd{q} (@code{calendar-exit}). This
8cf51b2c
GM
338buries all buffers related to the calendar, selecting other buffers.
339(If a frame contains a dedicated calendar window, exiting from the
36c0514c
GM
340calendar deletes or iconifies that frame depending on the value of
341@code{calendar-remove-frame-by-deleting}.)
8cf51b2c 342
d1354af0
GM
343@c FIXME this mentions holidays and diary entries, albeit briefly, so
344@c should it be moved after those sections? Or at least xref them.
8cf51b2c
GM
345@node Writing Calendar Files
346@section Writing Calendar Files
347
c1dabff0 348 You can write calendars and diary entries to HTML and @LaTeX{} files.
8cf51b2c
GM
349
350@cindex calendar and HTML
351 The Calendar HTML commands produce files of HTML code that contain
b859a383
GM
352calendar, holiday, and diary entries. Each file applies to one month,
353and has a name of the format @file{@var{yyyy}-@var{mm}.html}, where
354@var{yyyy} and @var{mm} are the four-digit year and two-digit month,
355respectively. The variable @code{cal-html-directory} specifies the
356default output directory for the HTML files. To prevent holidays
357from being shown, customize @code{cal-html-holidays}.
8cf51b2c
GM
358
359@vindex cal-html-css-default
360 Diary entries enclosed by @code{<} and @code{>} are interpreted as
361HTML tags (for example: this is a diary entry with <font
362color=''red''>some red text</font>). You can change the overall
363appearance of the displayed HTML pages (for example, the color of
364various page elements, header styles) via a stylesheet @file{cal.css} in
365the directory containing the HTML files (see the value of the variable
366@code{cal-html-css-default} for relevant style settings).
367
368@kindex t @r{(Calendar mode)}
369@table @kbd
370@item H m
371Generate a one-month calendar (@code{cal-html-cursor-month}).
372@item H y
373Generate a calendar file for each month of a year, as well as an index
374page (@code{cal-html-cursor-year}). By default, this command writes
f99f1641 375files to a @var{yyyy} subdirectory---if this is altered some hyperlinks
8cf51b2c
GM
376between years will not work.
377@end table
378
379 If the variable @code{cal-html-print-day-number-flag} is
380non-@code{nil}, then the monthly calendars show the day-of-the-year
381number. The variable @code{cal-html-year-index-cols} specifies the
382number of columns in the yearly index page.
383
c1dabff0
GM
384@cindex calendar and @LaTeX{}
385 The Calendar @LaTeX{} commands produce a buffer of @LaTeX{} code that
8cf51b2c
GM
386prints as a calendar. Depending on the command you use, the printed
387calendar covers the day, week, month or year that point is in.
388
389@kindex t @r{(Calendar mode)}
390@table @kbd
391@item t m
392Generate a one-month calendar (@code{cal-tex-cursor-month}).
393@item t M
394Generate a sideways-printing one-month calendar
395(@code{cal-tex-cursor-month-landscape}).
396@item t d
397Generate a one-day calendar
398(@code{cal-tex-cursor-day}).
399@item t w 1
f1f4dba0 400Generate a one-page calendar for one week, with hours
8cf51b2c
GM
401(@code{cal-tex-cursor-week}).
402@item t w 2
f1f4dba0 403Generate a two-page calendar for one week, with hours
8cf51b2c
GM
404(@code{cal-tex-cursor-week2}).
405@item t w 3
f1f4dba0 406Generate an ISO-style calendar for one week, without hours
8cf51b2c
GM
407(@code{cal-tex-cursor-week-iso}).
408@item t w 4
f1f4dba0 409Generate a calendar for one Monday-starting week, with hours
8cf51b2c 410(@code{cal-tex-cursor-week-monday}).
f1f4dba0
GM
411@item t w W
412Generate a two-page calendar for one week, without hours
413(@code{cal-tex-cursor-week2-summary}).
8cf51b2c
GM
414@item t f w
415Generate a Filofax-style two-weeks-at-a-glance calendar
416(@code{cal-tex-cursor-filofax-2week}).
417@item t f W
418Generate a Filofax-style one-week-at-a-glance calendar
419(@code{cal-tex-cursor-filofax-week}).
420@item t y
421Generate a calendar for one year
422(@code{cal-tex-cursor-year}).
423@item t Y
424Generate a sideways-printing calendar for one year
425(@code{cal-tex-cursor-year-landscape}).
426@item t f y
427Generate a Filofax-style calendar for one year
428(@code{cal-tex-cursor-filofax-year}).
429@end table
430
431 Some of these commands print the calendar sideways (in ``landscape
432mode''), so it can be wider than it is long. Some of them use Filofax
433paper size (3.75in x 6.75in). All of these commands accept a prefix
d1354af0 434argument, which specifies how many days, weeks, months or years to print
8cf51b2c
GM
435(starting always with the selected one).
436
437 If the variable @code{cal-tex-holidays} is non-@code{nil} (the default),
438then the printed calendars show the holidays in @code{calendar-holidays}.
439If the variable @code{cal-tex-diary} is non-@code{nil} (the default is
440@code{nil}), diary entries are included also (in monthly, filofax, and
441iso-week calendars only). If the variable @code{cal-tex-rules} is
442non-@code{nil} (the default is @code{nil}), the calendar displays ruled
443pages in styles that have sufficient room. Consult the documentation of
444the individual cal-tex functions to see which calendars support which
445features.
446
447 You can use the variable @code{cal-tex-preamble-extra} to insert extra
c1dabff0 448@LaTeX{} commands in the preamble of the generated document if you need
8cf51b2c
GM
449to.
450
451@node Holidays
452@section Holidays
453@cindex holidays
454
373cb509
GM
455 The Emacs calendar knows about many major and minor holidays,
456and can display them. You can add your own holidays to the default list.
8cf51b2c
GM
457
458@table @kbd
d1354af0
GM
459@item Mouse-3 Holidays
460@itemx h
8cf51b2c
GM
461Display holidays for the selected date
462(@code{calendar-cursor-holidays}).
8cf51b2c 463@item x
fc8ee913 464Mark holidays in the calendar window (@code{calendar-mark-holidays}).
8cf51b2c
GM
465@item u
466Unmark calendar window (@code{calendar-unmark}).
467@item a
468List all holidays for the displayed three months in another window
fc8ee913 469(@code{calendar-list-holidays}).
8cf51b2c
GM
470@item M-x holidays
471List all holidays for three months around today's date in another
472window.
126050ff 473@item M-x list-holidays
8cf51b2c
GM
474List holidays in another window for a specified range of years.
475@end table
476
477@kindex h @r{(Calendar mode)}
478@findex calendar-cursor-holidays
36c0514c 479@vindex calendar-view-holidays-initially-flag
8cf51b2c
GM
480 To see if any holidays fall on a given date, position point on that
481date in the calendar window and use the @kbd{h} command. Alternatively,
b597d348 482click on that date with @kbd{Mouse-3} and then choose @kbd{Holidays}
8cf51b2c
GM
483from the menu that appears. Either way, this displays the holidays for
484that date, in the echo area if they fit there, otherwise in a separate
485window.
486
487@kindex x @r{(Calendar mode)}
fc8ee913 488@findex calendar-mark-holidays
8cf51b2c
GM
489@kindex u @r{(Calendar mode)}
490@findex calendar-unmark
36c0514c 491@vindex calendar-mark-holidays-flag
8cf51b2c
GM
492 To view the distribution of holidays for all the dates shown in the
493calendar, use the @kbd{x} command. This displays the dates that are
160f11d3 494holidays in a different face.
8cf51b2c 495@iftex
eceeb5fc 496@xref{Calendar Customizing,,, emacs-xtra, Specialized Emacs Features}.
8cf51b2c
GM
497@end iftex
498@ifnottex
499@xref{Calendar Customizing, calendar-holiday-marker}.
500@end ifnottex
501 The command applies both to the currently visible months and to
502other months that subsequently become visible by scrolling. To turn
503marking off and erase the current marks, type @kbd{u}, which also
504erases any diary marks (@pxref{Diary}). If the variable
36c0514c 505@code{calendar-mark-holidays-flag} is non-@code{nil}, creating or
8cf51b2c
GM
506updating the calendar marks holidays automatically.
507
508@kindex a @r{(Calendar mode)}
fc8ee913 509@findex calendar-list-holidays
8cf51b2c
GM
510 To get even more detailed information, use the @kbd{a} command, which
511displays a separate buffer containing a list of all holidays in the
512current three-month range. You can use @key{SPC} and @key{DEL} in the
513calendar window to scroll that list up and down, respectively.
514
515@findex holidays
516 The command @kbd{M-x holidays} displays the list of holidays for the
517current month and the preceding and succeeding months; this works even
518if you don't have a calendar window. If the variable
36c0514c 519@code{calendar-view-holidays-initially-flag} is non-@code{nil}, creating
8cf51b2c
GM
520the calendar displays holidays in this way. If you want the list of
521holidays centered around a different month, use @kbd{C-u M-x
522holidays}, which prompts for the month and year.
523
524 The holidays known to Emacs include United States holidays and the
102f1b54 525