www.delorie.com/gnu/docs/elisp-manual-21/elisp_667.html   search  
 
Buy the book!


GNU Emacs Lisp Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

39.1 Customizing the Calendar

If you set the variable view-diary-entries-initially to t, calling up the calendar automatically displays the diary entries for the current date as well. The diary dates appear only if the current date is visible. If you add both of the following lines to your init file:

 
(setq view-diary-entries-initially t)
(calendar)

this displays both the calendar and diary windows whenever you start Emacs.

Similarly, if you set the variable view-calendar-holidays-initially to t, entering the calendar automatically displays a list of holidays for the current three-month period. The holiday list appears in a separate window.

You can set the variable mark-diary-entries-in-calendar to t in order to mark any dates with diary entries. This takes effect whenever the calendar window contents are recomputed. There are two ways of marking these dates: by changing the face (see section 38.11 Faces), or by placing a plus sign (`+') beside the date.

Similarly, setting the variable mark-holidays-in-calendar to t marks holiday dates, either with a change of face or with an asterisk (`*').

The variable calendar-holiday-marker specifies how to mark a date as being a holiday. Its value may be a character to insert next to the date, or a face name to use for displaying the date. Likewise, the variable diary-entry-marker specifies how to mark a date that has diary entries. The calendar creates faces named holiday-face and diary-face for these purposes; those symbols are the default values of these variables.

The variable calendar-load-hook is a normal hook run when the calendar package is first loaded (before actually starting to display the calendar).

Starting the calendar runs the normal hook initial-calendar-window-hook. Recomputation of the calendar display does not run this hook. But if you leave the calendar with the q command and reenter it, the hook runs again.

The variable today-visible-calendar-hook is a normal hook run after the calendar buffer has been prepared with the calendar when the current date is visible in the window. One use of this hook is to replace today's date with asterisks; to do that, use the hook function calendar-star-date.

 
(add-hook 'today-visible-calendar-hook 'calendar-star-date)

Another standard hook function marks the current date, either by changing its face or by adding an asterisk. Here's how to use it:

 
(add-hook 'today-visible-calendar-hook 'calendar-mark-today)

The variable calendar-today-marker specifies how to mark today's date. Its value should be a character to insert next to the date or a face name to use for displaying the date. A face named calendar-today-face is provided for this purpose; that symbol is the default for this variable.

A similar normal hook, today-invisible-calendar-hook is run if the current date is not visible in the window.

Starting in Emacs 21, each of the calendar cursor motion commands runs the hook calendar-move-hook after it moves the cursor.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003