1 \input texinfo @c -*-texinfo-*-
2 @comment %**start of header
3 @setfilename ../info/emacs-xtra
4 @settitle Specialized Emacs Features
8 @comment %**end of header
11 This manual describes specialized features of Emacs.
13 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
16 Permission is granted to copy, distribute and/or modify this document
17 under the terms of the GNU Free Documentation License, Version 1.2 or
18 any later version published by the Free Software Foundation; with no
19 Invariant Sections, with the Front-Cover texts being ``A GNU
20 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
21 license is included in the section entitled ``GNU Free Documentation
22 License'' in the Emacs manual.
24 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
25 this GNU Manual, like GNU software. Copies published by the Free
26 Software Foundation raise funds for GNU development.''
28 This document is part of a collection distributed under the GNU Free
29 Documentation License. If you want to distribute this document
30 separately from the collection, you can do so by adding a copy of the
31 license to the document, as described in section 6 of the license.
37 * Emacs-Xtra: (emacs-xtra). Specialized Emacs features.
41 @title Specialized Emacs Features
43 @vskip 0pt plus 1filll
51 @top Specialized Emacs Features
58 * Introduction:: What documentation belongs here?
59 * Autorevert:: Auto Reverting non-file buffers.
60 * Subdir switches:: Subdirectory switches in Dired.
61 * Advanced Calendar/Diary Usage:: Advanced Calendar/Diary customization.
66 @unnumbered Introduction
68 This manual contains detailed information about various features that
69 are too specialized to be included in the Emacs manual. It is
70 intended to be readable by anyone having a basic knowledge of Emacs.
71 However, certain sections may be intended for a more specialized
72 audience, such as Elisp authors. This should be clearly pointed out
73 at the beginning of these sections.
75 This manual is intended as a complement, rather than an alternative,
76 to other ways to gain a more detailed knowledge of Emacs than the
77 Emacs manual can provide, such as browsing packages using @kbd{C-h p},
78 accessing mode documentation using @kbd{C-h m} and browsing user
79 options using Custom. Also, certain packages, or collections of
80 related features, have their own manuals. The present manual is
81 mainly intended to be a collection of smaller specialized features,
82 too small to get their own manual.
84 Sections intended specifically for Elisp programmers can follow the
85 style of the Elisp manual. Other sections should follow the style of
89 @chapter Auto Reverting non-file Buffers
91 Normally Global Auto Revert Mode only reverts file buffers. There are
92 two ways to auto-revert certain non-file buffers: enabling Auto Revert
93 Mode in those buffers (using @kbd{M-x auto-revert-mode}) and setting
94 @code{global-auto-revert-non-file-buffers} to @code{t}. The latter
95 enables Auto Reverting for all types of buffers for which it is
96 implemented, that is, for the types of buffers listed in the menu
99 Like file buffers, non-file buffers should normally not revert while
100 you are working on them, or while they contain information that might
101 get lost after reverting. Therefore, they do not revert if they are
102 ``modified''. This can get tricky, because deciding when a non-file
103 buffer should be marked modified is usually more difficult than for
106 Another tricky detail is that, for efficiency reasons, Auto Revert
107 often does not try to detect all possible changes in the buffer, only
108 changes that are ``major'' or easy to detect. Hence, enabling
109 auto-reverting for a non-file buffer does not always guarantee that
110 all information in the buffer is up to date and does not necessarily
111 make manual reverts useless.
113 At the other extreme, certain buffers automatically auto-revert every
114 @code{auto-revert-interval} seconds. (This currently only applies to
115 the Buffer Menu.) In this case, Auto Revert does not print any
116 messages while reverting, even when @code{auto-revert-verbose} is
119 The details depend on the particular types of buffers and are
120 explained in the corresponding sections.
123 * Auto Reverting the Buffer Menu::
124 * Auto Reverting Dired::
125 * Supporting additional buffers::
128 @node Auto Reverting the Buffer Menu
129 @section Auto Reverting the Buffer Menu
131 If auto-reverting of non-file buffers is enabled, the Buffer Menu
132 automatically reverts every @code{auto-revert-interval} seconds,
133 whether there is a need for it or not. (It would probably take longer
134 to check whether there is a need than to actually revert.)
136 If the Buffer Menu inappropriately gets marked modified, just revert
137 it manually using @kbd{g} and auto-reverting will resume. However, if
138 you marked certain buffers to get deleted or to be displayed, you have
139 to be careful, because reverting erases all marks. The fact that
140 adding marks sets the buffer's modified flag prevents Auto Revert from
141 automatically erasing the marks.
143 @node Auto Reverting Dired
144 @section Auto Reverting Dired buffers
146 Auto-reverting Dired buffers currently works on GNU or Unix style
147 operating systems. It may not work satisfactorily on some other
150 Dired buffers only auto-revert when the file list of the buffer's main
151 directory changes. They do not auto-revert when information about a
152 particular file changes or when inserted subdirectories change. To be
153 sure that @emph{all} listed information is up to date, you have to
154 manually revert using @kbd{g}, @emph{even} if auto-reverting is
155 enabled in the Dired buffer. Sometimes, you might get the impression
156 that modifying or saving files listed in the main directory actually
157 does cause auto-reverting. This is because making changes to a file,
158 or saving it, very often causes changes in the directory itself, for
159 instance, through backup files or auto-save files. However, this is
162 If the Dired buffer is marked modified and there are no changes you
163 want to protect, then most of the time you can make auto-reverting
164 resume by manually reverting the buffer using @kbd{g}. There is one
165 exception. If you flag or mark files, you can safely revert the
166 buffer. This will not erase the flags or marks (unless the marked
167 file has been deleted, of course). However, the buffer will stay
168 modified, even after reverting, and auto-reverting will not resume.
169 This is because, if you flag or mark files, you may be working on the
170 buffer and you might not want the buffer to change without warning.
171 If you want auto-reverting to resume in the presence of marks and
172 flags, mark the buffer non-modified using @kbd{M-~}. However, adding,
173 deleting or changing marks or flags will mark it modified again.
175 Remote Dired buffers are not auto-reverted. Neither are Dired buffers
176 for which you used shell wildcards or file arguments to list only some
177 of the files. @samp{*Find*} and @samp{*Locate*} buffers do not
180 @node Supporting additional buffers
181 @section Adding Support for Auto-Reverting additional Buffers.
183 This section is intended for Elisp programmers who would like to add
184 support for auto-reverting new types of buffers.
186 To support auto-reverting the buffer must first of all have a
187 @code{revert-buffer-function}. @xref{Definition of
188 revert-buffer-function,, Reverting, elisp, the Emacs Lisp Reference Manual}.
190 In addition, it @emph{must} have a @code{buffer-stale-function}.
192 @defvar buffer-stale-function
193 The value of this variable is a function to check whether a non-file
194 buffer needs reverting. This should be a function with one optional
195 argument @var{noconfirm}. The function should return non-@code{nil}
196 if the buffer should be reverted. The buffer is current when this
199 While this function is mainly intended for use in auto-reverting, it
200 could be used for other purposes as well. For instance, if
201 auto-reverting is not enabled, it could be used to warn the user that
202 the buffer needs reverting. The idea behind the @var{noconfirm}
203 argument is that it should be @code{t} if the buffer is going to be
204 reverted without asking the user and @code{nil} if the function is
205 just going to be used to warn the user that the buffer is out of date.
206 In particular, for use in auto-reverting, @var{noconfirm} is @code{t}.
207 If the function is only going to be used for auto-reverting, you can
208 ignore the @var{noconfirm} argument.
210 If you just want to automatically auto-revert every
211 @code{auto-revert-interval} seconds, use:
214 (set (make-local-variable 'buffer-stale-function)
215 #'(lambda (&optional noconfirm) 'fast))
219 in the buffer's mode function.
221 The special return value @samp{fast} tells the caller that the need
222 for reverting was not checked, but that reverting the buffer is fast.
223 It also tells Auto Revert not to print any revert messages, even if
224 @code{auto-revert-verbose} is non-@code{nil}. This is important, as
225 getting revert messages every @code{auto-revert-interval} seconds can
226 be very annoying. The information provided by this return value could
227 also be useful if the function is consulted for purposes other than
231 Once the buffer has a @code{revert-buffer-function} and a
232 @code{buffer-stale-function}, several problems usually remain.
234 The buffer will only auto-revert if it is marked unmodified. Hence,
235 you will have to make sure that various functions mark the buffer
236 modified if and only if either the buffer contains information that
237 might be lost by reverting or there is reason to believe that the user
238 might be inconvenienced by auto-reverting, because he is actively
239 working on the buffer. The user can always override this by manually
240 adjusting the modified status of the buffer. To support this, calling
241 the @code{revert-buffer-function} on a buffer that is marked
242 unmodified should always keep the buffer marked unmodified.
244 It is important to assure that point does not continuously jump around
245 as a consequence of auto-reverting. Of course, moving point might be
246 inevitable if the buffer radically changes.
248 You should make sure that the @code{revert-buffer-function} does not
249 print messages that unnecessarily duplicate Auto Revert's own messages
250 if @code{auto-revert-verbose} is @code{t} and effectively override a
251 @code{nil} value for @code{auto-revert-verbose}. Hence, adapting a
252 mode for auto-reverting often involves getting rid of such messages.
253 This is especially important for buffers that automatically
254 auto-revert every @code{auto-revert-interval} seconds.
256 Also, you may want to update the documentation string of
257 @code{global-auto-revert-non-file-buffers}.
260 Finally, you should add a node to this chapter's menu. This node
263 Finally, you should add a section to this chapter. This section
265 should at the very least make clear whether enabling auto-reverting
266 for the buffer reliably assures that all information in the buffer is
267 completely up to date (or will be after @code{auto-revert-interval}
270 @node Subdir switches
271 @chapter Subdirectory Switches in Dired
273 You can insert subdirectories with specified @code{ls} switches in
274 Dired buffers, using @kbd{C-u i}. You can change the @code{ls}
275 switches of an already inserted subdirectory using @kbd{C-u l}.
277 In Emacs versions 22.1 and later, Dired remembers the switches, so
278 that reverting the buffer will not change them back to the main
279 directory's switches. Deleting a subdirectory forgets about its
282 Using @code{dired-undo} (usually bound to @kbd{C-_} and @kbd{C-x u})
283 to reinsert or delete subdirectories, that were inserted with explicit
284 switches, can bypass Dired's machinery for remembering (or forgetting)
285 switches. Deleting a subdirectory using @code{dired-undo} does not
286 forget its switches. When later reinserted using @kbd{i}, it will be
287 reinserted using its old switches. Using @code{dired-undo} to
288 reinsert a subdirectory that was deleted using the regular
289 Dired commands (not @code{dired-undo}) will originally insert it with
290 its old switches. However, reverting the buffer will relist it using
291 the buffer's default switches. If any of this yields problems, you
292 can easily correct the situation using @kbd{C-u i} or @kbd{C-u l}.
294 Dired does not remember the @code{R} switch. Inserting a subdirectory
295 with switches that include the @code{R} switch is equivalent with
296 inserting each of its subdirectories using all remaining switches.
297 For instance, updating or killing a subdirectory that was inserted
298 with the @code{R} switch will not update or kill its subdirectories.
300 The buffer's default switches do not affect subdirectories that were
301 inserted using explicitly specified switches. In particular,
302 commands such as @kbd{s}, that change the buffer's switches do not
303 affect such subdirectories. (They do affect subdirectories without
304 explicitly assigned switches, however.)
306 You can make Dired forget about all subdirectory switches and relist
307 all subdirectories with the buffer's default switches using
308 @kbd{M-x dired-reset-subdir-switches}. This also reverts the Dired buffer.
311 @c Moved here from the Emacs Lisp Reference Manual, 2005-03-26.
312 @node Advanced Calendar/Diary Usage
313 @chapter Customizing the Calendar and Diary
315 There are many customizations that you can use to make the calendar and
316 diary suit your personal tastes.
319 * Calendar Customizing:: Defaults you can set.
320 * Holiday Customizing:: Defining your own holidays.
321 * Date Display Format:: Changing the format.
322 * Time Display Format:: Changing the format.
323 * Daylight Savings:: Changing the default.
324 * Diary Customizing:: Defaults you can set.
325 * Hebrew/Islamic Entries:: How to obtain them.
326 * Fancy Diary Display:: Enhancing the diary display, sorting entries,
327 using included diary files.
328 * Sexp Diary Entries:: Fancy things you can do.
331 @node Calendar Customizing
332 @section Customizing the Calendar
333 @vindex calendar-holiday-marker
334 @vindex diary-entry-marker
335 The variable @code{calendar-holiday-marker} specifies how to mark a
336 date as being a holiday. Its value may be a single-character string
337 to insert next to the date, or a face name to use for displaying the
338 date. Likewise, the variable @code{diary-entry-marker} specifies how
339 to mark a date that has diary entries. The calendar creates faces
340 named @code{holiday-face} and @code{diary-face} for these purposes;
341 those symbols are the default values of these variables.
343 @vindex calendar-load-hook
344 The variable @code{calendar-load-hook} is a normal hook run when the
345 calendar package is first loaded (before actually starting to display
348 @vindex initial-calendar-window-hook
349 Starting the calendar runs the normal hook
350 @code{initial-calendar-window-hook}. Recomputation of the calendar
351 display does not run this hook. But if you leave the calendar with the
352 @kbd{q} command and reenter it, the hook runs again.@refill
354 @vindex today-visible-calendar-hook
355 The variable @code{today-visible-calendar-hook} is a normal hook run
356 after the calendar buffer has been prepared with the calendar when the
357 current date is visible in the window. One use of this hook is to
358 replace today's date with asterisks; to do that, use the hook function
359 @code{calendar-star-date}.
361 @findex calendar-star-date
363 (add-hook 'today-visible-calendar-hook 'calendar-star-date)
367 Another standard hook function marks the current date, either by
368 changing its face or by adding an asterisk. Here's how to use it:
370 @findex calendar-mark-today
372 (add-hook 'today-visible-calendar-hook 'calendar-mark-today)
376 @vindex calendar-today-marker
377 The variable @code{calendar-today-marker} specifies how to mark
378 today's date. Its value should be a single-character string to insert
379 next to the date or a face name to use for displaying the date. A
380 face named @code{calendar-today-face} is provided for this purpose;
381 that symbol is the default for this variable.
383 @vindex today-invisible-calendar-hook
385 A similar normal hook, @code{today-invisible-calendar-hook} is run if
386 the current date is @emph{not} visible in the window.
388 @vindex calendar-move-hook
389 Each of the calendar cursor motion commands runs the hook
390 @code{calendar-move-hook} after it moves the cursor.
392 @node Holiday Customizing
393 @section Customizing the Holidays
395 @vindex calendar-holidays
396 @vindex christian-holidays
397 @vindex hebrew-holidays
398 @vindex islamic-holidays
399 Emacs knows about holidays defined by entries on one of several lists.
400 You can customize these lists of holidays to your own needs, adding or
401 deleting holidays. The lists of holidays that Emacs uses are for
402 general holidays (@code{general-holidays}), local holidays
403 (@code{local-holidays}), Christian holidays (@code{christian-holidays}),
404 Hebrew (Jewish) holidays (@code{hebrew-holidays}), Islamic (Muslim)
405 holidays (@code{islamic-holidays}), and other holidays
406 (@code{other-holidays}).
408 @vindex general-holidays
409 The general holidays are, by default, holidays common throughout the
410 United States. To eliminate these holidays, set @code{general-holidays}
413 @vindex local-holidays
414 There are no default local holidays (but sites may supply some). You
415 can set the variable @code{local-holidays} to any list of holidays, as
418 @vindex all-christian-calendar-holidays
419 @vindex all-hebrew-calendar-holidays
420 @vindex all-islamic-calendar-holidays
421 By default, Emacs does not include all the holidays of the religions
422 that it knows, only those commonly found in secular calendars. For a
423 more extensive collection of religious holidays, you can set any (or
424 all) of the variables @code{all-christian-calendar-holidays},
425 @code{all-hebrew-calendar-holidays}, or
426 @code{all-islamic-calendar-holidays} to @code{t}. If you want to
427 eliminate the religious holidays, set any or all of the corresponding
428 variables @code{christian-holidays}, @code{hebrew-holidays}, and
429 @code{islamic-holidays} to @code{nil}.@refill
431 @vindex other-holidays
432 You can set the variable @code{other-holidays} to any list of
433 holidays. This list, normally empty, is intended for individual use.
435 @cindex holiday forms
436 Each of the lists (@code{general-holidays}, @code{local-holidays},
437 @code{christian-holidays}, @code{hebrew-holidays},
438 @code{islamic-holidays}, and @code{other-holidays}) is a list of
439 @dfn{holiday forms}, each holiday form describing a holiday (or
440 sometimes a list of holidays).
442 Here is a table of the possible kinds of holiday form. Day numbers
443 and month numbers count starting from 1, but ``dayname'' numbers
444 count Sunday as 0. The element @var{string} is always the
445 name of the holiday, as a string.
448 @item (holiday-fixed @var{month} @var{day} @var{string})
449 A fixed date on the Gregorian calendar.
451 @item (holiday-float @var{month} @var{dayname} @var{k} @var{string})
452 The @var{k}th @var{dayname} in @var{month} on the Gregorian calendar
453 (@var{dayname}=0 for Sunday, and so on); negative @var{k} means count back
454 from the end of the month.
456 @item (holiday-hebrew @var{month} @var{day} @var{string})
457 A fixed date on the Hebrew calendar.
459 @item (holiday-islamic @var{month} @var{day} @var{string})
460 A fixed date on the Islamic calendar.
462 @item (holiday-julian @var{month} @var{day} @var{string})
463 A fixed date on the Julian calendar.
465 @item (holiday-sexp @var{sexp} @var{string})
466 A date calculated by the Lisp expression @var{sexp}. The expression
467 should use the variable @code{year} to compute and return the date of a
468 holiday, or @code{nil} if the holiday doesn't happen this year. The
469 value of @var{sexp} must represent the date as a list of the form
470 @code{(@var{month} @var{day} @var{year})}.
472 @item (if @var{condition} @var{holiday-form})
473 A holiday that happens only if @var{condition} is true.
475 @item (@var{function} @r{[}@var{args}@r{]})
476 A list of dates calculated by the function @var{function}, called with
477 arguments @var{args}.
480 For example, suppose you want to add Bastille Day, celebrated in
481 France on July 14. You can do this as follows:
484 (setq other-holidays '((holiday-fixed 7 14 "Bastille Day")))
488 The holiday form @code{(holiday-fixed 7 14 "Bastille Day")} specifies the
489 fourteenth day of the seventh month (July).
491 Many holidays occur on a specific day of the week, at a specific time
492 of month. Here is a holiday form describing Hurricane Supplication Day,
493 celebrated in the Virgin Islands on the fourth Monday in August:
496 (holiday-float 8 1 4 "Hurricane Supplication Day")
500 Here the 8 specifies August, the 1 specifies Monday (Sunday is 0,
501 Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in
502 the month (1 specifies the first occurrence, 2 the second occurrence,
503 @minus{}1 the last occurrence, @minus{}2 the second-to-last occurrence, and
506 You can specify holidays that occur on fixed days of the Hebrew,
507 Islamic, and Julian calendars too. For example,
511 '((holiday-hebrew 10 2 "Last day of Hanukkah")
512 (holiday-islamic 3 12 "Mohammed's Birthday")
513 (holiday-julian 4 2 "Jefferson's Birthday")))
517 adds the last day of Hanukkah (since the Hebrew months are numbered with
518 1 starting from Nisan), the Islamic feast celebrating Mohammed's
519 birthday (since the Islamic months are numbered from 1 starting with
520 Muharram), and Thomas Jefferson's birthday, which is 2 April 1743 on the
523 To include a holiday conditionally, use either Emacs Lisp's @code{if} or the
524 @code{holiday-sexp} form. For example, American presidential elections
525 occur on the first Tuesday after the first Monday in November of years
529 (holiday-sexp '(if (= 0 (% year 4))
530 (calendar-gregorian-from-absolute
531 (1+ (calendar-dayname-on-or-before
532 1 (+ 6 (calendar-absolute-from-gregorian
533 (list 11 1 year)))))))
534 "US Presidential Election")
541 (if (= 0 (% displayed-year 4))
543 (extract-calendar-day
544 (calendar-gregorian-from-absolute
545 (1+ (calendar-dayname-on-or-before
546 1 (+ 6 (calendar-absolute-from-gregorian
547 (list 11 1 displayed-year)))))))
548 "US Presidential Election"))
551 Some holidays just don't fit into any of these forms because special
552 calculations are involved in their determination. In such cases you
553 must write a Lisp function to do the calculation. To include eclipses,
554 for example, add @code{(eclipses)} to @code{other-holidays}
555 and write an Emacs Lisp function @code{eclipses} that returns a
556 (possibly empty) list of the relevant Gregorian dates among the range
557 visible in the calendar window, with descriptive strings, like this:
560 (((6 27 1991) "Lunar Eclipse") ((7 11 1991) "Solar Eclipse") ... )
563 @node Date Display Format
564 @section Date Display Format
565 @vindex calendar-date-display-form
567 You can customize the manner of displaying dates in the diary, in mode
568 lines, and in messages by setting @code{calendar-date-display-form}.
569 This variable holds a list of expressions that can involve the variables
570 @code{month}, @code{day}, and @code{year}, which are all numbers in
571 string form, and @code{monthname} and @code{dayname}, which are both
572 alphabetic strings. In the American style, the default value of this
576 ((if dayname (concat dayname ", ")) monthname " " day ", " year)
580 while in the European style this value is the default:
583 ((if dayname (concat dayname ", ")) day " " monthname " " year)
587 The ISO standard date representation is this:
590 (year "-" month "-" day)
594 This specifies a typical American format:
597 (month "/" day "/" (substring year -2))
600 @node Time Display Format
601 @section Time Display Format
602 @vindex calendar-time-display-form
604 The calendar and diary by default display times of day in the
605 conventional American style with the hours from 1 through 12, minutes,
606 and either @samp{am} or @samp{pm}. If you prefer the European style,
607 also known in the US as military, in which the hours go from 00 to 23,
608 you can alter the variable @code{calendar-time-display-form}. This
609 variable is a list of expressions that can involve the variables
610 @code{12-hours}, @code{24-hours}, and @code{minutes}, which are all
611 numbers in string form, and @code{am-pm} and @code{time-zone}, which are
612 both alphabetic strings. The default value of
613 @code{calendar-time-display-form} is as follows:
616 (12-hours ":" minutes am-pm
617 (if time-zone " (") time-zone (if time-zone ")"))
621 Here is a value that provides European style times:
624 (24-hours ":" minutes
625 (if time-zone " (") time-zone (if time-zone ")"))
628 @node Daylight Savings
629 @section Daylight Savings Time
630 @cindex daylight savings time
632 Emacs understands the difference between standard time and daylight
633 savings time---the times given for sunrise, sunset, solstices,
634 equinoxes, and the phases of the moon take that into account. The rules
635 for daylight savings time vary from place to place and have also varied
636 historically from year to year. To do the job properly, Emacs needs to
637 know which rules to use.
639 Some operating systems keep track of the rules that apply to the place
640 where you are; on these systems, Emacs gets the information it needs
641 from the system automatically. If some or all of this information is
642 missing, Emacs fills in the gaps with the rules currently used in
643 Cambridge, Massachusetts, which is the center of GNU's world.
646 @vindex calendar-daylight-savings-starts
647 @vindex calendar-daylight-savings-ends
648 If the default choice of rules is not appropriate for your location,
649 you can tell Emacs the rules to use by setting the variables
650 @code{calendar-daylight-savings-starts} and
651 @code{calendar-daylight-savings-ends}. Their values should be Lisp
652 expressions that refer to the variable @code{year}, and evaluate to the
653 Gregorian date on which daylight savings time starts or (respectively)
654 ends, in the form of a list @code{(@var{month} @var{day} @var{year})}.
655 The values should be @code{nil} if your area does not use daylight
658 Emacs uses these expressions to determine the start and end dates of
659 daylight savings time as holidays and for correcting times of day in the
660 solar and lunar calculations.
662 The values for Cambridge, Massachusetts are as follows:
666 (calendar-nth-named-day 1 0 4 year)
667 (calendar-nth-named-day -1 0 10 year)
672 i.e., the first 0th day (Sunday) of the fourth month (April) in
673 the year specified by @code{year}, and the last Sunday of the tenth month
674 (October) of that year. If daylight savings time were
675 changed to start on October 1, you would set
676 @code{calendar-daylight-savings-starts} to this:
682 For a more complex example, suppose daylight savings time begins on
683 the first of Nisan on the Hebrew calendar. You should set
684 @code{calendar-daylight-savings-starts} to this value:
687 (calendar-gregorian-from-absolute
688 (calendar-absolute-from-hebrew
689 (list 1 1 (+ year 3760))))
693 because Nisan is the first month in the Hebrew calendar and the Hebrew
694 year differs from the Gregorian year by 3760 at Nisan.
696 If there is no daylight savings time at your location, or if you want
697 all times in standard time, set @code{calendar-daylight-savings-starts}
698 and @code{calendar-daylight-savings-ends} to @code{nil}.
700 @vindex calendar-daylight-time-offset
701 The variable @code{calendar-daylight-time-offset} specifies the
702 difference between daylight savings time and standard time, measured in
703 minutes. The value for Cambridge is 60.
705 @vindex calendar-daylight-savings-starts-time
706 @vindex calendar-daylight-savings-ends-time
707 The variable @code{calendar-daylight-savings-starts-time} and the
708 variable @code{calendar-daylight-savings-ends-time} specify the number
709 of minutes after midnight local time when the transition to and from
710 daylight savings time should occur. For Cambridge, both variables'
713 @node Diary Customizing
714 @section Customizing the Diary
716 @vindex holidays-in-diary-buffer
717 Ordinarily, the mode line of the diary buffer window indicates any
718 holidays that fall on the date of the diary entries. The process of
719 checking for holidays can take several seconds, so including holiday
720 information delays the display of the diary buffer noticeably. If you'd
721 prefer to have a faster display of the diary buffer but without the
722 holiday information, set the variable @code{holidays-in-diary-buffer} to
725 @vindex number-of-diary-entries
726 The variable @code{number-of-diary-entries} controls the number of
727 days of diary entries to be displayed at one time. It affects the
728 initial display when @code{view-diary-entries-initially} is @code{t}, as
729 well as the command @kbd{M-x diary}. For example, the default value is
730 1, which says to display only the current day's diary entries. If the
731 value is 2, both the current day's and the next day's entries are
732 displayed. The value can also be a vector of seven elements: for
733 example, if the value is @code{[0 2 2 2 2 4 1]} then no diary entries
734 appear on Sunday, the current date's and the next day's diary entries
735 appear Monday through Thursday, Friday through Monday's entries appear
736 on Friday, while on Saturday only that day's entries appear.
738 @vindex print-diary-entries-hook
739 @findex print-diary-entries
740 The variable @code{print-diary-entries-hook} is a normal hook run
741 after preparation of a temporary buffer containing just the diary
742 entries currently visible in the diary buffer. (The other, irrelevant
743 diary entries are really absent from the temporary buffer; in the diary
744 buffer, they are merely hidden.) The default value of this hook does
745 the printing with the command @code{lpr-buffer}. If you want to use a
746 different command to do the printing, just change the value of this
747 hook. Other uses might include, for example, rearranging the lines into
748 order by day and time.
750 @vindex diary-date-forms
751 You can customize the form of dates in your diary file, if neither the
752 standard American nor European styles suits your needs, by setting the
753 variable @code{diary-date-forms}. This variable is a list of patterns
754 for recognizing a date. Each date pattern is a list whose elements may
755 be regular expressions (@pxref{Regular Expressions,,, elisp, the Emacs
756 Lisp Reference Manual}) or the symbols @code{month}, @code{day},
757 @code{year}, @code{monthname}, and @code{dayname}. All these elements
758 serve as patterns that match certain kinds of text in the diary file.
759 In order for the date pattern, as a whole, to match, all of its elements
760 must match consecutively.
762 A regular expression in a date pattern matches in its usual fashion,
763 using the standard syntax table altered so that @samp{*} is a word
766 The symbols @code{month}, @code{day}, @code{year}, @code{monthname},
767 and @code{dayname} match the month number, day number, year number,
768 month name, and day name of the date being considered. The symbols that
769 match numbers allow leading zeros; those that match names allow
770 three-letter abbreviations and capitalization. All the symbols can
771 match @samp{*}; since @samp{*} in a diary entry means ``any day'', ``any
772 month'', and so on, it should match regardless of the date being
775 The default value of @code{diary-date-forms} in the American style is
779 ((month "/" day "[^/0-9]")
780 (month "/" day "/" year "[^0-9]")
781 (monthname " *" day "[^,0-9]")
782 (monthname " *" day ", *" year "[^0-9]")
786 The date patterns in the list must be @emph{mutually exclusive} and
787 must not match any portion of the diary entry itself, just the date and
788 one character of whitespace. If, to be mutually exclusive, the pattern
789 must match a portion of the diary entry text---beyond the whitespace
790 that ends the date---then the first element of the date pattern
791 @emph{must} be @code{backup}. This causes the date recognizer to back
792 up to the beginning of the current word of the diary entry, after
793 finishing the match. Even if you use @code{backup}, the date pattern
794 must absolutely not match more than a portion of the first word of the
795 diary entry. The default value of @code{diary-date-forms} in the
796 European style is this list:
799 ((day "/" month "[^/0-9]")
800 (day "/" month "/" year "[^0-9]")
801 (backup day " *" monthname "\\W+\\<[^*0-9]")
802 (day " *" monthname " *" year "[^0-9]")
807 Notice the use of @code{backup} in the third pattern, because it needs
808 to match part of a word beyond the date itself to distinguish it from
811 @node Hebrew/Islamic Entries
812 @section Hebrew- and Islamic-Date Diary Entries
814 Your diary file can have entries based on Hebrew or Islamic dates, as
815 well as entries based on the world-standard Gregorian calendar.
816 However, because recognition of such entries is time-consuming and most
817 people don't use them, you must explicitly enable their use. If you
818 want the diary to recognize Hebrew-date diary entries, for example,
821 @vindex nongregorian-diary-listing-hook
822 @vindex nongregorian-diary-marking-hook
823 @findex list-hebrew-diary-entries
824 @findex mark-hebrew-diary-entries
826 (add-hook 'nongregorian-diary-listing-hook 'list-hebrew-diary-entries)
827 (add-hook 'nongregorian-diary-marking-hook 'mark-hebrew-diary-entries)
831 If you want Islamic-date entries, do this:
833 @findex list-islamic-diary-entries
834 @findex mark-islamic-diary-entries
836 (add-hook 'nongregorian-diary-listing-hook 'list-islamic-diary-entries)
837 (add-hook 'nongregorian-diary-marking-hook 'mark-islamic-diary-entries)
840 Hebrew- and Islamic-date diary entries have the same formats as
841 Gregorian-date diary entries, except that @samp{H} precedes a Hebrew
842 date and @samp{I} precedes an Islamic date. Moreover, because the
843 Hebrew and Islamic month names are not uniquely specified by the first
844 three letters, you may not abbreviate them. For example, a diary entry
845 for the Hebrew date Heshvan 25 could look like this:
848 HHeshvan 25 Happy Hebrew birthday!
852 and would appear in the diary for any date that corresponds to Heshvan 25
853 on the Hebrew calendar. And here is an Islamic-date diary entry that matches
857 IDhu al-Qada 25 Happy Islamic birthday!
860 As with Gregorian-date diary entries, Hebrew- and Islamic-date entries
861 are nonmarking if they are preceded with an ampersand (@samp{&}).
863 Here is a table of commands used in the calendar to create diary entries
864 that match the selected date and other dates that are similar in the Hebrew
869 Add a diary entry for the Hebrew date corresponding to the selected date
870 (@code{insert-hebrew-diary-entry}).
872 Add a diary entry for the day of the Hebrew month corresponding to the
873 selected date (@code{insert-monthly-hebrew-diary-entry}). This diary
874 entry matches any date that has the same Hebrew day-within-month as the
877 Add a diary entry for the day of the Hebrew year corresponding to the
878 selected date (@code{insert-yearly-hebrew-diary-entry}). This diary
879 entry matches any date which has the same Hebrew month and day-within-month
880 as the selected date.
882 Add a diary entry for the Islamic date corresponding to the selected date
883 (@code{insert-islamic-diary-entry}).
885 Add a diary entry for the day of the Islamic month corresponding to the
886 selected date (@code{insert-monthly-islamic-diary-entry}).
888 Add a diary entry for the day of the Islamic year corresponding to the
889 selected date (@code{insert-yearly-islamic-diary-entry}).
892 @findex insert-hebrew-diary-entry
893 @findex insert-monthly-hebrew-diary-entry
894 @findex insert-yearly-hebrew-diary-entry
895 @findex insert-islamic-diary-entry
896 @findex insert-monthly-islamic-diary-entry
897 @findex insert-yearly-islamic-diary-entry
898 These commands work much like the corresponding commands for ordinary
899 diary entries: they apply to the date that point is on in the calendar
900 window, and what they do is insert just the date portion of a diary entry
901 at the end of your diary file. You must then insert the rest of the
904 @node Fancy Diary Display
905 @section Fancy Diary Display
906 @vindex diary-display-hook
907 @findex simple-diary-display
909 Diary display works by preparing the diary buffer and then running the
910 hook @code{diary-display-hook}. The default value of this hook
911 (@code{simple-diary-display}) hides the irrelevant diary entries and
912 then displays the buffer. However, if you specify the hook as follows,
915 @findex fancy-diary-display
917 (add-hook 'diary-display-hook 'fancy-diary-display)
921 this enables fancy diary display. It displays diary entries and
922 holidays by copying them into a special buffer that exists only for the
923 sake of display. Copying to a separate buffer provides an opportunity
924 to change the displayed text to make it prettier---for example, to sort
925 the entries by the dates they apply to.
927 As with simple diary display, you can print a hard copy of the buffer
928 with @code{print-diary-entries}. To print a hard copy of a day-by-day
929 diary for a week, position point on Sunday of that week, type
930 @kbd{7 d}, and then do @kbd{M-x print-diary-entries}. As usual, the
931 inclusion of the holidays slows down the display slightly; you can speed
932 things up by setting the variable @code{holidays-in-diary-buffer} to
935 @vindex diary-list-include-blanks
936 Ordinarily, the fancy diary buffer does not show days for which there are
937 no diary entries, even if that day is a holiday. If you want such days to be
938 shown in the fancy diary buffer, set the variable
939 @code{diary-list-include-blanks} to @code{t}.@refill
941 @cindex sorting diary entries
942 If you use the fancy diary display, you can use the normal hook
943 @code{list-diary-entries-hook} to sort each day's diary entries by their
944 time of day. Here's how:
946 @findex sort-diary-entries
948 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
952 For each day, this sorts diary entries that begin with a recognizable
953 time of day according to their times. Diary entries without times come
954 first within each day.
956 Fancy diary display also has the ability to process included diary
957 files. This permits a group of people to share a diary file for events
958 that apply to all of them. Lines in the diary file of this form:
961 #include "@var{filename}"
965 includes the diary entries from the file @var{filename} in the fancy
966 diary buffer. The include mechanism is recursive, so that included files
967 can include other files, and so on; you must be careful not to have a
968 cycle of inclusions, of course. Here is how to enable the include
971 @vindex list-diary-entries-hook
972 @vindex mark-diary-entries-hook
973 @findex include-other-diary-files
974 @findex mark-included-diary-files
976 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
977 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
980 The include mechanism works only with the fancy diary display, because
981 ordinary diary display shows the entries directly from your diary file.
983 @node Sexp Diary Entries
984 @section Sexp Entries and the Fancy Diary Display
985 @cindex sexp diary entries
987 Sexp diary entries allow you to do more than just have complicated
988 conditions under which a diary entry applies. If you use the fancy
989 diary display, sexp entries can generate the text of the entry depending
990 on the date itself. For example, an anniversary diary entry can insert
991 the number of years since the anniversary date into the text of the
992 diary entry. Thus the @samp{%d} in this dairy entry:
994 @findex diary-anniversary
996 %%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old)
1000 gets replaced by the age, so on October 31, 1990 the entry appears in
1001 the fancy diary buffer like this:
1004 Arthur's birthday (42 years old)
1008 If the diary file instead contains this entry:
1011 %%(diary-anniversary 10 31 1948) Arthur's %d%s birthday
1015 the entry in the fancy diary buffer for October 31, 1990 appears like this:
1018 Arthur's 42nd birthday
1021 Similarly, cyclic diary entries can interpolate the number of repetitions
1024 @findex diary-cyclic
1026 %%(diary-cyclic 50 1 1 1990) Renew medication (%d%s time)
1033 Renew medication (5th time)
1037 in the fancy diary display on September 8, 1990.
1039 There is an early reminder diary sexp that includes its entry in the
1040 diary not only on the date of occurrence, but also on earlier dates.
1041 For example, if you want a reminder a week before your anniversary, you
1044 @findex diary-remind
1046 %%(diary-remind '(diary-anniversary 12 22 1968) 7) Ed's anniversary
1050 and the fancy diary will show
1055 both on December 15 and on December 22.
1058 The function @code{diary-date} applies to dates described by a month,
1059 day, year combination, each of which can be an integer, a list of
1060 integers, or @code{t}. The value @code{t} means all values. For
1064 %%(diary-date '(10 11 12) 22 t) Rake leaves
1068 causes the fancy diary to show
1075 on October 22, November 22, and December 22 of every year.
1078 The function @code{diary-float} allows you to describe diary entries
1079 that apply to dates like the third Friday of November, or the last
1080 Tuesday in April. The parameters are the @var{month}, @var{dayname},
1081 and an index @var{n}. The entry appears on the @var{n}th @var{dayname}
1082 of @var{month}, where @var{dayname}=0 means Sunday, 1 means Monday, and
1083 so on. If @var{n} is negative it counts backward from the end of
1084 @var{month}. The value of @var{month} can be a list of months, a single
1085 month, or @code{t} to specify all months. You can also use an optional
1086 parameter @var{day} to specify the @var{n}th @var{dayname} of
1087 @var{month} on or after/before @var{day}; the value of @var{day} defaults
1088 to 1 if @var{n} is positive and to the last day of @var{month} if
1089 @var{n} is negative. For example,
1092 %%(diary-float t 1 -1) Pay rent
1096 causes the fancy diary to show
1103 on the last Monday of every month.
1105 The generality of sexp diary entries lets you specify any diary
1106 entry that you can describe algorithmically. A sexp diary entry
1107 contains an expression that computes whether the entry applies to any
1108 given date. If its value is non-@code{nil}, the entry applies to that
1109 date; otherwise, it does not. The expression can use the variable
1110 @code{date} to find the date being considered; its value is a list
1111 (@var{month} @var{day} @var{year}) that refers to the Gregorian
1114 The sexp diary entry applies to a date when the expression's value
1115 is non-@code{nil}, but some values have more specific meanings. If
1116 the value is a string, that string is a description of the event which
1117 occurs on that date. The value can also have the form
1118 @code{(@var{mark} . @var{string})}; then @var{mark} specifies how to
1119 mark the date in the calendar, and @var{string} is the description of
1120 the event. If @var{mark} is a single-character string, that character
1121 appears next to the date in the calendar. If @var{mark} is a face
1122 name, the date is displayed in that face. If @var{mark} is
1123 @code{nil}, that specifies no particular highlighting for the date.
1125 Suppose you get paid on the 21st of the month if it is a weekday, and
1126 on the Friday before if the 21st is on a weekend. Here is how to write
1127 a sexp diary entry that matches those dates:
1130 &%%(let ((dayname (calendar-day-of-week date))
1131 (day (car (cdr date))))
1132 (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
1133 (and (memq day '(19 20)) (= dayname 5)))
1134 ) Pay check deposited
1137 The following sexp diary entries take advantage of the ability (in the fancy
1138 diary display) to concoct diary entries whose text varies based on the date:
1140 @findex diary-sunrise-sunset
1141 @findex diary-phases-of-moon
1142 @findex diary-day-of-year
1143 @findex diary-iso-date
1144 @findex diary-julian-date
1145 @findex diary-astro-day-number
1146 @findex diary-hebrew-date
1147 @findex diary-islamic-date
1148 @findex diary-french-date
1149 @findex diary-mayan-date
1151 @item %%(diary-sunrise-sunset)
1152 Make a diary entry for the local times of today's sunrise and sunset.
1153 @item %%(diary-phases-of-moon)
1154 Make a diary entry for the phases (quarters) of the moon.
1155 @item %%(diary-day-of-year)
1156 Make a diary entry with today's day number in the current year and the number
1157 of days remaining in the current year.
1158 @item %%(diary-iso-date)
1159 Make a diary entry with today's equivalent ISO commercial date.
1160 @item %%(diary-julian-date)
1161 Make a diary entry with today's equivalent date on the Julian calendar.
1162 @item %%(diary-astro-day-number)
1163 Make a diary entry with today's equivalent astronomical (Julian) day number.
1164 @item %%(diary-hebrew-date)
1165 Make a diary entry with today's equivalent date on the Hebrew calendar.
1166 @item %%(diary-islamic-date)
1167 Make a diary entry with today's equivalent date on the Islamic calendar.
1168 @item %%(diary-french-date)
1169 Make a diary entry with today's equivalent date on the French Revolutionary
1171 @item %%(diary-mayan-date)
1172 Make a diary entry with today's equivalent date on the Mayan calendar.
1176 Thus including the diary entry
1179 &%%(diary-hebrew-date)
1183 causes every day's diary display to contain the equivalent date on the
1184 Hebrew calendar, if you are using the fancy diary display. (With simple
1185 diary display, the line @samp{&%%(diary-hebrew-date)} appears in the
1186 diary for any date, but does nothing particularly useful.)
1188 These functions can be used to construct sexp diary entries based on
1189 the Hebrew calendar in certain standard ways:
1192 @findex diary-rosh-hodesh
1193 @cindex parasha, weekly
1194 @findex diary-parasha
1195 @cindex candle lighting times
1196 @findex diary-sabbath-candles
1200 @findex diary-yahrzeit
1202 @item %%(diary-rosh-hodesh)
1203 Make a diary entry that tells the occurrence and ritual announcement of each
1205 @item %%(diary-parasha)
1206 Make a Saturday diary entry that tells the weekly synagogue scripture reading.
1207 @item %%(diary-sabbath-candles)
1208 Make a Friday diary entry that tells the @emph{local time} of Sabbath
1210 @item %%(diary-omer)
1211 Make a diary entry that gives the omer count, when appropriate.
1212 @item %%(diary-yahrzeit @var{month} @var{day} @var{year}) @var{name}
1213 Make a diary entry marking the anniversary of a date of death. The date
1214 is the @emph{Gregorian} (civil) date of death. The diary entry appears
1215 on the proper Hebrew calendar anniversary and on the day before. (In
1216 the European style, the order of the parameters is changed to @var{day},
1217 @var{month}, @var{year}.)
1220 All the functions documented above take an optional argument
1221 @var{mark} which specifies how to mark the date in the calendar display.
1222 If one of these functions decides that it applies to a certain date,
1223 it returns a value that contains @var{mark}.
1234 arch-tag: 75c33f13-32c6-41b6-9537-847a312e2e49