Let's move to a topic everyone is interested in: holidays. To display the holidays for the part of the calendar you are looking at, type a(for list-calendar-holidays) or select 3 Monthsfrom the Holidaysmenu.
Type: a

Emacs lists holidays for the time period shown.
As you can see, Emacs knows about a fairly wide variety of holidays or, as it calls them, "notable dates." If you are somewhere else on the calendar but want to see holidays surrounding the current month, type M-x holidays. Emacs lists them. To see whether today is a holiday, type hor select One Dayfrom the Holidaysmenu.
Typing xmarks holidays in a special way, typically highlighting them in pink. If the display doesn't support this, Emacs puts an asterisk to the right of the date. Typing uremoves the marks.
We have taught you only the bare bones of the calendar commands. Emacs offers to tell you sunrise and sunset and phases of the moon. You can choose other calendars, like the Islamic calendar, the Hebrew calendar, the Mayan calendar, or even the French Revolutionary calendar. But we will leave these for you to explore.
More calendar commands are used in the context of the diary, discussed next.
The diary, closely related to the calendar, allows you to make notes about certain dates. You can enter a full daily schedule or just mark major events. The level of detail is entirely up to you.
5.5.2.1 Creating a diary file
To use the diary, you must have a diary file that contains notations about important events or things to do. It can remind you to back up your system every Thursday, that you get paid every two weeks, that you're on vacation during the first two weeks in July, or that your mother's birthday is August 6.
The file must be called diary and must exist in your home directory. In this file, you insert lines—or have Emacs write lines for you—that note dates you want to remember. The diary file need not be all in one format and need not be sorted in any particular order. Date formats can be mixed: December 19, 2004 could be 12/19/04, Dec 19 04, or dec 19 2004. Here are a few lines from a diary file to illustrate what we mean.
11/14 My birthday
July 17 2004 Company picnic
March 18 2004 Annual report due
January 8 2004 Hair appointment
&Saturday Tea with Queen Elizabeth
Friday Payday
If you don't specify a year, Emacs assumes you want to mark that date every year, as in birthdays. If you don't specify a date but only the day of the week (as in tea with the queen on Saturday), Emacs displays the diary entry every Saturday. Putting an ampersand (&) before an entry tells Emacs not to mark it on the calendar (you don't want every Saturday marked, and you may not want everyone to know that you hang around with the royal family).
Date formats can be mixed, but the choice to use European date format (DD/MM/YYYY or 9 October 2004) versus the default American format (MM/DD/YYYY or October 9, 2004) must be made before you create the diary file. To specify European date format, add this line to your .emacs file:
(setq european-calendar-style 't)
5.5.2.2 Adding diary entries
You can write your own entries or have Emacs help you put them in. To have Emacs help you, go to the calendar by typing M-x calendar. Then press g dto specify the date you want to move to. Press i d(for insert-diary-entry). Emacs moves you to the diary window with the date written out. You can then make a diary entry next to the date. If your entry spans more than one line, begin the second and subsequent lines with a single space, so that Emacs understands it's a continuation. After you make the notation about the date, Emacs leaves you in the diary
buffer so you can make more entries. Type C-x bto move to another buffer.
The insert-diary-entrycommand assumes you want to make a single, one-time entry. To create a recurring entry, you need a few more commands. To insert a weekly entry, type i w. Emacs moves you to the diary
buffer with the day of the week written out. Type the weekly activity (such as a staff meeting), and save the diary file. To insert an annual entry, type i y. Emacs moves you to the diary
buffer with the day and month written out; type the annual event. There is a more specific command for anniversaries. Type i ato add an anniversary; this entry includes the year (though we have not seen a function that uses this information for any particular purpose, such as counting which anniversary this is).
You can also put in cyclic diary entries, entries that occur at regular intervals, like reminders to change the oil in your car every three months. To do so, move to the date you changed your oil last and type i c. Emacs says, Repeat every how many days:
and you type the number of days between oil changes. Emacs writes a Lisp function to handle this and puts it in the diary buffer. You can then make a notation next to the Lisp function, such as a note that tells you to change the oil. The entry that Emacs inserts looks like this (we put the part about changing the oil in ourselves):
%%(diary-cyclic 90 12 23 2004) Change the oil
The entry says that every 90 days, counting from the day we inserted the entry, December 23, 2004, we should change the oil in our car.
You can mark a block of dates, as in the case of a week-long conference or a vacation. Put the cursor on the first date and press C-Spaceto set the mark. [31]Move (using calendar movement commands like C-f, C-n, and so on) to the second date and press i b. Emacs moves you to the diary
buffer and inserts an incantation that marks the week on your calendar. Make a notation following the Lisp function Emacs inserts. The entry will look something like this:
%%(diary-block 3 15 2004 3 20 2004) Trip to Alabama
This entry indicates that from March 15 to March 20, we'll go on a trip to Alabama.
What if you want to note that you have to file your expense report on the fifteenth of every month? Emacs accepts the asterisk wildcard (*) for the month, as you will see when you type i m(for insert-monthly-diary-entry). Emacs inserts an asterisk in place of the month, followed by the day, as in * 15for something scheduled for the fifteenth of each month. As always, you make a note following the entry.
Now that you see how Emacs constructs diary entries, you can try writing some of your own based on what Emacs has done. After all, the diary file is like any other Emacs file; you can make changes, add lines, and delete lines at will. The only requirement is that you save the file when you're through. Now let's see how to display diary entries on the appropriate dates.
5.5.2.3 Displaying diary entries
If you want to review the diary entries for a given date, press dfrom the calendar. In order to see the whole diary file, press sfrom the calendar. If you want today's diary entries to display automatically when you start Emacs, add this line to your .emacs file:
Читать дальше