Post

31 Using Time Management Tools

31 Using Time Management Tools

Displaying the Calendar

M-x calendar

By default, weeks start on Sunday. If you’d like them to start on Monday instead, type M-x set-variable calendar-week-start Enter 1 Enter. You enter the calendar again to have this take effect. If you’d like to have the calendar always start on Monday, add this line to your .emacs file:

1
(setq calendar-week-start-day 1)

If you’d like to see the calendar each time you start Emacs, you can add this line to your .emacs file:

(calendar)

Calendar movement commands

KeystrokesCommand nameAction
(none) Tools Display CalendarcalendarDisplay the calendar.
.Goto Todaycalendar-goto-todayMove to today’s date.
C-fcalendar-forward-dayMove forward a day.
C-bcalendar-backward-dayMove backward a day.
C-ncalendar-forward-weekMove forward a week.
C-pcalendar-backward-weekMove backward a week.
M-}calendar-forward-monthMove forward one month.
M-{calendar-backward-monthMove backward a month.
C-x ] Scroll Forward 1 Yearcalendar-forward-yearMove forward a year.
C-x [ Scroll Backward 1 Yearcalendar-backward-yearMove backward a year.
C-a Goto Beginning of Weekcalendar-beginning-of-weekMove to the beginning of the week.
C-e Goto End of Weekcalendar-end-of-weekMove to the end of the week.
M-a Goto Beginning of Monthcalendar-beginning-of-monthMove to the beginning of the month.
M-e Goto End of Monthcalendar-end-of-monthMove to the end of the month.
M-< Goto Beginning of Yearcalendar-beginning-of-yearMove to the beginning of the year.
M-> Goto End of Yearcalendar-end-of-yearMove to the end of the year.
g d Goto Other Datecalendar-goto-dateGo to the specified date.
ocalendar-other-monthPut the specified month in the middle of the display.
C-x < Scroll Forward 1 Monthscroll-calendar-leftScroll forward one month.
C-x > Scroll Backward 1 Monthscroll-calendar-rightScroll backward one month.
C-v Scroll Forward 3 Monthsscroll-calendar-left-three-monthsScroll forward three months.
M-v Scroll Forward 3 Monthsscroll-calendar-right-three-monthsScroll backward three months.
Spacescroll-other-windowScroll another window.

Displaying holidays

To display the holidays for the part of the calendar you are looking at, type a (for list-calendar-holidays) or select 3 Months from the Holidays menu.

want to see holidays surrounding the current month, type M-x holidays.

To see whether today is a holiday, type h or select One Day from the Holidays menu.

Typing x marks holidays in a special way; Typing u removes 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.

Using the Diary

Creating a diary file

The file must be called diary and must exist in your home directory.The file must be called diary.

Here are a few lines from a diary file:

1
2
3
4
5
6
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).

To specify European date format, add this line to your .emacs file:

(setq european-calendar-style 't)

Adding diary entries

If you want today’s diary entries to display automatically when you start Emacs, add this line to your .emacs file:

(diary)

To mark dates with diary entries in red, press m from the calendar. To remove the marks, press u. (This command removes highlighting for diary entries as well as for holidays.)

Table 5-5. Holiday and diary commands

KeystrokesCommand nameAction
p dcalendar-print-day-of-yearDisplay the day of the year this is (for example, Day 364 of 365).
p ocalendar-print-other-datesDisplay information about this date for all calendars.
Spacescroll-other-windowScroll the other window.
qexit-calendarQuit calendar.
a Holidays For Windowlist-calendar-holidaysDisplay holidays for calendar period shown.
h Holidays For Cursor Datecalendar-cursor-holidaysIn the minibuffer, display holiday information for the day the cursor is on.
x Holidays Markmark-calendar-holidaysDisplay holidays in a different typeface, color, or with an asterisk beside them.
u Holidays Unmark Calendarcalendar-unmarkRemove marks for holidays and diary entries (opposite ofx command).
i w Diary Insert Weeklyinsert-weekly-diary-entryAdd a weekly entry based on the day of the week.
i y Diary Insert Yearlyinsert-yearly-diary-entryAdd an annual entry.
i d Diary Insert Dailyinsert-diary-entryAdd an entry for a particular day.
i m Diary Insert Monthlyinsert-monthly-diary-entryAdd an entry for the day of the month.
i c Diary Insert Cyclicinsert-cyclic-diary-entryAdd an entry to recur everyn days.
i a Diary Insert Anniversaryinsert-anniversary-diary-entryAdd an annual entry (the year is included for reference).
i b Diary Insert Blockinsert-block-diary-entryAdd a block entry.
mmark-diary-entriesDisplay diary entries in a different typeface, color, or with a plus sign beside them.
dview-diary-entriesDisplay diary entries for the current date.
s Diary Show Allshow-all-diary-entriesDisplaydiary file.
M-=calendar-count-days-regionCount the number of days in a region.
M Moon Lunar Phasescalendar-phases-of-moonDisplay phases of the moon for a three-month period.
Scalendar-sunrise-sunsetGiven longitude and latitude, display sunrise and sunset times for the current date.
C-Space or C-@calendar-set-markMark regions by time rather than horizontally.
This post is licensed under CC BY 4.0 by the author.