Next: Appt Customizing, Previous: Included Diary Files, Up: Calendar Customization [Contents][Index]
Sexp diary entries allow you to do more than just have complicated conditions under which a diary entry applies. If you use the fancy diary display, sexp entries can generate the text of the entry depending on the date itself. For example, an anniversary diary entry can insert the number of years since the anniversary date into the text of the diary entry. Thus the ‘%d’ in this dairy entry:
%%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old)
gets replaced by the age, so on October 31, 1990 the entry appears in the fancy diary buffer like this:
Arthur's birthday (42 years old)
If the diary file instead contains this entry:
%%(diary-anniversary 10 31 1948) Arthur's %d%s birthday
the entry in the fancy diary buffer for October 31, 1990 appears like this:
Arthur's 42nd birthday
Similarly, cyclic diary entries can interpolate the number of repetitions that have occurred:
%%(diary-cyclic 50 1 1 1990) Renew medication (%d%s time)
looks like this:
Renew medication (5th time)
in the fancy diary display on September 8, 1990.
The generality of sexp diary entries lets you specify any diary entry
that you can describe algorithmically. A sexp diary entry contains an
expression that computes whether the entry applies to any given date.
If its value is non-nil
, the entry applies to that date;
otherwise, it does not. The expression can use the variable date
to find the date being considered; its value is a list (month
day year) that refers to the Gregorian calendar.
Suppose you get paid on the 21st of the month if it is a weekday, and on the Friday before if the 21st is on a weekend. Here is how to write a sexp diary entry that matches those dates:
&%%(let ((dayname (calendar-day-of-week date)) (day (car (cdr date)))) (or (and (= day 21) (memq dayname '(1 2 3 4 5))) (and (memq day '(19 20)) (= dayname 5))) ) Pay check deposited
applies to just those dates. This example illustrates how the sexp can
depend on the variable date
; this variable is a list (month
day year) that gives the Gregorian date for which the diary
entries are being found. If the value of the expression is t
,
the entry applies to that date. If the expression evaluates to
nil
, the entry does not apply to that date.
The following sexp diary entries take advantage of the ability (in the fancy diary display) to concoct diary entries whose text varies based on the date:
%%(diary-sunrise-sunset)
Make a diary entry for the local times of today’s sunrise and sunset.
%%(diary-phases-of-moon)
Make a diary entry for the phases (quarters) of the moon.
%%(diary-day-of-year)
Make a diary entry with today’s day number in the current year and the number of days remaining in the current year.
%%(diary-iso-date)
Make a diary entry with today’s equivalent ISO commercial date.
%%(diary-julian-date)
Make a diary entry with today’s equivalent date on the Julian calendar.
%%(diary-astro-day-number)
Make a diary entry with today’s equivalent astronomical (Julian) day number.
%%(diary-hebrew-date)
Make a diary entry with today’s equivalent date on the Hebrew calendar.
%%(diary-islamic-date)
Make a diary entry with today’s equivalent date on the Islamic calendar.
%%(diary-french-date)
Make a diary entry with today’s equivalent date on the French Revolutionary calendar.
%%(diary-mayan-date)
Make a diary entry with today’s equivalent date on the Mayan calendar.
Thus including the diary entry
&%%(diary-hebrew-date)
causes every day’s diary display to contain the equivalent date on the Hebrew calendar, if you are using the fancy diary display. (With simple diary display, the line ‘&%%(diary-hebrew-date)’ appears in the diary for any date, but does nothing particularly useful.)
These functions can be used to construct sexp diary entries based on the Hebrew calendar in certain standard ways:
%%(diary-rosh-hodesh)
Make a diary entry that tells the occurrence and ritual announcement of each new Hebrew month.
%%(diary-parasha)
Make a Saturday diary entry that tells the weekly synagogue scripture reading.
%%(diary-sabbath-candles)
Make a Friday diary entry that tells the local time of Sabbath candle lighting.
%%(diary-omer)
Make a diary entry that gives the omer count, when appropriate.
%%(diary-yahrzeit month day year) name
Make a diary entry marking the anniversary of a date of death. The date is the Gregorian (civil) date of death. The diary entry appears on the proper Hebrew calendar anniversary and on the day before. (In the European style, the order of the parameters is changed to day, month, year.)
Next: Appt Customizing, Previous: Included Diary Files, Up: Calendar Customization [Contents][Index]