calendar.texi 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310
  1. @node Calendar/Diary, Sorting, Reading Mail, Top
  2. @section Calendar Mode and the Diary
  3. @cindex calendar
  4. @findex calendar
  5. Emacs provides the functions of a desk calendar, with a diary of
  6. planned or past events. To enter the calendar, type @kbd{M-x calendar};
  7. this displays a three-month calendar centered on the current month, with
  8. point on the current date. With a numeric argument, as in @kbd{C-u M-x
  9. calendar}, it prompts you for the month and year to be the center of the
  10. three-month calendar. The calendar uses its own buffer, whose major
  11. mode is Calendar mode.
  12. @kbd{Button2} in the calendar brings up a menu of operations on a
  13. particular date; @kbd{Buttons3} brings up a menu of commonly used
  14. calendar features that are independent of any particular date. To exit
  15. the calendar, type @kbd{q}. @xref{Calendar, Customizing the Calendar
  16. and Diary,, lispref, The XEmacs Lisp Reference Manual}, for customization
  17. information about the calendar and diary.
  18. @menu
  19. * Calendar Motion:: Moving through the calendar; selecting a date.
  20. * Scroll Calendar:: Bringing earlier or later months onto the screen.
  21. * Mark and Region:: Remembering dates, the mark ring.
  22. * General Calendar:: Exiting or recomputing the calendar.
  23. * LaTeX Calendar:: Print a calendar using LaTeX.
  24. * Holidays:: Displaying dates of holidays.
  25. * Sunrise/Sunset:: Displaying local times of sunrise and sunset.
  26. * Lunar Phases:: Displaying phases of the moon.
  27. * Other Calendars:: Converting dates to other calendar systems.
  28. * Diary:: Displaying events from your diary.
  29. * Calendar Customization:: Altering the behavior of the features above.
  30. @end menu
  31. @node Calendar Motion, Scroll Calendar, Calendar/Diary, Calendar/Diary
  32. @subsection Movement in the Calendar
  33. @cindex moving inside the calendar
  34. Calendar mode lets you move through the calendar in logical units of
  35. time such as days, weeks, months, and years. If you move outside the
  36. three months originally displayed, the calendar display ``scrolls''
  37. automatically through time to make the selected date visible. Moving to
  38. a date lets you view its holidays or diary entries, or convert it to other
  39. calendars; moving longer time periods is also useful simply to scroll the
  40. calendar.
  41. @menu
  42. * Calendar Unit Motion:: Moving by days, weeks, months, and years.
  43. * Move to Beginning or End:: Moving to start/end of weeks, months, and years.
  44. * Specified Dates:: Moving to the current date or another
  45. specific date.
  46. @end menu
  47. @node Calendar Unit Motion, Move to Beginning or End, Calendar Motion, Calendar Motion
  48. @subsubsection Motion by Integral Days, Weeks, Months, Years
  49. The commands for movement in the calendar buffer parallel the
  50. commands for movement in text. You can move forward and backward by
  51. days, weeks, months, and years.
  52. @table @kbd
  53. @item C-f
  54. Move point one day forward (@code{calendar-forward-day}).
  55. @item C-b
  56. Move point one day backward (@code{calendar-backward-day}).
  57. @item C-n
  58. Move point one week forward (@code{calendar-forward-week}).
  59. @item C-p
  60. Move point one week backward (@code{calendar-backward-week}).
  61. @item M-@}
  62. Move point one month forward (@code{calendar-forward-month}).
  63. @item M-@{
  64. Move point one month backward (@code{calendar-backward-month}).
  65. @item C-x ]
  66. Move point one year forward (@code{calendar-forward-year}).
  67. @item C-x [
  68. Move point one year backward (@code{calendar-backward-year}).
  69. @end table
  70. @kindex C-f @r{(Calendar mode)}
  71. @findex calendar-forward-day
  72. @kindex C-b @r{(Calendar mode)}
  73. @findex calendar-backward-day
  74. @kindex C-n @r{(Calendar mode)}
  75. @findex calendar-forward-week
  76. @kindex C-p @r{(Calendar mode)}
  77. @findex calendar-backward-week
  78. The day and week commands are natural analogues of the usual Emacs
  79. commands for moving by characters and by lines. Just as @kbd{C-n}
  80. usually moves to the same column in the following line, in Calendar
  81. mode it moves to the same day in the following week. And @kbd{C-p}
  82. moves to the same day in the previous week.
  83. The arrow keys are equivalent to @kbd{C-f}, @kbd{C-b}, @kbd{C-n} and
  84. @kbd{C-p}, just as they normally are in other modes.
  85. @kindex M-@} @r{(Calendar mode)}
  86. @findex calendar-forward-month
  87. @kindex M-@{ @r{(Calendar mode)}
  88. @findex calendar-backward-month
  89. @kindex C-x ] @r{(Calendar mode)}
  90. @findex calendar-forward-year
  91. @kindex C-x [ @r{(Calendar mode)}
  92. @findex calendar-forward-year
  93. The commands for motion by months and years work like those for
  94. weeks, but move a larger distance. The month commands @kbd{M-@}} and
  95. @kbd{M-@{} move forward or backward by an entire month's time. The
  96. year commands @kbd{C-x ]} and @w{@kbd{C-x [}} move forward or backward a
  97. whole year.
  98. The easiest way to remember these commands is to consider months and
  99. years analogous to paragraphs and pages of text, respectively. But the
  100. commands themselves are not quite analogous. The ordinary Emacs paragraph
  101. commands move to the beginning or end of a paragraph, whereas these month
  102. and year commands move by an entire month or an entire year, which usually
  103. involves skipping across the end of a month or year.
  104. All these commands accept a numeric argument as a repeat count.
  105. For convenience, the digit keys and the minus sign specify numeric
  106. arguments in Calendar mode even without the Meta modifier. For example,
  107. @kbd{100 C-f} moves point 100 days forward from its present location.
  108. @node Move to Beginning or End, Specified Dates, Calendar Unit Motion, Calendar Motion
  109. @subsubsection Beginning or End of Week, Month or Year
  110. A week (or month, or year) is not just a quantity of days; we think of
  111. weeks (months, years) as starting on particular dates. So Calendar mode
  112. provides commands to move to the beginning or end of a week, month or
  113. year:
  114. @table @kbd
  115. @kindex C-a @r{(Calendar mode)}
  116. @findex calendar-beginning-of-week
  117. @item C-a
  118. Move point to start of week (@code{calendar-beginning-of-week}).
  119. @kindex C-e @r{(Calendar mode)}
  120. @findex calendar-end-of-week
  121. @item C-e
  122. Move point to end of week (@code{calendar-end-of-week}).
  123. @kindex M-a @r{(Calendar mode)}
  124. @findex calendar-beginning-of-month
  125. @item M-a
  126. Move point to start of month (@code{calendar-beginning-of-month}).
  127. @kindex M-e @r{(Calendar mode)}
  128. @findex calendar-end-of-month
  129. @item M-e
  130. Move point to end of month (@code{calendar-end-of-month}).
  131. @kindex M-< @r{(Calendar mode)}
  132. @findex calendar-beginning-of-year
  133. @item M-<
  134. Move point to start of year (@code{calendar-beginning-of-year}).
  135. @kindex M-> @r{(Calendar mode)}
  136. @findex calendar-end-of-year
  137. @item M->
  138. Move point to end of year (@code{calendar-end-of-year}).
  139. @end table
  140. These commands also take numeric arguments as repeat counts, with the
  141. repeat count indicating how many weeks, months, or years to move
  142. backward or forward.
  143. @vindex calendar-week-start-day
  144. @cindex weeks, which day they start on
  145. @cindex calendar, first day of week
  146. By default, weeks begin on Sunday. To make them begin on Monday
  147. instead, set the variable @code{calendar-week-start-day} to 1.
  148. @node Specified Dates,,Move to Beginning or End, Calendar Motion
  149. @subsubsection Particular Dates
  150. Calendar mode provides commands for moving to a particular date
  151. specified in various ways.
  152. @table @kbd
  153. @item g d
  154. Move point to specified date (@code{calendar-goto-date}).
  155. @item o
  156. Center calendar around specified month (@code{calendar-other-month}).
  157. @item .
  158. Move point to today's date (@code{calendar-goto-today}).
  159. @end table
  160. @kindex g d @r{(Calendar mode)}
  161. @findex calendar-goto-date
  162. @kbd{g d} (@code{calendar-goto-date}) prompts for a year, a month, and a day
  163. of the month, and then moves to that date. Because the calendar includes all
  164. dates from the beginning of the current era, you must type the year in its
  165. entirety; that is, type @samp{1990}, not @samp{90}.
  166. @kindex o @r{(Calendar mode)}
  167. @findex calendar-other-month
  168. @kbd{o} (@code{calendar-other-month}) prompts for a month and year,
  169. then centers the three-month calendar around that month.
  170. @kindex . @r{(Calendar mode)}
  171. @findex calendar-goto-today
  172. You can return to today's date with @kbd{.}@:
  173. (@code{calendar-goto-today}).
  174. @node Scroll Calendar, Mark and Region, Calendar Motion, Calendar/Diary
  175. @subsection Scrolling the Calendar through Time
  176. @cindex scrolling in the calendar
  177. The calendar display scrolls automatically through time when you move out
  178. of the visible portion. You can also scroll it manually. Imagine that the
  179. calendar window contains a long strip of paper with the months on it.
  180. Scrolling it means moving the strip so that new months become visible in
  181. the window.
  182. @table @kbd
  183. @item C-x <
  184. Scroll calendar one month forward (@code{scroll-calendar-left}).
  185. @item C-x >
  186. Scroll calendar one month backward (@code{scroll-calendar-right}).
  187. @item C-v
  188. @itemx @key{NEXT}
  189. Scroll calendar three months forward
  190. (@code{scroll-calendar-left-three-months}).
  191. @item M-v
  192. @itemx @key{PRIOR}
  193. Scroll calendar three months backward
  194. (@code{scroll-calendar-right-three-months}).
  195. @end table
  196. @kindex C-x < @r{(Calendar mode)}
  197. @findex scroll-calendar-left
  198. @kindex C-x > @r{(Calendar mode)}
  199. @findex scroll-calendar-right
  200. The most basic calendar scroll commands scroll by one month at a
  201. time. This means that there are two months of overlap between the
  202. display before the command and the display after. @kbd{C-x <} scrolls
  203. the calendar contents one month to the left; that is, it moves the
  204. display forward in time. @kbd{C-x >} scrolls the contents to the
  205. right, which moves backwards in time.
  206. @kindex C-v @r{(Calendar mode)}
  207. @findex scroll-calendar-left-three-months
  208. @kindex M-v @r{(Calendar mode)}
  209. @findex scroll-calendar-right-three-months
  210. The commands @kbd{C-v} and @kbd{M-v} scroll the calendar by an entire
  211. ``screenful''---three months---in analogy with the usual meaning of
  212. these commands. @kbd{C-v} makes later dates visible and @kbd{M-v} makes
  213. earlier dates visible. These commands take a numeric argument as a
  214. repeat count; in particular, since @kbd{C-u} multiplies the next command
  215. by four, typing @kbd{C-u C-v} scrolls the calendar forward by a year and
  216. typing @kbd{C-u M-v} scrolls the calendar backward by a year.
  217. The function keys @key{NEXT} and @key{PRIOR} are equivalent to
  218. @kbd{C-v} and @kbd{M-v}, just as they are in other modes.
  219. @node Mark and Region, General Calendar, Scroll Calendar, Calendar/Diary
  220. @subsection The Mark and the Region
  221. The concept of the mark applies to the calendar just as to any other
  222. buffer, but it marks a @emph{date}, not a @emph{position} in the buffer.
  223. The region consists of the days between the mark and point (including
  224. the starting and stopping dates).
  225. @table @kbd
  226. @item C-SPC
  227. Set the mark to today's date (@code{calendar-set-mark}).
  228. @item C-@@
  229. The same.
  230. @item C-x C-x
  231. Interchange mark and point (@code{calendar-exchange-point-and-mark}).
  232. @item M-=
  233. Display the number of days in the current region
  234. (@code{calendar-count-days-region}).
  235. @end table
  236. @kindex C-@@ @r{(Calendar mode)}
  237. @kindex C-SPC @r{(Calendar mode)}
  238. @findex calendar-set-mark
  239. @kindex C-x C-x @r{(Calendar mode)}
  240. @findex calendar-exchange-point-and-mark
  241. You set the mark in the calendar, as in any other buffer, by using @kbd{C-@@}
  242. or @kbd{C-SPC} (@code{calendar-set-mark}). You return to the marked date
  243. with the command @kbd{C-x C-x} (@code{calendar-exchange-point-and-mark})
  244. which puts the mark where point was and point where mark was. The calendar
  245. is scrolled as necessary, if the marked date was not visible on the
  246. screen. This does not change the extent of the region.
  247. @kindex M-= @r{(Calendar mode)}
  248. @findex calendar-count-days-region
  249. To determine the number of days in the region, type @kbd{M-=}
  250. (@code{calendar-count-days-region}). The numbers of days printed is
  251. @emph{inclusive}; that is, it includes the days specified by mark and
  252. point.
  253. @cindex mark ring
  254. The main use of the mark in the calendar is to remember dates that you may
  255. want to go back to. To make this feature more useful, the mark ring
  256. (@pxref{Mark Ring}) operates exactly as in other buffers: Emacs remembers
  257. 16 previous locations of the mark. To return to a marked date, type @kbd{C-u
  258. C-SPC} (or @kbd{C-u C-@@}); this is the command @code{calendar-set-mark} given
  259. a numeric argument. It moves point to where the mark was, restores the mark
  260. from the ring of former marks, and stores the previous point at the end of
  261. the mark ring. So, repeated use of this command moves point through all
  262. the old marks on the ring, one by one.
  263. @node General Calendar, LaTeX Calendar, Mark and Region, Calendar/Diary
  264. @subsection Miscellaneous Calendar Commands
  265. @table @kbd
  266. @item p d
  267. Display day-in-year (@code{calendar-print-day-of-year}).
  268. @item ?
  269. Briefly describe calendar commands (@code{describe-calendar-mode}).
  270. @item C-c C-l
  271. Regenerate the calendar window (@code{redraw-calendar}).
  272. @item SPC
  273. Scroll the next window (@code{scroll-other-window}).
  274. @item q
  275. Exit from calendar (@code{exit-calendar}).
  276. @end table
  277. @kindex p d @r{(Calendar mode)}
  278. @cindex day of year
  279. @findex calendar-print-day-of-year
  280. If you want to know how many days have elapsed since the start of
  281. the year, or the number of days remaining in the year, type the @kbd{p d}
  282. command (@code{calendar-print-day-of-year}). This displays both
  283. of those numbers in the echo area.
  284. @kindex ? @r{(Calendar mode)}
  285. @findex describe-calendar-mode
  286. To display a brief description of the calendar commands, type @kbd{?}
  287. (@code{describe-calendar-mode}). For a fuller description, type @kbd{C-h m}.
  288. @kindex SPC @r{(Calendar mode)}
  289. @findex scroll-other-window
  290. You can use @kbd{SPC} (@code{scroll-other-window}) to scroll the other
  291. window. This is handy when you display a list of holidays or diary entries
  292. in another window.
  293. @kindex C-c C-l @r{(Calendar mode)}
  294. @findex redraw-calendar
  295. If the calendar window text gets corrupted, type @kbd{C-c C-l}
  296. (@code{redraw-calendar}) to redraw it. (This can only happen if you use
  297. non-Calendar-mode editing commands.)
  298. @kindex SPC @r{(Calendar mode)}
  299. In Calendar mode, you can use @kbd{SPC} (@code{scroll-other-window})
  300. to scroll the other window. This is handy when you display a list of
  301. holidays or diary entries in another window.
  302. @kindex q @r{(Calendar mode)}
  303. @findex exit-calendar
  304. To exit from the calendar, type @kbd{q} (@code{exit-calendar}). This
  305. buries all buffers related to the calendar, selecting other buffers.
  306. (If a frame contains a dedicated calendar window, exiting from the
  307. calendar iconifies that frame.)
  308. @node LaTeX Calendar, Holidays, General Calendar, Calendar/Diary
  309. @section LaTeX Calendar
  310. @cindex calendar and La@TeX{}
  311. The Calendar La@TeX{} commands produce a buffer of La@TeX{} code that
  312. prints as a calendar. Depending on the command you use, the printed
  313. calendar covers the day, week, month or year that point is in.
  314. @kindex t @r{(Calendar mode)}
  315. @table @kbd
  316. @item t m
  317. Generate a one-month calendar (@code{cal-tex-cursor-month}).
  318. @item t M
  319. Generate a sideways-printing one-month calendar
  320. (@code{cal-tex-cursor-month-landscape}).
  321. @item t d
  322. Generate a one-day calendar
  323. (@code{cal-tex-cursor-day}).
  324. @item t w 1
  325. Generate a one-page calendar for one week
  326. (@code{cal-tex-cursor-week}).
  327. @item t w 2
  328. Generate a two-page calendar for one week
  329. (@code{cal-tex-cursor-week2}).
  330. @item t w 3
  331. Generate an ISO-style calendar for one week
  332. (@code{cal-tex-cursor-week-iso}).
  333. @item t w 4
  334. Generate a calendar for one Monday-starting week
  335. (@code{cal-tex-cursor-week-monday}).
  336. @item t f w
  337. Generate a Filofax-style two-weeks-at-a-glance calendar
  338. (@code{cal-tex-cursor-filofax-2week}).
  339. @item t f W
  340. Generate a Filofax-style one-week-at-a-glance calendar
  341. (@code{cal-tex-cursor-filofax-week}).
  342. @item t y
  343. Generate a calendar for one year
  344. (@code{cal-tex-cursor-year}).
  345. @item t Y
  346. Generate a sideways-printing calendar for one year
  347. (@code{cal-tex-cursor-year-landscape}).
  348. @item t f y
  349. Generate a Filofax-style calendar for one year
  350. (@code{cal-tex-cursor-filofax-year}).
  351. @end table
  352. Some of these commands print the calendar sideways (in ``landscape
  353. mode''), so it can be wider than it is long. Some of them use Filofax
  354. paper size (3.75in x 6.75in). All of these commands accept a prefix
  355. argument which specifies how many days, weeks, months or years to print
  356. (starting always with the selected one).
  357. If the variable @code{cal-tex-holidays} is non-@code{nil} (the
  358. default), then the printed calendars show the holidays in
  359. @code{calendar-holidays}. If the variable @code{cal-tex-diary} is
  360. non-@code{nil} (the default is @code{nil}), diary entries are included
  361. also (in weekly and monthly calendars only).
  362. @node Holidays, Sunrise/Sunset, LaTeX Calendar, Calendar/Diary
  363. @subsection Holidays
  364. @cindex holidays
  365. The Emacs calendar knows about all major and many minor holidays,
  366. and can display them.
  367. @table @kbd
  368. @item h
  369. Display holidays for the selected date
  370. (@code{calendar-cursor-holidays}).
  371. @item Button2 Holidays
  372. Display any holidays for the date you click on.
  373. @item x
  374. Mark holidays in the calendar window (@code{mark-calendar-holidays}).
  375. @item u
  376. Unmark calendar window (@code{calendar-unmark}).
  377. @item a
  378. List all holidays for the displayed three months in another window
  379. (@code{list-calendar-holidays}).
  380. @item M-x holidays
  381. List all holidays for three months around today's date in another
  382. window.
  383. @item M-x list-holidays
  384. List holidays in another window for a specified range of years.
  385. @end table
  386. @kindex h @r{(Calendar mode)}
  387. @findex calendar-cursor-holidays
  388. To see if any holidays fall on a given date, position point on that
  389. date in the calendar window and use the @kbd{h} command. Alternatively,
  390. click on that date with @kbd{Button2} and then choose @kbd{Holidays}
  391. from the menu that appears. Either way, this displays the holidays for
  392. that date, in the echo area if they fit there, otherwise in a separate
  393. window.
  394. @kindex x @r{(Calendar mode)}
  395. @findex mark-calendar-holidays
  396. @kindex u @r{(Calendar mode)}
  397. @findex calendar-unmark
  398. To view the distribution of holidays for all the dates shown in the
  399. calendar, use the @kbd{x} command. This displays the dates that are
  400. holidays in a different face (or places a @samp{*} after these dates, if
  401. display with multiple faces is not available). The command applies both
  402. to the currently visible months and to other months that subsequently
  403. become visible by scrolling. To turn marking off and erase the current
  404. marks, type @kbd{u}, which also erases any diary marks (@pxref{Diary}).
  405. @kindex a @r{(Calendar mode)}
  406. @findex list-calendar-holidays
  407. To get even more detailed information, use the @kbd{a} command, which
  408. displays a separate buffer containing a list of all holidays in the
  409. current three-month range. You can use @key{SPC} in the calendar window
  410. to scroll that list.
  411. @findex holidays
  412. The command @kbd{M-x holidays} displays the list of holidays for the
  413. current month and the preceding and succeeding months; this works even
  414. if you don't have a calendar window. If you want the list of holidays
  415. centered around a different month, use @kbd{C-u M-x holidays}, which
  416. prompts for the month and year.
  417. The holidays known to Emacs include United States holidays and the
  418. major Christian, Jewish, and Islamic holidays; also the solstices and
  419. equinoxes.
  420. @findex list-holidays
  421. The command @kbd{M-x list-holidays} displays the list of holidays for
  422. a range of years. This function asks you for the starting and stopping
  423. years, and allows you to choose all the holidays or one of several
  424. categories of holidays. You can use this command even if you don't have
  425. a calendar window.
  426. The dates used by Emacs for holidays are based on @emph{current
  427. practice}, not historical fact. Historically, for instance, the start
  428. of daylight savings time and even its existence have varied from year to
  429. year, but present United States law mandates that daylight savings time
  430. begins on the first Sunday in April. When the daylight savings rules
  431. are set up for the United States, Emacs always uses the present
  432. definition, even though it is wrong for some prior years.
  433. @node Sunrise/Sunset, Lunar Phases, Holidays, Calendar/Diary
  434. @subsection Times of Sunrise and Sunset
  435. @cindex sunrise and sunset
  436. Special calendar commands can tell you, to within a minute or two, the
  437. times of sunrise and sunset for any date.
  438. @table @kbd
  439. @item S
  440. Display times of sunrise and sunset for the selected date
  441. (@code{calendar-sunrise-sunset}).
  442. @item Button2 Sunrise/Sunset
  443. Display times of sunrise and sunset for the date you click on.
  444. @item M-x sunrise-sunset
  445. Display times of sunrise and sunset for today's date.
  446. @item C-u M-x sunrise-sunset
  447. Display times of sunrise and sunset for a specified date.
  448. @end table
  449. @kindex S @r{(Calendar mode)}
  450. @findex calendar-sunrise-sunset
  451. @findex sunrise-sunset
  452. Within the calendar, to display the @emph{local times} of sunrise and
  453. sunset in the echo area, move point to the date you want, and type
  454. @kbd{S}. Alternatively, click @kbd{Button2} on the date, then choose
  455. @kbd{Sunrise/Sunset} from the menu that appears. The command @kbd{M-x
  456. sunrise-sunset} is available outside the calendar to display this
  457. information for today's date or a specified date. To specify a date
  458. other than today, use @kbd{C-u M-x sunrise-sunset}, which prompts for
  459. the year, month, and day.
  460. You can display the times of sunrise and sunset for any location and
  461. any date with @kbd{C-u C-u M-x sunrise-sunset}. This asks you for a
  462. longitude, latitude, number of minutes difference from Coordinated
  463. Universal Time, and date, and then tells you the times of sunrise and
  464. sunset for that location on that date.
  465. Because the times of sunrise and sunset depend on the location on
  466. earth, you need to tell Emacs your latitude, longitude, and location
  467. name before using these commands. Here is an example of what to set:
  468. @vindex calendar-location-name
  469. @vindex calendar-longitude
  470. @vindex calendar-latitude
  471. @example
  472. (setq calendar-latitude 40.1)
  473. (setq calendar-longitude -88.2)
  474. (setq calendar-location-name "Urbana, IL")
  475. @end example
  476. @noindent
  477. Use one decimal place in the values of @code{calendar-latitude} and
  478. @code{calendar-longitude}.
  479. Your time zone also affects the local time of sunrise and sunset.
  480. Emacs usually gets time zone information from the operating system, but
  481. if these values are not what you want (or if the operating system does
  482. not supply them), you must set them yourself. Here is an example:
  483. @vindex calendar-time-zone
  484. @vindex calendar-standard-time-zone-name
  485. @vindex calendar-daylight-time-zone-name
  486. @example
  487. (setq calendar-time-zone -360)
  488. (setq calendar-standard-time-zone-name "CST")
  489. (setq calendar-daylight-time-zone-name "CDT")
  490. @end example
  491. @noindent
  492. The value of @code{calendar-time-zone} is the number of minutes
  493. difference between your local standard time and Coordinated Universal
  494. Time (Greenwich time). The values of
  495. @code{calendar-standard-time-zone-name} and
  496. @code{calendar-daylight-time-zone-name} are the abbreviations used in
  497. your time zone. Emacs displays the times of sunrise and sunset
  498. @emph{corrected for daylight savings time}. @xref{Daylight Savings},
  499. for how daylight savings time is determined.
  500. As a user, you might find it convenient to set the calendar location
  501. variables for your usual physical location in your init file. And when
  502. you install Emacs on a machine, you can create a @file{default.el} file
  503. which sets them properly for the typical location of most users of that
  504. machine. @xref{Init File}.
  505. @node Lunar Phases, Other Calendars, Sunrise/Sunset, Calendar/Diary
  506. @subsection Phases of the Moon
  507. @cindex phases of the moon
  508. @cindex moon, phases of
  509. These calendar commands display the dates and times of the phases of
  510. the moon (new moon, first quarter, full moon, last quarter). This
  511. feature is useful for debugging problems that ``depend on the phase of
  512. the moon.''
  513. @table @kbd
  514. @item M
  515. Display the dates and times for all the quarters of the moon for the
  516. three-month period shown (@code{calendar-phases-of-moon}).
  517. @item M-x phases-of-moon
  518. Display dates and times of the quarters of the moon for three months around
  519. today's date.
  520. @end table
  521. @kindex M @r{(Calendar mode)}
  522. @findex calendar-phases-of-moon
  523. Within the calendar, use the @kbd{M} command to display a separate
  524. buffer of the phases of the moon for the current three-month range. The
  525. dates and times listed are accurate to within a few minutes.
  526. @findex phases-of-moon
  527. Outside the calendar, use the command @kbd{M-x phases-of-moon} to
  528. display the list of the phases of the moon for the current month and the
  529. preceding and succeeding months. For information about a different
  530. month, use @kbd{C-u M-x phases-of-moon}, which prompts for the month and
  531. year.
  532. The dates and times given for the phases of the moon are given in
  533. local time (corrected for daylight savings, when appropriate); but if
  534. the variable @code{calendar-time-zone} is void, Coordinated Universal
  535. Time (the Greenwich time zone) is used. @xref{Daylight Savings}.
  536. @node Other Calendars, Calendar Systems, Lunar Phases, Calendar/Diary
  537. @subsection Conversion To and From Other Calendars
  538. @cindex Gregorian calendar
  539. The Emacs calendar displayed is @emph{always} the Gregorian calendar,
  540. sometimes called the ``new style'' calendar, which is used in most of
  541. the world today. However, this calendar did not exist before the
  542. sixteenth century and was not widely used before the eighteenth century;
  543. it did not fully displace the Julian calendar and gain universal
  544. acceptance until the early twentieth century. The Emacs calendar can
  545. display any month since January, year 1 of the current era, but the
  546. calendar displayed is the Gregorian, even for a date at which the
  547. Gregorian calendar did not exist.
  548. While Emacs cannot display other calendars, it can convert dates to
  549. and from several other calendars.
  550. @menu
  551. * Calendar Systems:: The calendars Emacs understands
  552. (aside from Gregorian).
  553. * To Other Calendar:: Converting the selected date to various calendars.
  554. * From Other Calendar:: Moving to a date specified in another calendar.
  555. * Mayan Calendar:: Moving to a date specified in a Mayan calendar.
  556. @end menu
  557. If you are interested in these calendars, you can convert dates one at a
  558. time. Put point on the desired date of the Gregorian calendar and press the
  559. appropriate keys. The @kbd{p} is a mnemonic for ``print'' since Emacs
  560. ``prints' the equivalent date in the echo area.
  561. @node Calendar Systems, To Other Calendar, Other Calendars, Other Calendars
  562. @section Supported Calendar Systems
  563. @cindex ISO commercial calendar
  564. The ISO commercial calendar is used largely in Europe.
  565. @cindex Julian calendar
  566. The Julian calendar, named after Julius Caesar, was the one used in Europe
  567. throughout medieval times, and in many countries up until the nineteenth
  568. century.
  569. @cindex Julian day numbers
  570. @cindex astronomical day numbers
  571. Astronomers use a simple counting of days elapsed since noon, Monday,
  572. January 1, 4713 B.C. on the Julian calendar. The number of days elapsed
  573. is called the @emph{Julian day number} or the @emph{Astronomical day number}.
  574. @cindex Hebrew calendar
  575. The Hebrew calendar is used by tradition in the Jewish religion. The
  576. Emacs calendar program uses the Hebrew calendar to determine the dates
  577. of Jewish holidays. Hebrew calendar dates begin and end at sunset.
  578. @cindex Islamic calendar
  579. The Islamic calendar is used in many predominantly Islamic countries.
  580. Emacs uses it to determine the dates of Islamic holidays. There is no
  581. universal agreement in the Islamic world about the calendar; Emacs uses
  582. a widely accepted version, but the precise dates of Islamic holidays
  583. often depend on proclamation by religious authorities, not on
  584. calculations. As a consequence, the actual dates of observance can vary
  585. slightly from the dates computed by Emacs. Islamic calendar dates begin
  586. and end at sunset.
  587. @cindex French Revolutionary calendar
  588. The French Revolutionary calendar was created by the Jacobins after the 1789
  589. revolution, to represent a more secular and nature-based view of the annual
  590. cycle, and to install a 10-day week in a rationalization measure similar to
  591. the metric system. The French government officially abandoned this
  592. calendar at the end of 1805.
  593. @cindex Mayan calendar
  594. The Maya of Central America used three separate, overlapping calendar
  595. systems, the @emph{long count}, the @emph{tzolkin}, and the @emph{haab}.
  596. Emacs knows about all three of these calendars. Experts dispute the
  597. exact correlation between the Mayan calendar and our calendar; Emacs uses the
  598. Goodman-Martinez-Thompson correlation in its calculations.
  599. @cindex Coptic calendar
  600. @cindex Ethiopic calendar
  601. The Copts use a calendar based on the ancient Egyptian solar calendar.
  602. Their calendar consists of twelve 30-day months followed by an extra
  603. five-day period. Once every fourth year they add a leap day to this
  604. extra period to make it six days. The Ethiopic calendar is identical in
  605. structure, but has different year numbers and month names.
  606. @cindex Persian calendar
  607. The Persians use a solar calendar based on a design of Omar Khayyam.
  608. Their calendar consists of twelve months of which the first six have 31
  609. days, the next five have 30 days, and the last has 29 in ordinary years
  610. and 30 in leap years. Leap years occur in a complicated pattern every
  611. four or five years.
  612. @cindex Chinese calendar
  613. The Chinese calendar is a complicated system of lunar months arranged
  614. into solar years. The years go in cycles of sixty, each year containing
  615. either twelve months in an ordinary year or thirteen months in a leap
  616. year; each month has either 29 or 30 days. Years, ordinary months, and
  617. days are named by combining one of ten ``celestial stems'' with one of
  618. twelve ``terrestrial branches'' for a total of sixty names that are
  619. repeated in a cycle of sixty.
  620. @node To Other Calendar, From Other Calendar, Calendar Systems, Other Calendars
  621. @section Converting To Other Calendars
  622. The following commands describe the selected date (the date at point)
  623. in various other calendar systems:
  624. @table @kbd
  625. @item Button2 Other Calendars
  626. Display the date that you click on, expressed in various other calendars.
  627. @kindex p @r{(Calendar mode)}
  628. @findex calendar-print-iso-date
  629. @item p c
  630. Display ISO commercial calendar equivalent for selected day
  631. (@code{calendar-print-iso-date}).
  632. @findex calendar-print-julian-date
  633. @item p j
  634. Display Julian date for selected day (@code{calendar-print-julian-date}).
  635. @findex calendar-print-astro-day-number
  636. @item p a
  637. Display astronomical (Julian) day number for selected day
  638. (@code{calendar-print-astro-day-number}).
  639. @findex calendar-print-hebrew-date
  640. @item p h
  641. Display Hebrew date for selected day (@code{calendar-print-hebrew-date}).
  642. @findex calendar-print-islamic-date
  643. @item p i
  644. Display Islamic date for selected day (@code{calendar-print-islamic-date}).
  645. @findex calendar-print-french-date
  646. @item p f
  647. Display French Revolutionary date for selected day
  648. (@code{calendar-print-french-date}).
  649. @findex calendar-print-chinese-date
  650. @item p C
  651. Display Chinese date for selected day
  652. (@code{calendar-print-chinese-date}).
  653. @findex calendar-print-coptic-date
  654. @item p k
  655. Display Coptic date for selected day
  656. (@code{calendar-print-coptic-date}).
  657. @findex calendar-print-ethiopic-date
  658. @item p e
  659. Display Ethiopic date for selected day
  660. (@code{calendar-print-ethiopic-date}).
  661. @findex calendar-print-persian-date
  662. @item p p
  663. Display Persian date for selected day
  664. (@code{calendar-print-persian-date}).
  665. @findex calendar-print-mayan-date
  666. @item p m
  667. Display Mayan date for selected day (@code{calendar-print-mayan-date}).
  668. @end table
  669. If you are using X, the easiest way to translate a date into other
  670. calendars is to click on it with @kbd{Button2}, then choose @kbd{Other
  671. Calendars} from the menu that appears. This displays the equivalent
  672. forms of the date in all the calendars Emacs understands, in the form of
  673. a menu. (Choosing an alternative from this menu doesn't actually do
  674. anything---the menu is used only for display.)
  675. Put point on the desired date of the Gregorian calendar, then type the
  676. appropriate keys. The @kbd{p} is a mnemonic for ``print'' since Emacs
  677. ``prints'' the equivalent date in the echo area.
  678. @node From Other Calendar, Mayan Calendar, To Other Calendar, Other Calendars
  679. @section Converting From Other Calendars
  680. You can use the other supported calendars to specify a date to move
  681. to. This section describes the commands for doing this using calendars
  682. other than Mayan; for the Mayan calendar, see the following section.
  683. @kindex g @var{char} @r{(Calendar mode)}
  684. @findex calendar-goto-iso-date
  685. @findex calendar-goto-julian-date
  686. @findex calendar-goto-astro-day-number
  687. @findex calendar-goto-hebrew-date
  688. @findex calendar-goto-islamic-date
  689. @findex calendar-goto-french-date
  690. @findex calendar-goto-chinese-date
  691. @findex calendar-goto-persian-date
  692. @findex calendar-goto-coptic-date
  693. @findex calendar-goto-ethiopic-date
  694. @table @kbd
  695. @item g c
  696. Move to a date specified in the ISO commercial calendar
  697. (@code{calendar-goto-iso-date}).
  698. @item g j
  699. Move to a date specified in the Julian calendar
  700. (@code{calendar-goto-julian-date}).
  701. @item g a
  702. Move to a date specified in astronomical (Julian) day number
  703. (@code{calendar-goto-astro-day-number}).
  704. @item g h
  705. Move to a date specified in the Hebrew calendar
  706. (@code{calendar-goto-hebrew-date}).
  707. @item g i
  708. Move to a date specified in the Islamic calendar
  709. (@code{calendar-goto-islamic-date}).
  710. @item g f
  711. Move to a date specified in the French Revolutionary calendar
  712. (@code{calendar-goto-french-date}).
  713. @item g C
  714. Move to a date specified in the Chinese calendar
  715. (@code{calendar-goto-chinese-date}).
  716. @item g p
  717. Move to a date specified in the Persian calendar
  718. (@code{calendar-goto-persian-date}).
  719. @item g k
  720. Move to a date specified in the Coptic calendar
  721. (@code{calendar-goto-coptic-date}).
  722. @item g e
  723. Move to a date specified in the Ethiopic calendar
  724. (@code{calendar-goto-ethiopic-date}).
  725. @end table
  726. These commands ask you for a date on the other calendar, move point to
  727. the Gregorian calendar date equivalent to that date, and display the
  728. other calendar's date in the echo area. Emacs uses strict completion
  729. (@pxref{Completion}) whenever it asks you to type a month name, so you
  730. don't have to worry about the spelling of Hebrew, Islamic, or French names.
  731. @findex list-yahrzeit-dates
  732. @cindex yahrzeits
  733. One common question concerning the Hebrew calendar is the computation
  734. of the anniversary of a date of death, called a ``yahrzeit.'' The Emacs
  735. calendar includes a facility for such calculations. If you are in the
  736. calendar, the command @kbd{M-x list-yahrzeit-dates} asks you for a
  737. range of years and then displays a list of the yahrzeit dates for those
  738. years for the date given by point. If you are not in the calendar,
  739. this command first asks you for the date of death and the range of
  740. years, and then displays the list of yahrzeit dates.
  741. @node Mayan Calendar, Diary ,From Other Calendar ,Other Calendars
  742. @subsection Converting from the Mayan Calendar
  743. Here are the commands to select dates based on the Mayan calendar:
  744. @table @kbd
  745. @item g m l
  746. Move to a date specified by the long count calendar
  747. (@code{calendar-goto-mayan-long-count-date}).
  748. @item g m n t
  749. Move to the next occurrence of a place in the
  750. tzolkin calendar (@code{calendar-next-tzolkin-date}).
  751. @item g m p t
  752. Move to the previous occurrence of a place in the
  753. tzolkin calendar (@code{calendar-previous-tzolkin-date}).
  754. @item g m n h
  755. Move to the next occurrence of a place in the
  756. haab calendar (@code{calendar-next-haab-date}).
  757. @item g m p h
  758. Move to the previous occurrence of a place in the
  759. haab calendar (@code{calendar-previous-haab-date}).
  760. @item g m n c
  761. Move to the next occurrence of a place in the
  762. calendar round (@code{calendar-next-calendar-round-date}).
  763. @item g m p c
  764. Move to the previous occurrence of a place in the
  765. calendar round (@code{calendar-previous-calendar-round-date}).
  766. @end table
  767. @cindex Mayan long count
  768. To understand these commands, you need to understand the Mayan calendars.
  769. The @dfn{long count} is a counting of days with these units:
  770. @display
  771. 1 kin = 1 day@ @ @ 1 uinal = 20 kin@ @ @ 1 tun = 18 uinal
  772. 1 katun = 20 tun@ @ @ 1 baktun = 20 katun
  773. @end display
  774. @kindex g m l @r{(Calendar mode)}
  775. @findex calendar-goto-mayan-long-count-date
  776. @noindent
  777. Thus, the long count date 12.16.11.16.6 means 12 baktun, 16 katun, 11
  778. tun, 16 uinal, and 6 kin. The Emacs calendar can handle Mayan long
  779. count dates as early as 7.17.18.13.1, but no earlier. When you use the
  780. @kbd{g m l} command, type the Mayan long count date with the baktun,
  781. katun, tun, uinal, and kin separated by periods.
  782. @findex calendar-previous-tzolkin-date
  783. @findex calendar-next-tzolkin-date
  784. @cindex Mayan tzolkin calendar
  785. The Mayan tzolkin calendar is a cycle of 260 days formed by a pair of
  786. independent cycles of 13 and 20 days. Since this cycle repeats
  787. endlessly, Emacs provides commands to move backward and forward to the
  788. previous or next point in the cycle. Type @kbd{g m p t} to go to the
  789. previous tzolkin date; Emacs asks you for a tzolkin date and moves point
  790. to the previous occurrence of that date. Similarly, type @kbd{g m n t}
  791. to go to the next occurrence of a tzolkin date.
  792. @findex calendar-previous-haab-date
  793. @findex calendar-next-haab-date
  794. @cindex Mayan haab calendar
  795. The Mayan haab calendar is a cycle of 365 days arranged as 18 months
  796. of 20 days each, followed a 5-day monthless period. Like the tzolkin
  797. cycle, this cycle repeats endlessly, and there are commands to move
  798. backward and forward to the previous or next point in the cycle. Type
  799. @kbd{g m p h} to go to the previous haab date; Emacs asks you for a haab
  800. date and moves point to the previous occurrence of that date.
  801. Similarly, type @kbd{g m n h} to go to the next occurrence of a haab
  802. date.
  803. @c This is omitted because it is too long for smallbook format.
  804. @c @findex calendar-previous-calendar-round-date
  805. @findex calendar-next-calendar-round-date
  806. @cindex Mayan calendar round
  807. The Maya also used the combination of the tzolkin date and the haab
  808. date. This combination is a cycle of about 52 years called a
  809. @emph{calendar round}. If you type @kbd{g m p c}, Emacs asks you for
  810. both a haab and a tzolkin date and then moves point to the previous
  811. occurrence of that combination. Use @kbd{g m n c} to move point to the
  812. next occurrence of a combination. These commands signal an error if the
  813. haab/tzolkin date combination you have typed is impossible.
  814. Emacs uses strict completion (@pxref{Completion}) whenever it
  815. asks you to type a Mayan name, so you don't have to worry about
  816. spelling.
  817. @node Diary, Calendar Customization, Mayan Calendar, Calendar/Diary
  818. @subsection The Diary
  819. @cindex diary
  820. The Emacs diary keeps track of appointments or other events on a daily
  821. basis, in conjunction with the calendar. To use the diary feature, you
  822. must first create a @dfn{diary file} containing a list of events and
  823. their dates. Then Emacs can automatically pick out and display the
  824. events for today, for the immediate future, or for any specified
  825. date.
  826. By default, Emacs uses @file{~/diary} as the diary file. This is the
  827. same file that the @code{calendar} utility uses. A sample
  828. @file{~/diary} file is:
  829. @example
  830. 12/22/1988 Twentieth wedding anniversary!!
  831. &1/1. Happy New Year!
  832. 10/22 Ruth's birthday.
  833. * 21, *: Payday
  834. Tuesday--weekly meeting with grad students at 10am
  835. Supowit, Shen, Bitner, and Kapoor to attend.
  836. 1/13/89 Friday the thirteenth!!
  837. &thu 4pm squash game with Lloyd.
  838. mar 16 Dad's birthday
  839. April 15, 1989 Income tax due.
  840. &* 15 time cards due.
  841. @end example
  842. @noindent
  843. This example uses extra spaces to align the event descriptions of most
  844. of the entries. Such formatting is purely a matter of taste.
  845. Although you probably will start by creating a diary manually, Emacs
  846. provides a number of commands to let you view, add, and change diary
  847. entries. You can also share diary entries with other users
  848. (@pxref{Included Diary Files}).
  849. @menu
  850. * Diary Commands:: Viewing diary entries and associated calendar dates.
  851. * Format of Diary File:: Entering events in your diary.
  852. * Date Formats:: Various ways you can specify dates.
  853. * Adding to Diary:: Commands to create diary entries.
  854. * Special Diary Entries:: Anniversaries, blocks of dates, cyclic entries, etc.
  855. @end menu
  856. @node Diary Commands, Format of Diary File, Diary, Diary
  857. @subsection Commands Displaying Diary Entries
  858. Once you have created a @file{~/diary} file, you can use the calendar
  859. to view it. You can also view today's events outside of Calendar mode.
  860. @table @kbd
  861. @item d
  862. Display all diary entries for the selected date
  863. (@code{view-diary-entries}).
  864. @item Button2 Diary
  865. Display all diary entries for the date you click on.
  866. @item s
  867. Display the entire diary file (@code{show-all-diary-entries}).
  868. @item m
  869. Mark all visible dates that have diary entries
  870. (@code{mark-diary-entries}).
  871. @item u
  872. Unmark the calendar window (@code{calendar-unmark}).
  873. @item M-x print-diary-entries
  874. Print hard copy of the diary display as it appears.
  875. @item M-x diary
  876. Display all diary entries for today's date.
  877. @item M-x diary-mail-entries
  878. Mail yourself email reminders about upcoming diary entries.
  879. @end table
  880. @kindex d @r{(Calendar mode)}
  881. @findex view-diary-entries
  882. Displaying the diary entries with @kbd{d} shows in a separate window
  883. the diary entries for the selected date in the calendar. The mode line
  884. of the new window shows the date of the diary entries and any holidays
  885. that fall on that date. If you specify a numeric argument with @kbd{d},
  886. it shows all the diary entries for that many successive days. Thus,
  887. @kbd{2 d} displays all the entries for the selected date and for the
  888. following day.
  889. Another way to display the diary entries for a date is to click
  890. @kbd{Button2} on the date, and then choose @kbd{Diary} from the menu
  891. that appears.
  892. @kindex m @r{(Calendar mode)}
  893. @findex mark-diary-entries
  894. @kindex u @r{(Calendar mode)}
  895. @findex calendar-unmark
  896. To get a broader view of which days are mentioned in the diary, use
  897. the @kbd{m} command. This displays the dates that have diary entries
  898. in a different face (or places a @samp{+} after these dates, if
  899. display with multiple faces is not available). The command applies both
  900. to the currently visible months and to other months that subsequently
  901. become visible by scrolling. To turn marking off and erase the current
  902. marks, type @kbd{u}, which also turns off holiday marks
  903. (@pxref{Holidays}).
  904. @kindex s @r{(Calendar mode)}
  905. @findex show-all-diary-entries
  906. To see the full diary file, rather than just some of the entries, use
  907. the @kbd{s} command.
  908. Display of selected diary entries uses the selective display feature
  909. to hide entries that don't apply.
  910. @findex print-diary-entries
  911. The diary buffer as you see it is an illusion, so simply printing the
  912. buffer does not print what you see on your screen. There is a special
  913. command to print hard copy of the diary buffer @emph{as it appears};
  914. this command is @kbd{M-x print-diary-entries}. It sends the data
  915. directly to the printer. You can customize it like @code{lpr-region}
  916. (@pxref{Hardcopy}).
  917. @findex diary
  918. The command @kbd{M-x diary} displays the diary entries for the current
  919. date, independently of the calendar display, and optionally for the next
  920. few days as well; the variable @code{number-of-diary-entries} specifies
  921. how many days to include (@pxref{Customization}).
  922. If you put @code{(diary)} in your init file, this
  923. automatically displays a window with the day's diary entries, when you
  924. enter Emacs. @xref{Init File}. The mode line of the displayed window
  925. shows the date and any holidays that fall on that date.
  926. @findex diary-mail-entries
  927. @vindex diary-mail-days
  928. Many users like to receive notice of events in their diary as email.
  929. To send such mail to yourself, use the command @kbd{M-x
  930. diary-mail-entries}. A prefix argument specifies how many days
  931. (starting with today) to check; otherwise, the variable
  932. @code{diary-mail-days} says how many days.
  933. @node Format of Diary File, Date Formats, Diary Commands, Diary
  934. @subsection The Diary File
  935. @cindex diary file
  936. @vindex diary-file
  937. Your @dfn{diary file} is a file that records events associated with
  938. particular dates. The name of the diary file is specified by the
  939. variable @code{diary-file}; @file{~/diary} is the default. The
  940. @code{calendar} utility program supports a subset of the format allowed
  941. by the Emacs diary facilities, so you can use that utility to view the
  942. diary file, with reasonable results aside from the entries it cannot
  943. understand.
  944. Each entry in the diary file describes one event and consists of one
  945. or more lines. An entry always begins with a date specification at the
  946. left margin. The rest of the entry is simply text to describe the
  947. event. If the entry has more than one line, then the lines after the
  948. first must begin with whitespace to indicate they continue a previous
  949. entry. Lines that do not begin with valid dates and do not continue a
  950. preceding entry are ignored.
  951. You can inhibit the marking of certain diary entries in the calendar
  952. window; to do this, insert an ampersand (@samp{&}) at the beginning of
  953. the entry, before the date. This has no effect on display of the entry
  954. in the diary window; it affects only marks on dates in the calendar
  955. window. Nonmarking entries are especially useful for generic entries
  956. that would otherwise mark many different dates.
  957. If the first line of a diary entry consists only of the date or day
  958. name with no following blanks or punctuation, then the diary window
  959. display doesn't include that line; only the continuation lines appear.
  960. For example, this entry:
  961. @example
  962. 02/11/1989
  963. Bill B. visits Princeton today
  964. 2pm Cognitive Studies Committee meeting
  965. 2:30-5:30 Liz at Lawrenceville
  966. 4:00pm Dentist appt
  967. 7:30pm Dinner at George's
  968. 8:00-10:00pm concert
  969. @end example
  970. @noindent
  971. appears in the diary window without the date line at the beginning.
  972. This style of entry looks neater when you display just a single day's
  973. entries, but can cause confusion if you ask for more than one day's
  974. entries.
  975. You can edit the diary entries as they appear in the window, but it is
  976. important to remember that the buffer displayed contains the @emph{entire}
  977. diary file, with portions of it concealed from view. This means, for
  978. instance, that the @kbd{C-f} (@code{forward-char}) command can put point
  979. at what appears to be the end of the line, but what is in reality the
  980. middle of some concealed line.
  981. @emph{Be careful when editing the diary entries!} Inserting
  982. additional lines or adding/deleting characters in the middle of a
  983. visible line cannot cause problems, but editing at the end of a line may
  984. not do what you expect. Deleting a line may delete other invisible
  985. entries that follow it. Before editing the diary, it is best to display
  986. the entire file with @kbd{s} (@code{show-all-diary-entries}).
  987. @node Date Formats,Adding to Diary ,Format of Diary File, Diary
  988. @subsection Date Formats
  989. Here are some sample diary entries, illustrating different ways of
  990. formatting a date. The examples all show dates in American order
  991. (month, day, year), but Calendar mode supports European order (day,
  992. month, year) as an option.
  993. @example
  994. 4/20/93 Switch-over to new tabulation system
  995. apr. 25 Start tabulating annual results
  996. 4/30 Results for April are due
  997. */25 Monthly cycle finishes
  998. Friday Don't leave without backing up files
  999. @end example
  1000. The first entry appears only once, on April 20, 1993. The second and
  1001. third appear every year on the specified dates, and the fourth uses a
  1002. wildcard (asterisk) for the month, so it appears on the 25th of every
  1003. month. The final entry appears every week on Friday.
  1004. You can use just numbers to express a date, as in
  1005. @samp{@var{month}/@var{day}} or @samp{@var{month}/@var{day}/@var{year}}.
  1006. This must be followed by a nondigit. In the date itself, @var{month}
  1007. and @var{day} are numbers of one or two digits. The optional @var{year}
  1008. is also a number, and may be abbreviated to the last two digits; that
  1009. is, you can use @samp{11/12/1989} or @samp{11/12/89}.
  1010. Dates can also have the form @samp{@var{monthname} @var{day}} or
  1011. @samp{@var{monthname} @var{day}, @var{year}}, where the month's name can
  1012. be spelled in full or abbreviated to three characters (with or without a
  1013. period). Case is not significant.
  1014. A date may be @dfn{generic}; that is, partially unspecified. Then the
  1015. entry applies to all dates that match the specification. If the date
  1016. does not contain a year, it is generic and applies to any year.
  1017. Alternatively, @var{month}, @var{day}, or @var{year} can be a @samp{*};
  1018. this matches any month, day, or year, respectively. Thus, a diary entry
  1019. @samp{3/*/*} matches any day in March of any year; so does @samp{march
  1020. *}.
  1021. @vindex european-calendar-style
  1022. @findex european-calendar
  1023. @findex american-calendar
  1024. If you prefer the European style of writing dates---in which the day
  1025. comes before the month---type @kbd{M-x european-calendar} while in the
  1026. calendar, or set the variable @code{european-calendar-style} to @code{t}
  1027. @emph{before} using any calendar or diary command. This mode interprets
  1028. all dates in the diary in the European manner, and also uses European
  1029. style for displaying diary dates. (Note that there is no comma after
  1030. the @var{monthname} in the European style.) To go back to the (default)
  1031. American style of writing dates, type @kbd{M-x american-calendar}.
  1032. You can use the name of a day of the week as a generic date which
  1033. applies to any date falling on that day of the week. You can abbreviate
  1034. the day of the week to three letters (with or without a period) or spell
  1035. it in full; case is not significant.
  1036. @node Adding to Diary, Special Diary Entries, Date Formats, Diary
  1037. @subsection Commands to Add to the Diary
  1038. While in the calendar, there are several commands to create diary
  1039. entries:
  1040. @table @kbd
  1041. @item i d
  1042. Add a diary entry for the selected date (@code{insert-diary-entry}).
  1043. @item i w
  1044. Add a diary entry for the selected day of the week (@code{insert-weekly-diary-entry}).
  1045. @item i m
  1046. Add a diary entry for the selected day of the month (@code{insert-monthly-diary-entry}).
  1047. @item i y
  1048. Add a diary entry for the selected day of the year (@code{insert-yearly-diary-entry}).
  1049. @end table
  1050. @kindex i d @r{(Calendar mode)}
  1051. @findex insert-diary-entry
  1052. You can make a diary entry for a specific date by selecting that date
  1053. in the calendar window and typing the @kbd{i d} command. This command
  1054. displays the end of your diary file in another window and inserts the
  1055. date; you can then type the rest of the diary entry.
  1056. @kindex i w @r{(Calendar mode)}
  1057. @findex insert-weekly-diary-entry
  1058. @kindex i m @r{(Calendar mode)}
  1059. @findex insert-monthly-diary-entry
  1060. @kindex i y @r{(Calendar mode)}
  1061. @findex insert-yearly-diary-entry
  1062. If you want to make a diary entry that applies to a specific day of
  1063. the week, select that day of the week (any occurrence will do) and type
  1064. @kbd{i w}. This inserts the day-of-week as a generic date; you can then
  1065. type the rest of the diary entry. You can make a monthly diary entry in
  1066. the same fashion. Select the day of the month, use the @kbd{i m}
  1067. command, and type rest of the entry. Similarly, you can insert a yearly
  1068. diary entry with the @kbd{i y} command.
  1069. All of the above commands make marking diary entries by default. To
  1070. make a nonmarking diary entry, give a numeric argument to the command.
  1071. For example, @kbd{C-u i w} makes a nonmarking weekly diary entry.
  1072. When you modify the diary file, be sure to save the file before
  1073. exiting Emacs.
  1074. @node Special Diary Entries,, Adding to Diary, Diary
  1075. @subsection Special Diary Entries
  1076. In addition to entries based on calendar dates, the diary file can
  1077. contain @dfn{sexp entries} for regular events such as anniversaries.
  1078. These entries are based on Lisp expressions (sexps) that Emacs evaluates
  1079. as it scans the diary file. Instead of a date, a sexp entry contains
  1080. @samp{%%} followed by a Lisp expression which must begin and end with
  1081. parentheses. The Lisp expression determines which dates the entry
  1082. applies to.
  1083. Calendar mode provides commands to insert certain commonly used
  1084. sexp entries:
  1085. @table @kbd
  1086. @item i a
  1087. Add an anniversary diary entry for the selected date
  1088. (@code{insert-anniversary-diary-entry}).
  1089. @item i b
  1090. Add a block diary entry for the current region
  1091. (@code{insert-block-diary-entry}).
  1092. @item i c
  1093. Add a cyclic diary entry starting at the date
  1094. (@code{insert-cyclic-diary-entry}).
  1095. @end table
  1096. @kindex i a @r{(Calendar mode)}
  1097. @findex insert-anniversary-diary-entry
  1098. If you want to make a diary entry that applies to the anniversary of a
  1099. specific date, move point to that date and use the @kbd{i a} command.
  1100. This displays the end of your diary file in another window and inserts
  1101. the anniversary description; you can then type the rest of the diary
  1102. entry. The entry looks like this:
  1103. @findex diary-anniversary
  1104. The effect of @kbd{i a} is to add a @code{diary-anniversary} sexp to your
  1105. diary file. You can also add one manually, for instance:
  1106. @example
  1107. %%(diary-anniversary 10 31 1948) Arthur's birthday
  1108. @end example
  1109. @noindent
  1110. This entry applies to October 31 in any year after 1948; @samp{10 31
  1111. 1948} specifies the date. (If you are using the European calendar
  1112. style, the month and day are interchanged.) The reason this expression
  1113. requires a beginning year is that advanced diary functions can use it to
  1114. calculate the number of elapsed years.
  1115. A @dfn{block} diary entry applies to a specified range of consecutive
  1116. dates. Here is a block diary entry that applies to all dates from June
  1117. 24, 1990 through July 10, 1990:
  1118. @findex diary-block
  1119. @example
  1120. %%(diary-block 6 24 1990 7 10 1990) Vacation
  1121. @end example
  1122. @noindent
  1123. The @samp{6 24 1990} indicates the starting date and the @samp{7 10 1990}
  1124. indicates the stopping date. (Again, if you are using the European calendar
  1125. style, the month and day are interchanged.)
  1126. @kindex i b @r{(Calendar mode)}
  1127. @findex insert-block-diary-entry
  1128. To insert a block entry, place point and the mark on the two
  1129. dates that begin and end the range, and type @kbd{i b}. This command
  1130. displays the end of your diary file in another window and inserts the
  1131. block description; you can then type the diary entry.
  1132. @kindex i c @r{(Calendar mode)}
  1133. @findex insert-cyclic-diary-entry
  1134. @dfn{Cyclic} diary entries repeat after a fixed interval of days. To
  1135. create one, select the starting date and use the @kbd{i c} command. The
  1136. command prompts for the length of interval, then inserts the entry,
  1137. which looks like this:
  1138. @findex diary-cyclic
  1139. @example
  1140. %%(diary-cyclic 50 3 1 1990) Renew medication
  1141. @end example
  1142. @noindent
  1143. This entry applies to March 1, 1990 and every 50th day following;
  1144. @samp{3 1 1990} specifies the starting date. (If you are using the
  1145. European calendar style, the month and day are interchanged.)
  1146. All three of these commands make marking diary entries. To insert a
  1147. nonmarking entry, give a numeric argument to the command. For example,
  1148. @kbd{C-u i a} makes a nonmarking anniversary diary entry.
  1149. Marking sexp diary entries in the calendar is @emph{extremely}
  1150. time-consuming, since every date visible in the calendar window must be
  1151. individually checked. So it's a good idea to make sexp diary entries
  1152. nonmarking (with @samp{&}) when possible.
  1153. Another sophisticated kind of sexp entry, a @dfn{floating} diary entry,
  1154. specifies a regularly occurring event by offsets specified in days,
  1155. weeks, and months. It is comparable to a crontab entry interpreted by
  1156. the @code{cron} utility. Here is a nonmarking, floating diary entry
  1157. that applies to the last Thursday in November:
  1158. @findex diary-float
  1159. @example
  1160. &%%(diary-float 11 4 -1) American Thanksgiving
  1161. @end example
  1162. @noindent
  1163. The 11 specifies November (the eleventh month), the 4 specifies Thursday
  1164. (the fourth day of the week, where Sunday is numbered zero), and the
  1165. @minus{}1 specifies ``last'' (1 would mean ``first'', 2 would mean
  1166. ``second'', @minus{}2 would mean ``second-to-last'', and so on). The
  1167. month can be a single month or a list of months. Thus you could change
  1168. the 11 above to @samp{'(1 2 3)} and have the entry apply to the last
  1169. Thursday of January, February, and March. If the month is @code{t}, the
  1170. entry applies to all months of the year.@refill
  1171. The sexp feature of the diary allows you to specify diary entries
  1172. based on any Emacs Lisp expression. You can use the library of built-in
  1173. functions or you can write your own functions. The built-in functions
  1174. include the ones shown in this section, plus a few others (@pxref{Sexp
  1175. Diary Entries}).
  1176. The generality of sexps lets you specify any diary entry that you can
  1177. describe algorithmically. Suppose you get paid on the 21st of the month
  1178. if it is a weekday, and to the Friday before if the 21st is on a
  1179. weekend. The diary entry
  1180. @example
  1181. &%%(let ((dayname (calendar-day-of-week date))
  1182. (day (car (cdr date))))
  1183. (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
  1184. (and (memq day '(19 20)) (= dayname 5)))
  1185. ) Pay check deposited
  1186. @end example
  1187. @noindent
  1188. to just those dates. This example illustrates how the sexp can depend
  1189. on the variable @code{date}; this variable is a list (@var{month}
  1190. @var{day} @var{year}) that gives the Gregorian date for which the diary
  1191. entries are being found. If the value of the sexp is @code{t}, the
  1192. entry applies to that date. If the sexp evaluates to @code{nil}, the
  1193. entry does @emph{not} apply to that date.
  1194. @node Calendar Customization,,Diary, Calendar/Diary
  1195. @subsection Customizing the Calendar and Diary
  1196. There are many customizations that you can use to make the calendar and
  1197. diary suit your personal tastes.
  1198. @menu
  1199. * Calendar Customizing:: Defaults you can set.
  1200. * Holiday Customizing:: Defining your own holidays.
  1201. * Date Display Format:: Changing the format.
  1202. * Time Display Format:: Changing the format.
  1203. * Daylight Savings:: Changing the default.
  1204. * Diary Customizing:: Defaults you can set.
  1205. * Hebrew/Islamic Entries:: How to obtain them.
  1206. * Fancy Diary Display:: Enhancing the diary display, sorting entries.
  1207. * Included Diary Files:: Sharing a common diary file.
  1208. * Sexp Diary Entries:: Fancy things you can do.
  1209. * Appt Customizing:: Customizing appointment reminders.
  1210. @end menu
  1211. @node Calendar Customizing
  1212. @subsubsection Customizing the Calendar
  1213. @vindex view-diary-entries-initially
  1214. If you set the variable @code{view-diary-entries-initially} to
  1215. @code{t}, calling up the calendar automatically displays the diary
  1216. entries for the current date as well. The diary dates appear only if
  1217. the current date is visible. If you add both of the following lines to
  1218. your init file:@refill
  1219. @example
  1220. (setq view-diary-entries-initially t)
  1221. (calendar)
  1222. @end example
  1223. @noindent
  1224. this displays both the calendar and diary windows whenever you start
  1225. Emacs. @xref{Init File}.
  1226. @vindex view-calendar-holidays-initially
  1227. Similarly, if you set the variable
  1228. @code{view-calendar-holidays-initially} to @code{t}, entering the
  1229. calendar automatically displays a list of holidays for the current
  1230. three-month period. The holiday list appears in a separate
  1231. window.
  1232. @vindex mark-diary-entries-in-calendar
  1233. You can set the variable @code{mark-diary-entries-in-calendar} to
  1234. @code{t} in order to mark any dates with diary entries. This takes
  1235. effect whenever the calendar window contents are recomputed. There are
  1236. two ways of marking these dates: by changing the face (@pxref{Faces}),
  1237. if the display supports that, or by placing a plus sign (@samp{+})
  1238. beside the date otherwise.
  1239. @vindex mark-holidays-in-calendar
  1240. Similarly, setting the variable @code{mark-holidays-in-calendar} to
  1241. @code{t} marks holiday dates, either with a change of face or with an
  1242. asterisk (@samp{*}).
  1243. @vindex calendar-holiday-marker
  1244. @vindex diary-entry-marker
  1245. The variable @code{calendar-holiday-marker} specifies how to mark a
  1246. date as being a holiday. Its value may be a character to insert next to
  1247. the date, or a face name to use for displaying the date. Likewise, the
  1248. variable @code{diary-entry-marker} specifies how to mark a date that has
  1249. diary entries. The calendar creates faces named @code{holiday-face} and
  1250. @code{diary-face} for these purposes; those symbols are the default
  1251. values of these variables, when Emacs supports multiple faces on your
  1252. terminal.
  1253. @vindex calendar-load-hook
  1254. The variable @code{calendar-load-hook} is a normal hook run when the
  1255. calendar package is first loaded (before actually starting to display
  1256. the calendar).
  1257. @vindex initial-calendar-window-hook
  1258. Starting the calendar runs the normal hook
  1259. @code{initial-calendar-window-hook}. Recomputation of the calendar
  1260. display does not run this hook. But if you leave the calendar with the
  1261. @kbd{q} command and reenter it, the hook runs again.@refill
  1262. @vindex today-visible-calendar-hook
  1263. The variable @code{today-visible-calendar-hook} is a normal hook run
  1264. after the calendar buffer has been prepared with the calendar when the
  1265. current date is visible in the window. One use of this hook is to
  1266. replace today's date with asterisks; to do that, use the hook function
  1267. @code{calendar-star-date}.
  1268. @findex calendar-star-date
  1269. @example
  1270. (add-hook 'today-visible-calendar-hook 'calendar-star-date)
  1271. @end example
  1272. @noindent
  1273. Another standard hook function marks the current date, either by
  1274. changing its face or by adding an asterisk. Here's how to use it:
  1275. @findex calendar-mark-today
  1276. @example
  1277. (add-hook 'today-visible-calendar-hook 'calendar-mark-today)
  1278. @end example
  1279. @noindent
  1280. @vindex calendar-today-marker
  1281. The variable @code{calendar-today-marker} specifies how to mark today's
  1282. date. Its value should be a character to insert next to the date or a
  1283. face name to use for displaying the date. A face named
  1284. @code{calendar-today-face} is provided for this purpose; that symbol is
  1285. the default for this variable when Emacs supports multiple faces on your
  1286. terminal.
  1287. @vindex today-invisible-calendar-hook
  1288. @noindent
  1289. A similar normal hook, @code{today-invisible-calendar-hook} is run if
  1290. the current date is @emph{not} visible in the window.
  1291. @node Holiday Customizing
  1292. @subsubsection Customizing the Holidays
  1293. @vindex calendar-holidays
  1294. @vindex christian-holidays
  1295. @vindex hebrew-holidays
  1296. @vindex islamic-holidays
  1297. Emacs knows about holidays defined by entries on one of several lists.
  1298. You can customize these lists of holidays to your own needs, adding or
  1299. deleting holidays. The lists of holidays that Emacs uses are for
  1300. general holidays (@code{general-holidays}), local holidays
  1301. (@code{local-holidays}), Christian holidays (@code{christian-holidays}),
  1302. Hebrew (Jewish) holidays (@code{hebrew-holidays}), Islamic (Moslem)
  1303. holidays (@code{islamic-holidays}), and other holidays
  1304. (@code{other-holidays}).
  1305. @vindex general-holidays
  1306. The general holidays are, by default, holidays common throughout the
  1307. United States. To eliminate these holidays, set @code{general-holidays}
  1308. to @code{nil}.
  1309. @vindex local-holidays
  1310. There are no default local holidays (but sites may supply some). You
  1311. can set the variable @code{local-holidays} to any list of holidays, as
  1312. described below.
  1313. @vindex all-christian-calendar-holidays
  1314. @vindex all-hebrew-calendar-holidays
  1315. @vindex all-islamic-calendar-holidays
  1316. By default, Emacs does not include all the holidays of the religions
  1317. that it knows, only those commonly found in secular calendars. For a
  1318. more extensive collection of religious holidays, you can set any (or
  1319. all) of the variables @code{all-christian-calendar-holidays},
  1320. @code{all-hebrew-calendar-holidays}, or
  1321. @code{all-islamic-calendar-holidays} to @code{t}. If you want to
  1322. eliminate the religious holidays, set any or all of the corresponding
  1323. variables @code{christian-holidays}, @code{hebrew-holidays}, and
  1324. @code{islamic-holidays} to @code{nil}.@refill
  1325. @vindex other-holidays
  1326. You can set the variable @code{other-holidays} to any list of
  1327. holidays. This list, normally empty, is intended for individual use.
  1328. @cindex holiday forms
  1329. Each of the lists (@code{general-holidays}, @code{local-holidays},
  1330. @code{christian-holidays}, @code{hebrew-holidays},
  1331. @code{islamic-holidays}, and @code{other-holidays}) is a list of
  1332. @dfn{holiday forms}, each holiday form describing a holiday (or
  1333. sometimes a list of holidays).
  1334. Here is a table of the possible kinds of holiday form. Day numbers
  1335. and month numbers count starting from 1, but ``dayname'' numbers
  1336. count Sunday as 0. The element @var{string} is always the
  1337. name of the holiday, as a string.
  1338. @table @code
  1339. @item (holiday-fixed @var{month} @var{day} @var{string})
  1340. A fixed date on the Gregorian calendar. @var{month} and @var{day} are
  1341. numbers, @var{string} is the name of the holiday.
  1342. @item (holiday-float @var{month} @var{dayname} @var{k} @var{string})
  1343. The @var{k}th @var{dayname} in @var{month} on the Gregorian calendar
  1344. (@var{dayname}=0 for Sunday, and so on); negative @var{k} means count back
  1345. from the end of the month. @var{string} is the name of the holiday.
  1346. @item (holiday-hebrew @var{month} @var{day} @var{string})
  1347. A fixed date on the Hebrew calendar. @var{month} and @var{day} are
  1348. numbers, @var{string} is the name of the holiday.
  1349. @item (holiday-islamic @var{month} @var{day} @var{string})
  1350. A fixed date on the Islamic calendar. @var{month} and @var{day} are
  1351. numbers, @var{string} is the name of the holiday.
  1352. @item (holiday-julian @var{month} @var{day} @var{string})
  1353. A fixed date on the Julian calendar. @var{month} and @var{day} are
  1354. numbers, @var{string} is the name of the holiday.
  1355. @item (holiday-sexp @var{sexp} @var{string})
  1356. A date calculated by the Lisp expression @var{sexp}. The expression
  1357. should use the variable @code{year} to compute and return the date of a
  1358. holiday, or @code{nil} if the holiday doesn't happen this year. The
  1359. value of @var{sexp} must represent the date as a list of the form
  1360. @code{(@var{month} @var{day} @var{year})}. @var{string} is the name of
  1361. the holiday.
  1362. @item (if @var{condition} @var{holiday-form} &optional @var{holiday-form})
  1363. A holiday that happens only if @var{condition} is true.
  1364. @item (@var{function} @r{[}@var{args}@r{]})
  1365. A list of dates calculated by the function @var{function}, called with
  1366. arguments @var{args}.
  1367. @end table
  1368. For example, suppose you want to add Bastille Day, celebrated in
  1369. France on July 14. You can do this by adding the following line
  1370. to your init file:
  1371. @smallexample
  1372. (setq other-holidays '((holiday-fixed 7 14 "Bastille Day")))
  1373. @end smallexample
  1374. @xref{Init File}.
  1375. @noindent
  1376. The holiday form @code{(holiday-fixed 7 14 "Bastille Day")} specifies the
  1377. fourteenth day of the seventh month (July).
  1378. Many holidays occur on a specific day of the week, at a specific time
  1379. of month. Here is a holiday form describing Hurricane Supplication Day,
  1380. celebrated in the Virgin Islands on the fourth Monday in August:
  1381. @smallexample
  1382. (holiday-float 8 1 4 "Hurricane Supplication Day")
  1383. @end smallexample
  1384. @noindent
  1385. Here the 8 specifies August, the 1 specifies Monday (Sunday is 0,
  1386. Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in
  1387. the month (1 specifies the first occurrence, 2 the second occurrence,
  1388. @minus{}1 the last occurrence, @minus{}2 the second-to-last occurrence, and
  1389. so on).
  1390. You can specify holidays that occur on fixed days of the Hebrew,
  1391. Islamic, and Julian calendars too. For example,
  1392. @smallexample
  1393. (setq other-holidays
  1394. '((holiday-hebrew 10 2 "Last day of Hanukkah")
  1395. (holiday-islamic 3 12 "Mohammed's Birthday")
  1396. (holiday-julian 4 2 "Jefferson's Birthday")))
  1397. @end smallexample
  1398. @noindent
  1399. adds the last day of Hanukkah (since the Hebrew months are numbered with
  1400. 1 starting from Nisan), the Islamic feast celebrating Mohammed's
  1401. birthday (since the Islamic months are numbered from 1 starting with
  1402. Muharram), and Thomas Jefferson's birthday, which is 2 April 1743 on the
  1403. Julian calendar.
  1404. To include a holiday conditionally, use either Emacs Lisp's @code{if} or the
  1405. @code{holiday-sexp} form. For example, American presidential elections
  1406. occur on the first Tuesday after the first Monday in November of years
  1407. divisible by 4:
  1408. @smallexample
  1409. (holiday-sexp (if (= 0 (% year 4))
  1410. (calendar-gregorian-from-absolute
  1411. (1+ (calendar-dayname-on-or-before
  1412. 1 (+ 6 (calendar-absolute-from-gregorian
  1413. (list 11 1 year))))))
  1414. "US Presidential Election"))
  1415. @end smallexample
  1416. @noindent
  1417. or
  1418. @smallexample
  1419. (if (= 0 (% displayed-year 4))
  1420. (fixed 11
  1421. (extract-calendar-day
  1422. (calendar-gregorian-from-absolute
  1423. (1+ (calendar-dayname-on-or-before
  1424. 1 (+ 6 (calendar-absolute-from-gregorian
  1425. (list 11 1 displayed-year)))))))
  1426. "US Presidential Election"))
  1427. @end smallexample
  1428. Some holidays just don't fit into any of these forms because special
  1429. calculations are involved in their determination. In such cases you
  1430. must write a Lisp function to do the calculation. To include eclipses,
  1431. for example, add @code{(eclipses)} to @code{other-holidays}
  1432. and write an Emacs Lisp function @code{eclipses} that returns a
  1433. (possibly empty) list of the relevant Gregorian dates among the range
  1434. visible in the calendar window, with descriptive strings, like this:
  1435. @smallexample
  1436. (((6 27 1991) "Lunar Eclipse") ((7 11 1991) "Solar Eclipse") ... )
  1437. @end smallexample
  1438. @node Date Display Format
  1439. @subsubsection Date Display Format
  1440. @vindex calendar-date-display-form
  1441. You can customize the manner of displaying dates in the diary, in mode
  1442. lines, and in messages by setting @code{calendar-date-display-form}.
  1443. This variable holds a list of expressions that can involve the variables
  1444. @code{month}, @code{day}, and @code{year}, which are all numbers in
  1445. string form, and @code{monthname} and @code{dayname}, which are both
  1446. alphabetic strings. In the American style, the default value of this
  1447. list is as follows:
  1448. @smallexample
  1449. ((if dayname (concat dayname ", ")) monthname " " day ", " year)
  1450. @end smallexample
  1451. @noindent
  1452. while in the European style this value is the default:
  1453. @smallexample
  1454. ((if dayname (concat dayname ", ")) day " " monthname " " year)
  1455. @end smallexample
  1456. +@noindent
  1457. The ISO standard date representation is this:
  1458. @smallexample
  1459. (year "-" month "-" day)
  1460. @end smallexample
  1461. @noindent
  1462. This specifies a typical American format:
  1463. @smallexample
  1464. (month "/" day "/" (substring year -2))
  1465. @end smallexample
  1466. @node Time Display Format
  1467. @subsubsection Time Display Format
  1468. @vindex calendar-time-display-form
  1469. The calendar and diary by default display times of day in the
  1470. conventional American style with the hours from 1 through 12, minutes,
  1471. and either @samp{am} or @samp{pm}. If you prefer the European style,
  1472. also known in the US as military, in which the hours go from 00 to 23,
  1473. you can alter the variable @code{calendar-time-display-form}. This
  1474. variable is a list of expressions that can involve the variables
  1475. @code{12-hours}, @code{24-hours}, and @code{minutes}, which are all
  1476. numbers in string form, and @code{am-pm} and @code{time-zone}, which are
  1477. both alphabetic strings. The default value of
  1478. @code{calendar-time-display-form} is as follows:
  1479. @smallexample
  1480. (12-hours ":" minutes am-pm
  1481. (if time-zone " (") time-zone (if time-zone ")"))
  1482. @end smallexample
  1483. @noindent
  1484. Here is a value that provides European style times:
  1485. @smallexample
  1486. (24-hours ":" minutes
  1487. (if time-zone " (") time-zone (if time-zone ")"))
  1488. @end smallexample
  1489. @noindent
  1490. gives military-style times like @samp{21:07 (UT)} if time zone names are
  1491. defined, and times like @samp{21:07} if they are not.
  1492. @node Daylight Savings
  1493. @subsubsection Daylight Savings Time
  1494. @cindex daylight savings time
  1495. Emacs understands the difference between standard time and daylight
  1496. savings time---the times given for sunrise, sunset, solstices,
  1497. equinoxes, and the phases of the moon take that into account. The rules
  1498. for daylight savings time vary from place to place and have also varied
  1499. historically from year to year. To do the job properly, Emacs needs to
  1500. know which rules to use.
  1501. Some operating systems keep track of the rules that apply to the place
  1502. where you are; on these systems, Emacs gets the information it needs
  1503. from the system automatically. If some or all of this information is
  1504. missing, Emacs fills in the gaps with the rules currently used in
  1505. Cambridge, Massachusetts. If the resulting rules are not what you want,
  1506. you can tell Emacs the rules to use by setting certain variables.
  1507. @vindex calendar-daylight-savings-starts
  1508. @vindex calendar-daylight-savings-ends
  1509. If the default choice of rules is not appropriate for your location,
  1510. you can tell Emacs the rules to use by setting the variables
  1511. @code{calendar-daylight-savings-starts} and
  1512. @code{calendar-daylight-savings-ends}. Their values should be Lisp
  1513. expressions that refer to the variable @code{year}, and evaluate to the
  1514. Gregorian date on which daylight savings time starts or (respectively)
  1515. ends, in the form of a list @code{(@var{month} @var{day} @var{year})}.
  1516. The values should be @code{nil} if your area does not use daylight
  1517. savings time.
  1518. Emacs uses these expressions to determine the starting date of
  1519. daylight savings time for the holiday list and for correcting times of
  1520. day in the solar and lunar calculations.
  1521. The values for Cambridge, Massachusetts are as follows:
  1522. @example
  1523. @group
  1524. (calendar-nth-named-day 1 0 4 year)
  1525. (calendar-nth-named-day -1 0 10 year)
  1526. @end group
  1527. @end example
  1528. @noindent
  1529. That is, the first 0th day (Sunday) of the fourth month (April) in
  1530. the year specified by @code{year}, and the last Sunday of the tenth month
  1531. (October) of that year. If daylight savings time were
  1532. changed to start on October 1, you would set
  1533. @code{calendar-daylight-savings-starts} to this:
  1534. @example
  1535. (list 10 1 year)
  1536. @end example
  1537. For a more complex example, suppose daylight savings time begins on
  1538. the first of Nisan on the Hebrew calendar. You should set
  1539. @code{calendar-daylight-savings-starts} to this value:
  1540. @example
  1541. (calendar-gregorian-from-absolute
  1542. (calendar-absolute-from-hebrew
  1543. (list 1 1 (+ year 3760))))
  1544. @end example
  1545. @noindent
  1546. because Nisan is the first month in the Hebrew calendar and the Hebrew
  1547. year differs from the Gregorian year by 3760 at Nisan.
  1548. If there is no daylight savings time at your location, or if you want
  1549. all times in standard time, set @code{calendar-daylight-savings-starts}
  1550. and @code{calendar-daylight-savings-ends} to @code{nil}.
  1551. @vindex calendar-daylight-time-offset
  1552. The variable @code{calendar-daylight-time-offset} specifies the
  1553. difference between daylight savings time and standard time, measured in
  1554. minutes. The value for Cambridge, Massachusetts is 60.
  1555. @c @vindex calendar-daylight-savings-starts-time too long!
  1556. @vindex calendar-daylight-savings-ends-time
  1557. The two variables @code{calendar-daylight-savings-starts-time} and
  1558. @code{calendar-daylight-savings-ends-time} specify the number of minutes
  1559. after midnight local time when the transition to and from daylight
  1560. savings time should occur. For Cambridge, Massachusetts both variables'
  1561. values are 120.
  1562. @node Diary Customizing
  1563. @subsubsection Customizing the Diary
  1564. @vindex holidays-in-diary-buffer
  1565. Ordinarily, the mode line of the diary buffer window indicates any
  1566. holidays that fall on the date of the diary entries. The process of
  1567. checking for holidays can take several seconds, so including holiday
  1568. information delays the display of the diary buffer noticeably. If you'd
  1569. prefer to have a faster display of the diary buffer but without the
  1570. holiday information, set the variable @code{holidays-in-diary-buffer} to
  1571. @code{nil}.@refill
  1572. @vindex number-of-diary-entries
  1573. The variable @code{number-of-diary-entries} controls the number of
  1574. days of diary entries to be displayed at one time. It affects the
  1575. initial display when @code{view-diary-entries-initially} is @code{t}, as
  1576. well as the command @kbd{M-x diary}. For example, the default value is
  1577. 1, which says to display only the current day's diary entries. If the
  1578. value is 2, both the current day's and the next day's entries are
  1579. displayed. The value can also be a vector of seven elements: for
  1580. example, if the value is @code{[0 2 2 2 2 4 1]} then no diary entries
  1581. appear on Sunday, the current date's and the next day's diary entries
  1582. appear Monday through Thursday, Friday through Monday's entries appear
  1583. on Friday, while on Saturday only that day's entries appear.
  1584. @vindex print-diary-entries-hook
  1585. @findex print-diary-entries
  1586. The variable @code{print-diary-entries-hook} is a normal hook run
  1587. after preparation of a temporary buffer containing just the diary
  1588. entries currently visible in the diary buffer. (The other, irrelevant
  1589. diary entries are really absent from the temporary buffer; in the diary
  1590. buffer, they are merely hidden.) The default value of this hook does
  1591. the printing with the command @code{lpr-buffer}. If you want to use a
  1592. different command to do the printing, just change the value of this
  1593. hook. Other uses might include, for example, rearranging the lines into
  1594. order by day and time.
  1595. @vindex diary-date-forms
  1596. You can customize the form of dates in your diary file, if neither the
  1597. standard American nor European styles suits your needs, by setting the
  1598. variable @code{diary-date-forms}. This variable is a list of patterns
  1599. for recognizing a date. Each date pattern is a list whose elements may
  1600. be regular expressions (@pxref{Regexps}) or the symbols
  1601. @code{month}, @code{day}, @code{year}, @code{monthname}, and
  1602. @code{dayname}. All these elements serve as patterns that match certain
  1603. kinds of text in the diary file. In order for the date pattern, as a
  1604. whole, to match, all of its elements must match consecutively.
  1605. A regular expression in a date pattern matches in its usual fashion,
  1606. using the standard syntax table altered so that @samp{*} is a word
  1607. constituent.
  1608. The symbols @code{month}, @code{day}, @code{year}, @code{monthname},
  1609. and @code{dayname} match the month number, day number, year number,
  1610. month name, and day name of the date being considered. The symbols that
  1611. match numbers allow leading zeros; those that match names allow
  1612. three-letter abbreviations and capitalization. All the symbols can
  1613. match @samp{*}; since @samp{*} in a diary entry means ``any day'', ``any
  1614. month'', and so on, it should match regardless of the date being
  1615. considered.
  1616. The default value of @code{diary-date-forms} in the American style is
  1617. this:
  1618. @example
  1619. ((month "/" day "[^/0-9]")
  1620. (month "/" day "/" year "[^0-9]")
  1621. (monthname " *" day "[^,0-9]")
  1622. (monthname " *" day ", *" year "[^0-9]")
  1623. (dayname "\\W"))
  1624. @end example
  1625. @noindent
  1626. Emacs matches of the diary entries with the date forms is done with the
  1627. standard syntax table from Fundamental mode
  1628. (@pxref{Syntax Tables,,,lispref,XEmacs Lisp Reference Manual}),
  1629. but with the @samp{*} changed so that it is a word constituent.@refill
  1630. The date patterns in the list must be @emph{mutually exclusive} and
  1631. must not match any portion of the diary entry itself, just the date and
  1632. one character of whitespace. If, to be mutually exclusive, the pattern
  1633. must match a portion of the diary entry text---beyond the whitespace
  1634. that ends the date---then the first element of the date pattern
  1635. @emph{must} be @code{backup}. This causes the date recognizer to back
  1636. up to the beginning of the current word of the diary entry, after
  1637. finishing the match. Even if you use @code{backup}, the date pattern
  1638. must absolutely not match more than a portion of the first word of the
  1639. diary entry. The default value of @code{diary-date-forms} in the
  1640. European style is this list:
  1641. @example
  1642. ((day "/" month "[^/0-9]")
  1643. (day "/" month "/" year "[^0-9]")
  1644. (backup day " *" monthname "\\W+\\<[^*0-9]")
  1645. (day " *" monthname " *" year "[^0-9]")
  1646. (dayname "\\W"))
  1647. @end example
  1648. @noindent
  1649. Notice the use of @code{backup} in the third pattern, because it needs
  1650. to match part of a word beyond the date itself to distinguish it from
  1651. the fourth pattern.
  1652. @node Hebrew/Islamic Entries
  1653. @subsubsection Hebrew- and Islamic-Date Diary Entries
  1654. Your diary file can have entries based on Hebrew or Islamic dates, as
  1655. well as entries based on the world-standard Gregorian calendar.
  1656. However, because recognition of such entries is time-consuming and most
  1657. people don't use them, you must explicitly enable their use. If you
  1658. want the diary to recognize Hebrew-date diary entries, for example,
  1659. you must do this:
  1660. @vindex nongregorian-diary-listing-hook
  1661. @vindex nongregorian-diary-marking-hook
  1662. @findex list-hebrew-diary-entries
  1663. @findex mark-hebrew-diary-entries
  1664. @smallexample
  1665. (add-hook 'nongregorian-diary-listing-hook 'list-hebrew-diary-entries)
  1666. (add-hook 'nongregorian-diary-marking-hook 'mark-hebrew-diary-entries)
  1667. @end smallexample
  1668. @noindent
  1669. If you want Islamic-date entries, do this:
  1670. @findex list-islamic-diary-entries
  1671. @findex mark-islamic-diary-entries
  1672. @smallexample
  1673. (add-hook 'nongregorian-diary-listing-hook 'list-islamic-diary-entries)
  1674. (add-hook 'nongregorian-diary-marking-hook 'mark-islamic-diary-entries)
  1675. @end smallexample
  1676. Hebrew- and Islamic-date diary entries have the same formats as
  1677. Gregorian-date diary entries, except that @samp{H} precedes a Hebrew
  1678. date and @samp{I} precedes an Islamic date. Moreover, because the
  1679. Hebrew and Islamic month names are not uniquely specified by the first
  1680. three letters, you may not abbreviate them. For example, a diary entry
  1681. for the Hebrew date Heshvan 25 could look like this:
  1682. @smallexample
  1683. HHeshvan 25 Happy Hebrew birthday!
  1684. @end smallexample
  1685. @noindent
  1686. and would appear in the diary for any date that corresponds to Heshvan 25
  1687. on the Hebrew calendar. And here is Islamic-date diary entry that matches
  1688. Dhu al-Qada 25:
  1689. @smallexample
  1690. IDhu al-Qada 25 Happy Islamic birthday!
  1691. @end smallexample
  1692. @noindent
  1693. and would appear in the diary for any date that corresponds to Dhu al-Qada 25
  1694. on the Islamic calendar.
  1695. As with Gregorian-date diary entries, Hebrew- and Islamic-date entries
  1696. are nonmarking if they are preceded with an ampersand (@samp{&}).
  1697. Here is a table of commands used in the calendar to create diary entries
  1698. that match the selected date and other dates that are similar in the Hebrew
  1699. or Islamic calendar:
  1700. @table @kbd
  1701. @item i h d
  1702. Add a diary entry for the Hebrew date corresponding to the selected date
  1703. (@code{insert-hebrew-diary-entry}).
  1704. @item i h m
  1705. Add a diary entry for the day of the Hebrew month corresponding to the
  1706. selected date (@code{insert-monthly-hebrew-diary-entry}). This diary
  1707. entry matches any date that has the same Hebrew day-within-month as the
  1708. selected date.
  1709. @item i h y
  1710. Add a diary entry for the day of the Hebrew year corresponding to the
  1711. selected date (@code{insert-yearly-hebrew-diary-entry}). This diary
  1712. entry matches any date which has the same Hebrew month and day-within-month
  1713. as the selected date.
  1714. @item i i d
  1715. Add a diary entry for the Islamic date corresponding to the selected date
  1716. (@code{insert-islamic-diary-entry}).
  1717. @item i i m
  1718. Add a diary entry for the day of the Islamic month corresponding to the
  1719. selected date (@code{insert-monthly-islamic-diary-entry}).
  1720. @item i i y
  1721. Add a diary entry for the day of the Islamic year corresponding to the
  1722. selected date (@code{insert-yearly-islamic-diary-entry}).
  1723. @end table
  1724. @findex insert-hebrew-diary-entry
  1725. @findex insert-monthly-hebrew-diary-entry
  1726. @findex insert-yearly-hebrew-diary-entry
  1727. @findex insert-islamic-diary-entry
  1728. @findex insert-monthly-islamic-diary-entry
  1729. @findex insert-yearly-islamic-diary-entry
  1730. These commands work much like the corresponding commands for ordinary
  1731. diary entries: they apply to the date that point is on in the calendar
  1732. window, and what they do is insert just the date portion of a diary entry
  1733. at the end of your diary file. You must then insert the rest of the
  1734. diary entry.
  1735. @node Fancy Diary Display
  1736. @subsubsection Fancy Diary Display
  1737. @vindex diary-display-hook
  1738. @findex simple-diary-display
  1739. Diary display works by preparing the diary buffer and then running the
  1740. hook @code{diary-display-hook}. The default value of this hook
  1741. (@code{simple-diary-display}) hides the irrelevant diary entries and
  1742. then displays the buffer. However, if you specify the hook as follows,
  1743. @cindex diary buffer
  1744. @findex fancy-diary-display
  1745. @example
  1746. (add-hook 'diary-display-hook 'fancy-diary-display)
  1747. @end example
  1748. @noindent
  1749. this enables fancy diary display. It displays diary entries and
  1750. holidays by copying them into a special buffer that exists only for the
  1751. sake of display. Copying to a separate buffer provides an opportunity
  1752. to change the displayed text to make it prettier---for example, to sort
  1753. the entries by the dates they apply to.
  1754. As with simple diary display, you can print a hard copy of the buffer
  1755. with @code{print-diary-entries}. To print a hard copy of a day-by-day
  1756. diary for a week by positioning point on Sunday of that week, type
  1757. @kbd{7 d} and then do @kbd{M-x print-diary-entries}. As usual, the
  1758. inclusion of the holidays slows down the display slightly; you can speed
  1759. things up by setting the variable @code{holidays-in-diary-buffer} to
  1760. @code{nil}.
  1761. @vindex diary-list-include-blanks
  1762. Ordinarily, the fancy diary buffer does not show days for which there are
  1763. no diary entries, even if that day is a holiday. If you want such days to be
  1764. shown in the fancy diary buffer, set the variable
  1765. @code{diary-list-include-blanks} to @code{t}.@refill
  1766. @cindex sorting diary entries
  1767. If you use the fancy diary display, you can use the normal hook
  1768. @code{list-diary-entries-hook} to sort each day's diary entries by their
  1769. time of day. Add this line to your init file:
  1770. @findex sort-diary-entries
  1771. @example
  1772. (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
  1773. @end example
  1774. @xref{Init File}.
  1775. @noindent
  1776. For each day, this sorts diary entries that begin with a recognizable
  1777. time of day according to their times. Diary entries without times come
  1778. first within each day.
  1779. @node Included Diary Files
  1780. @subsubsection Included Diary Files
  1781. Fancy diary display also has the ability to process included diary
  1782. files. This permits a group of people to share a diary file for events
  1783. that apply to all of them. Lines in the diary file of this form:
  1784. @smallexample
  1785. #include "@var{filename}"
  1786. @end smallexample
  1787. @noindent
  1788. includes the diary entries from the file @var{filename} in the fancy
  1789. diary buffer. The include mechanism is recursive, so that included files
  1790. can include other files, and so on; you must be careful not to have a
  1791. cycle of inclusions, of course. Here is how to enable the include
  1792. facility:
  1793. @vindex list-diary-entries-hook
  1794. @vindex mark-diary-entries-hook
  1795. @findex include-other-diary-files
  1796. @findex mark-included-diary-files
  1797. @smallexample
  1798. (add-hook 'list-diary-entries-hook 'include-other-diary-files)
  1799. (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
  1800. @end smallexample
  1801. The include mechanism works only with the fancy diary display, because
  1802. ordinary diary display shows the entries directly from your diary file.
  1803. @node Sexp Diary Entries
  1804. @subsubsection Sexp Entries and the Fancy Diary Display
  1805. @cindex sexp diary entries
  1806. Sexp diary entries allow you to do more than just have complicated
  1807. conditions under which a diary entry applies. If you use the fancy
  1808. diary display, sexp entries can generate the text of the entry depending
  1809. on the date itself. For example, an anniversary diary entry can insert
  1810. the number of years since the anniversary date into the text of the
  1811. diary entry. Thus the @samp{%d} in this dairy entry:
  1812. @findex diary-anniversary
  1813. @smallexample
  1814. %%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old)
  1815. @end smallexample
  1816. @noindent
  1817. gets replaced by the age, so on October 31, 1990 the entry appears in
  1818. the fancy diary buffer like this:
  1819. @smallexample
  1820. Arthur's birthday (42 years old)
  1821. @end smallexample
  1822. @noindent
  1823. If the diary file instead contains this entry:
  1824. @smallexample
  1825. %%(diary-anniversary 10 31 1948) Arthur's %d%s birthday
  1826. @end smallexample
  1827. @noindent
  1828. the entry in the fancy diary buffer for October 31, 1990 appears like this:
  1829. @smallexample
  1830. Arthur's 42nd birthday
  1831. @end smallexample
  1832. Similarly, cyclic diary entries can interpolate the number of repetitions
  1833. that have occurred:
  1834. @findex diary-cyclic
  1835. @smallexample
  1836. %%(diary-cyclic 50 1 1 1990) Renew medication (%d%s time)
  1837. @end smallexample
  1838. @noindent
  1839. looks like this:
  1840. @smallexample
  1841. Renew medication (5th time)
  1842. @end smallexample
  1843. @noindent
  1844. in the fancy diary display on September 8, 1990.
  1845. The generality of sexp diary entries lets you specify any diary entry
  1846. that you can describe algorithmically. A sexp diary entry contains an
  1847. expression that computes whether the entry applies to any given date.
  1848. If its value is non-@code{nil}, the entry applies to that date;
  1849. otherwise, it does not. The expression can use the variable @code{date}
  1850. to find the date being considered; its value is a list (@var{month}
  1851. @var{day} @var{year}) that refers to the Gregorian calendar.
  1852. Suppose you get paid on the 21st of the month if it is a weekday, and
  1853. on the Friday before if the 21st is on a weekend. Here is how to write
  1854. a sexp diary entry that matches those dates:
  1855. @smallexample
  1856. &%%(let ((dayname (calendar-day-of-week date))
  1857. (day (car (cdr date))))
  1858. (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
  1859. (and (memq day '(19 20)) (= dayname 5)))
  1860. ) Pay check deposited
  1861. @end smallexample
  1862. @noindent
  1863. applies to just those dates. This example illustrates how the sexp can
  1864. depend on the variable @code{date}; this variable is a list (@var{month}
  1865. @var{day} @var{year}) that gives the Gregorian date for which the diary
  1866. entries are being found. If the value of the expression is @code{t},
  1867. the entry applies to that date. If the expression evaluates to
  1868. @code{nil}, the entry does @emph{not} apply to that date.
  1869. The following sexp diary entries take advantage of the ability (in the fancy
  1870. diary display) to concoct diary entries whose text varies based on the date:
  1871. @findex diary-sunrise-sunset
  1872. @findex diary-phases-of-moon
  1873. @findex diary-day-of-year
  1874. @findex diary-iso-date
  1875. @findex diary-julian-date
  1876. @findex diary-astro-day-number
  1877. @findex diary-hebrew-date
  1878. @findex diary-islamic-date
  1879. @findex diary-french-date
  1880. @findex diary-mayan-date
  1881. @table @code
  1882. @item %%(diary-sunrise-sunset)
  1883. Make a diary entry for the local times of today's sunrise and sunset.
  1884. @item %%(diary-phases-of-moon)
  1885. Make a diary entry for the phases (quarters) of the moon.
  1886. @item %%(diary-day-of-year)
  1887. Make a diary entry with today's day number in the current year and the number
  1888. of days remaining in the current year.
  1889. @item %%(diary-iso-date)
  1890. Make a diary entry with today's equivalent ISO commercial date.
  1891. @item %%(diary-julian-date)
  1892. Make a diary entry with today's equivalent date on the Julian calendar.
  1893. @item %%(diary-astro-day-number)
  1894. Make a diary entry with today's equivalent astronomical (Julian) day number.
  1895. @item %%(diary-hebrew-date)
  1896. Make a diary entry with today's equivalent date on the Hebrew calendar.
  1897. @item %%(diary-islamic-date)
  1898. Make a diary entry with today's equivalent date on the Islamic calendar.
  1899. @item %%(diary-french-date)
  1900. Make a diary entry with today's equivalent date on the French Revolutionary
  1901. calendar.
  1902. @item %%(diary-mayan-date)
  1903. Make a diary entry with today's equivalent date on the Mayan calendar.
  1904. @end table
  1905. @noindent
  1906. Thus including the diary entry
  1907. @smallexample
  1908. &%%(diary-hebrew-date)
  1909. @end smallexample
  1910. @noindent
  1911. causes every day's diary display to contain the equivalent date on the
  1912. Hebrew calendar, if you are using the fancy diary display. (With simple
  1913. diary display, the line @samp{&%%(diary-hebrew-date)} appears in the
  1914. diary for any date, but does nothing particularly useful.)
  1915. These functions can be used to construct sexp diary entries based on
  1916. the Hebrew calendar in certain standard ways:
  1917. @cindex rosh hodesh
  1918. @findex diary-rosh-hodesh
  1919. @cindex parasha, weekly
  1920. @findex diary-parasha
  1921. @cindex candle lighting times
  1922. @findex diary-sabbath-candles
  1923. @cindex omer count
  1924. @findex diary-omer
  1925. @cindex yahrzeits
  1926. @findex diary-yahrzeit
  1927. @table @code
  1928. @item %%(diary-rosh-hodesh)
  1929. Make a diary entry that tells the occurrence and ritual announcement of each
  1930. new Hebrew month.
  1931. @item %%(diary-parasha)
  1932. Make a Saturday diary entry that tells the weekly synagogue scripture reading.
  1933. @item %%(diary-sabbath-candles)
  1934. Make a Friday diary entry that tells the @emph{local time} of Sabbath
  1935. candle lighting.
  1936. @item %%(diary-omer)
  1937. Make a diary entry that gives the omer count, when appropriate.
  1938. @item %%(diary-yahrzeit @var{month} @var{day} @var{year}) @var{name}
  1939. Make a diary entry marking the anniversary of a date of death. The date
  1940. is the @emph{Gregorian} (civil) date of death. The diary entry appears
  1941. on the proper Hebrew calendar anniversary and on the day before. (In
  1942. the European style, the order of the parameters is changed to @var{day},
  1943. @var{month}, @var{year}.)
  1944. @end table
  1945. @node Appt Customizing
  1946. @subsubsection Customizing Appointment Reminders
  1947. You can specify exactly how Emacs reminds you of an appointment, and
  1948. how far in advance it begins doing so, by setting these variables:
  1949. @vindex appt-message-warning-time
  1950. @vindex appt-audible
  1951. @vindex appt-visible
  1952. @vindex appt-display-mode-line
  1953. @vindex appt-msg-window
  1954. @vindex appt-display-duration
  1955. @table @code
  1956. @item appt-message-warning-time
  1957. The time in minutes before an appointment that the reminder begins. The
  1958. default is 10 minutes.
  1959. @item appt-audible
  1960. If this is @code{t} (the default), Emacs rings the terminal bell for
  1961. appointment reminders.
  1962. @item appt-visible
  1963. If this is @code{t} (the default), Emacs displays the appointment
  1964. message in echo area.
  1965. @item appt-display-mode-line
  1966. If this is @code{t} (the default), Emacs displays the number of minutes
  1967. to the appointment on the mode line.
  1968. @item appt-msg-window
  1969. If this is @code{t} (the default), Emacs displays the appointment
  1970. message in another window.
  1971. @item appt-display-duration
  1972. The number of seconds an appointment message is displayed. The default
  1973. is 5 seconds.
  1974. @end table