Книга: Learning GNU Emacs, 3rd Edition
5.5.2.2 Adding diary entries
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 d to 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 b to move to another buffer.
The insert-diary-entry command 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 a to 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-Space to 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 * 15 for 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 Using the Diary
- The conntrack entries
- 6.1 Adding on to Eclipse
- Adding New Users
- Adding Some Error Checking
- 1.17 Adding Binary Numbers
- Connecting the Virtual Subsidiary Network
- Adding hard drives
- Viewing disk quota entries
- Creating disk quota entries
- Deleting disk quota entries
- Adding and removing servers to manage