1 ;;; diary-lib.el --- diary functions.
3 ;; Copyright (C) 1989, 1990, 1992, 1993, 1994, 1995 Free Software Foundation,
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;; This collection of functions implements the diary features as described
30 ;; Comments, corrections, and improvements should be sent to
31 ;; Edward M. Reingold Department of Computer Science
32 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
33 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
34 ;; Urbana, Illinois 61801
41 (defun diary (&optional arg)
42 "Generate the diary window for ARG days starting with the current date.
43 If no argument is provided, the number of days of diary entries is governed
44 by the variable `number-of-diary-entries'. This function is suitable for
45 execution in a `.emacs' file."
47 (let ((d-file (substitute-in-file-name diary-file))
48 (date (calendar-current-date)))
49 (if (and d-file (file-exists-p d-file))
50 (if (file-readable-p d-file)
54 (arg (prefix-numeric-value arg))
55 ((vectorp number-of-diary-entries)
56 (aref number-of-diary-entries (calendar-day-of-week date)))
57 (t number-of-diary-entries)))
58 (error "Your diary file is not readable!"))
59 (error "You don't have a diary file!"))))
61 (defun view-diary-entries (arg)
62 "Prepare and display a buffer with diary entries.
63 Searches the file named in `diary-file' for entries that
64 match ARG days starting with the date indicated by the cursor position
65 in the displayed three-month calendar."
67 (let ((d-file (substitute-in-file-name diary-file)))
68 (if (and d-file (file-exists-p d-file))
69 (if (file-readable-p d-file)
70 (list-diary-entries (calendar-cursor-to-date t) arg)
71 (error "Diary file is not readable!"))
72 (error "You don't have a diary file!"))))
74 (defun view-other-diary-entries (arg diary-file)
75 "Prepare and display buffer of diary entries from an alternative diary file.
76 Prompts for a file name and searches that file for entries that match ARG
77 days starting with the date indicated by the cursor position in the displayed
78 three-month calendar."
80 (list (cond ((null current-prefix-arg) 1)
81 ((listp current-prefix-arg) (car current-prefix-arg))
82 (t current-prefix-arg))
83 (setq diary-file (read-file-name "Enter diary file name: "
84 default-directory nil t))))
85 (view-diary-entries arg))
87 (autoload 'check-calendar-holidays "holidays"
88 "Check the list of holidays for any that occur on DATE.
89 The value returned is a list of strings of relevant holiday descriptions.
90 The holidays are those in the list `calendar-holidays'."
93 (autoload 'calendar-holiday-list "holidays"
94 "Form the list of holidays that occur on dates in the calendar window.
95 The holidays are those in the list `calendar-holidays'."
98 (autoload 'diary-french-date "cal-french"
99 "French calendar equivalent of date diary entry."
102 (autoload 'diary-mayan-date "cal-mayan"
103 "Mayan calendar equivalent of date diary entry."
106 (autoload 'diary-iso-date "cal-iso"
107 "ISO calendar equivalent of date diary entry."
110 (autoload 'diary-julian-date "cal-julian"
111 "Julian calendar equivalent of date diary entry."
114 (autoload 'diary-astro-day-number "cal-julian"
115 "Astronomical (Julian) day number diary entry."
118 (autoload 'diary-chinese-date "cal-chinese"
119 "Chinese calendar equivalent of date diary entry."
122 (autoload 'diary-islamic-date "cal-islamic"
123 "Islamic calendar equivalent of date diary entry."
126 (autoload 'list-islamic-diary-entries "cal-islamic"
127 "Add any Islamic date entries from the diary file to `diary-entries-list'."
130 (autoload 'mark-islamic-diary-entries "cal-islamic"
131 "Mark days in the calendar window that have Islamic date diary entries."
134 (autoload 'mark-islamic-calendar-date-pattern "cal-islamic"
135 "Mark dates in calendar window that conform to Islamic date MONTH/DAY/YEAR."
138 (autoload 'diary-hebrew-date "cal-hebrew"
139 "Hebrew calendar equivalent of date diary entry."
142 (autoload 'diary-omer "cal-hebrew"
143 "Omer count diary entry."
146 (autoload 'diary-yahrzeit "cal-hebrew"
147 "Yahrzeit diary entry--entry applies if date is yahrzeit or the day before."
150 (autoload 'diary-parasha "cal-hebrew"
151 "Parasha diary entry--entry applies if date is a Saturday."
154 (autoload 'diary-rosh-hodesh "cal-hebrew"
155 "Rosh Hodesh diary entry."
158 (autoload 'list-hebrew-diary-entries "cal-hebrew"
159 "Add any Hebrew date entries from the diary file to `diary-entries-list'."
162 (autoload 'mark-hebrew-diary-entries "cal-hebrew"
163 "Mark days in the calendar window that have Hebrew date diary entries."
166 (autoload 'mark-hebrew-calendar-date-pattern "cal-hebrew"
167 "Mark dates in calendar window that conform to Hebrew date MONTH/DAY/YEAR."
170 (autoload 'diary-coptic-date "cal-coptic"
171 "Coptic calendar equivalent of date diary entry."
174 (autoload 'diary-ethiopic-date "cal-coptic"
175 "Ethiopic calendar equivalent of date diary entry."
178 (autoload 'diary-phases-of-moon "lunar" "Moon phases diary entry." t)
180 (autoload 'diary-sunrise-sunset "solar"
181 "Local time of sunrise and sunset as a diary entry."
184 (autoload 'diary-sabbath-candles "solar"
185 "Local time of candle lighting diary entry--applies if date is a Friday.
186 No diary entry if there is no sunset on that date."
189 (defvar diary-syntax-table (copy-syntax-table (standard-syntax-table))
190 "The syntax table used when parsing dates in the diary file.
191 It is the standard syntax table used in Fundamental mode, but with the
192 syntax of `*' changed to be a word constituent.")
194 (modify-syntax-entry ?* "w" diary-syntax-table)
196 (defun list-diary-entries (date number)
197 "Create and display a buffer containing the relevant lines in diary-file.
198 The arguments are DATE and NUMBER; the entries selected are those
199 for NUMBER days starting with date DATE. The other entries are hidden
200 using selective display.
202 Returns a list of all relevant diary entries found, if any, in order by date.
203 The list entries have the form ((month day year) string). If the variable
204 `diary-list-include-blanks' is t, this list includes a dummy diary entry
205 \(consisting of the empty string) for a date with no diary entries.
207 After the list is prepared, the hooks `nongregorian-diary-listing-hook',
208 `list-diary-entries-hook', `diary-display-hook', and `diary-hook' are run.
209 These hooks have the following distinct roles:
211 `nongregorian-diary-listing-hook' can cull dates from the diary
212 and each included file. Usually used for Hebrew or Islamic
213 diary entries in files. Applied to *each* file.
215 `list-diary-entries-hook' adds or manipulates diary entries from
216 external sources. Used, for example, to include diary entries
217 from other files or to sort the diary entries. Invoked *once* only,
218 before the display hook is run.
220 `diary-display-hook' does the actual display of information. If this is
221 nil, simple-diary-display will be used. Use add-hook to set this to
222 fancy-diary-display, if desired. If you want no diary display, use
223 add-hook to set this to ignore.
225 `diary-hook' is run last. This can be used for an appointment
226 notification function."
229 (let* ((original-date date);; save for possible use in the hooks
230 (old-diary-syntax-table)
232 (date-string (calendar-date-string date))
233 (d-file (substitute-in-file-name diary-file)))
234 (message "Preparing diary...")
236 (let ((diary-buffer (find-buffer-visiting d-file)))
237 (set-buffer (if diary-buffer
239 (find-file-noselect d-file t))))
240 (setq selective-display t)
241 (setq selective-display-ellipses nil)
242 (setq old-diary-syntax-table (syntax-table))
243 (set-syntax-table diary-syntax-table)
245 (let ((buffer-read-only nil)
246 (diary-modified (buffer-modified-p))
247 (mark (regexp-quote diary-nonmarking-symbol)))
248 (goto-char (1- (point-max)))
249 (if (not (looking-at "\^M\\|\n"))
252 (insert-string "\^M")))
253 (goto-char (point-min))
254 (if (not (looking-at "\^M\\|\n"))
255 (insert-string "\^M"))
256 (subst-char-in-region (point-min) (point-max) ?\n ?\^M t)
257 (calendar-for-loop i from 1 to number do
258 (let ((d diary-date-forms)
259 (month (extract-calendar-month date))
260 (day (extract-calendar-day date))
261 (year (extract-calendar-year date))
262 (entry-found (list-sexp-diary-entries date)))
265 ((date-form (if (equal (car (car d)) 'backup)
268 (backup (equal (car (car d)) 'backup))
271 (calendar-day-name date) "\\|"
272 (substring (calendar-day-name date) 0 3) ".?"))
276 (calendar-month-name month) "\\|"
277 (substring (calendar-month-name month) 0 3) ".?"))
278 (month (concat "\\*\\|0*" (int-to-string month)))
279 (day (concat "\\*\\|0*" (int-to-string day)))
282 "\\*\\|0*" (int-to-string year)
283 (if abbreviated-calendar-year
284 (concat "\\|" (int-to-string (% year 100)))
288 "\\(\\`\\|\^M\\|\n\\)" mark "?\\("
289 (mapconcat 'eval date-form "\\)\\(")
291 (case-fold-search t))
292 (goto-char (point-min))
293 (while (re-search-forward regexp nil t)
294 (if backup (re-search-backward "\\<" nil t))
295 (if (and (or (char-equal (preceding-char) ?\^M)
296 (char-equal (preceding-char) ?\n))
297 (not (looking-at " \\|\^I")))
298 ;; Diary entry that consists only of date.
300 ;; Found a nonempty diary entry--make it visible and
301 ;; add it to the list.
303 (let ((entry-start (point))
305 (re-search-backward "\^M\\|\n\\|\\`")
306 (setq date-start (point))
307 (re-search-forward "\^M\\|\n" nil t 2)
308 (while (looking-at " \\|\^I")
309 (re-search-forward "\^M\\|\n" nil t))
311 (subst-char-in-region date-start
315 (buffer-substring-no-properties
316 entry-start (point)))))))
319 (not diary-list-include-blanks)
320 (setq diary-entries-list
321 (append diary-entries-list
322 (list (list date "")))))
324 (calendar-gregorian-from-absolute
325 (1+ (calendar-absolute-from-gregorian date))))
326 (setq entry-found nil)))
327 (set-buffer-modified-p diary-modified))
328 (set-syntax-table old-diary-syntax-table))
329 (goto-char (point-min))
330 (run-hooks 'nongregorian-diary-listing-hook
331 'list-diary-entries-hook)
332 (if diary-display-hook
333 (run-hooks 'diary-display-hook)
334 (simple-diary-display))
335 (run-hooks 'diary-hook)
336 diary-entries-list))))
338 (defun include-other-diary-files ()
339 "Include the diary entries from other diary files with those of diary-file.
340 This function is suitable for use in `list-diary-entries-hook';
341 it enables you to use shared diary files together with your own.
342 The files included are specified in the diaryfile by lines of this form:
343 #include \"filename\"
344 This is recursive; that is, #include directives in diary files thus included
345 are obeyed. You can change the `#include' to some other string by
346 changing the variable `diary-include-string'."
347 (goto-char (point-min))
348 (while (re-search-forward
350 "\\(\\`\\|\^M\\|\n\\)"
351 (regexp-quote diary-include-string)
354 (let ((diary-file (substitute-in-file-name
355 (buffer-substring-no-properties
356 (match-beginning 2) (match-end 2))))
357 (diary-list-include-blanks nil)
358 (list-diary-entries-hook 'include-other-diary-files)
359 (diary-display-hook 'ignore)
361 (if (file-exists-p diary-file)
362 (if (file-readable-p diary-file)
364 (setq diary-entries-list
365 (append diary-entries-list
366 (list-diary-entries original-date number)))
367 (kill-buffer (find-buffer-visiting diary-file)))
369 (message "Can't read included diary file %s" diary-file)
372 (message "Can't find included diary file %s" diary-file)
374 (goto-char (point-min)))
376 (defun simple-diary-display ()
377 "Display the diary buffer if there are any relevant entries or holidays."
378 (let* ((holiday-list (if holidays-in-diary-buffer
379 (check-calendar-holidays original-date)))
380 (msg (format "No diary entries for %s %s"
381 (concat date-string (if holiday-list ":" ""))
382 (mapconcat 'identity holiday-list "; "))))
383 (if (or (not diary-entries-list)
384 (and (not (cdr diary-entries-list))
385 (string-equal (car (cdr (car diary-entries-list))) "")))
386 (if (<= (length msg) (frame-width))
388 (set-buffer (get-buffer-create holiday-buffer))
389 (setq buffer-read-only nil)
390 (calendar-set-mode-line date-string)
392 (insert (mapconcat 'identity holiday-list "\n"))
393 (goto-char (point-min))
394 (set-buffer-modified-p nil)
395 (setq buffer-read-only t)
396 (display-buffer holiday-buffer)
397 (message "No diary entries for %s" date-string))
398 (calendar-set-mode-line
399 (concat "Diary for " date-string
400 (if holiday-list ": " "")
401 (mapconcat 'identity holiday-list "; ")))
402 (display-buffer (find-buffer-visiting d-file))
403 (message "Preparing diary...done"))))
405 (defun fancy-diary-display ()
406 "Prepare a diary buffer with relevant entries in a fancy, noneditable form.
407 This function is provided for optional use as the `diary-display-hook'."
408 (save-excursion;; Turn off selective-display in the diary file's buffer.
409 (set-buffer (find-buffer-visiting (substitute-in-file-name diary-file)))
410 (let ((diary-modified (buffer-modified-p)))
411 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)
412 (setq selective-display nil)
413 (kill-local-variable 'mode-line-format)
414 (set-buffer-modified-p diary-modified)))
415 (if (or (not diary-entries-list)
416 (and (not (cdr diary-entries-list))
417 (string-equal (car (cdr (car diary-entries-list))) "")))
418 (let* ((holiday-list (if holidays-in-diary-buffer
419 (check-calendar-holidays original-date)))
420 (msg (format "No diary entries for %s %s"
421 (concat date-string (if holiday-list ":" ""))
422 (mapconcat 'identity holiday-list "; "))))
423 (if (<= (length msg) (frame-width))
425 (set-buffer (get-buffer-create holiday-buffer))
426 (setq buffer-read-only nil)
427 (calendar-set-mode-line date-string)
429 (insert (mapconcat 'identity holiday-list "\n"))
430 (goto-char (point-min))
431 (set-buffer-modified-p nil)
432 (setq buffer-read-only t)
433 (display-buffer holiday-buffer)
434 (message "No diary entries for %s" date-string)))
435 (save-excursion;; Prepare the fancy diary buffer.
436 (set-buffer (make-fancy-diary-buffer))
437 (setq buffer-read-only nil)
438 (let ((entry-list diary-entries-list)
440 (holiday-list-last-month 1)
441 (holiday-list-last-year 1)
444 (if (not (calendar-date-equal date (car (car entry-list))))
446 (setq date (car (car entry-list)))
447 (and holidays-in-diary-buffer
448 (calendar-date-compare
449 (list (list holiday-list-last-month
450 (calendar-last-day-of-month
451 holiday-list-last-month
452 holiday-list-last-year)
453 holiday-list-last-year))
455 ;; We need to get the holidays for the next 3 months.
456 (setq holiday-list-last-month
457 (extract-calendar-month date))
458 (setq holiday-list-last-year
459 (extract-calendar-year date))
460 (increment-calendar-month
461 holiday-list-last-month holiday-list-last-year 1)
463 (let ((displayed-month holiday-list-last-month)
464 (displayed-year holiday-list-last-year))
465 (calendar-holiday-list)))
466 (increment-calendar-month
467 holiday-list-last-month holiday-list-last-year 1))
468 (let* ((date-string (calendar-date-string date))
470 (let ((h holiday-list)
472 ;; Make a list of all holidays for date.
474 (if (calendar-date-equal date (car (car h)))
475 (setq d (append d (cdr (car h)))))
478 (insert (if (= (point) (point-min)) "" ?\n) date-string)
479 (if date-holiday-list (insert ": "))
480 (let ((l (current-column)))
481 (insert (mapconcat 'identity date-holiday-list
482 (concat "\n" (make-string l ? )))))
483 (let ((l (current-column)))
484 (insert ?\n (make-string l ?=) ?\n)))))
485 (if (< 0 (length (car (cdr (car entry-list)))))
486 (insert (car (cdr (car entry-list))) ?\n))
487 (setq entry-list (cdr entry-list))))
488 (set-buffer-modified-p nil)
489 (goto-char (point-min))
490 (setq buffer-read-only t)
491 (display-buffer fancy-diary-buffer)
492 (message "Preparing diary...done"))))
494 (defun make-fancy-diary-buffer ()
495 "Create and return the initial fancy diary buffer."
497 (set-buffer (get-buffer-create fancy-diary-buffer))
498 (setq buffer-read-only nil)
499 (make-local-variable 'mode-line-format)
500 (calendar-set-mode-line "Diary Entries")
502 (set-buffer-modified-p nil)
503 (setq buffer-read-only t)
504 (get-buffer fancy-diary-buffer)))
506 (defun print-diary-entries ()
507 "Print a hard copy of the diary display.
509 If the simple diary display is being used, prepare a temp buffer with the
510 visible lines of the diary buffer, add a heading line composed from the mode
511 line, print the temp buffer, and destroy it.
513 If the fancy diary display is being used, just print the buffer.
515 The hooks given by the variable `print-diary-entries-hook' are called to do
516 the actual printing."
518 (if (bufferp (get-buffer fancy-diary-buffer))
520 (set-buffer (get-buffer fancy-diary-buffer))
521 (run-hooks 'print-diary-entries-hook))
523 (find-buffer-visiting (substitute-in-file-name diary-file))))
525 (let ((temp-buffer (get-buffer-create "*Printable Diary Entries*"))
528 (set-buffer diary-buffer)
530 (if (not (stringp mode-line-format))
532 (string-match "^-*\\([^-].*[^-]\\)-*$" mode-line-format)
533 (substring mode-line-format
534 (match-beginning 1) (match-end 1))))
535 (copy-to-buffer temp-buffer (point-min) (point-max))
536 (set-buffer temp-buffer)
537 (while (re-search-forward "\^M.*$" nil t)
539 (goto-char (point-min))
541 (make-string (length heading) ?=) "\n")
542 (run-hooks 'print-diary-entries-hook)
543 (kill-buffer temp-buffer)))
544 (error "You don't have a diary buffer!")))))
546 (defun show-all-diary-entries ()
547 "Show all of the diary entries in the diary file.
548 This function gets rid of the selective display of the diary file so that
549 all entries, not just some, are visible. If there is no diary buffer, one
552 (let ((d-file (substitute-in-file-name diary-file)))
553 (if (and d-file (file-exists-p d-file))
554 (if (file-readable-p d-file)
556 (let ((diary-buffer (find-buffer-visiting d-file)))
557 (set-buffer (if diary-buffer
559 (find-file-noselect d-file t)))
560 (let ((buffer-read-only nil)
561 (diary-modified (buffer-modified-p)))
562 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)
563 (setq selective-display nil)
564 (make-local-variable 'mode-line-format)
565 (setq mode-line-format default-mode-line-format)
566 (display-buffer (current-buffer))
567 (set-buffer-modified-p diary-modified))))
568 (error "Your diary file is not readable!"))
569 (error "You don't have a diary file!"))))
571 (defun diary-name-pattern (string-array &optional fullname)
572 "Convert an STRING-ARRAY, an array of strings to a pattern.
573 The pattern will match any of the strings, either entirely or abbreviated
574 to three characters. An abbreviated form will match with or without a period;
575 If the optional FULLNAME is t, abbreviations will not match, just the full
578 (calendar-for-loop i from 0 to (1- (length string-array)) do
582 (if (string-equal pattern "") "" "\\|")
583 (aref string-array i)
588 (substring (aref string-array i) 0 3) ".?")))))
591 (defvar marking-diary-entries nil
592 "True during the marking of diary entries, nil otherwise.")
594 (defvar marking-diary-entry nil
595 "True during the marking of diary entries, if current entry is marking.")
597 (defun mark-diary-entries ()
598 "Mark days in the calendar window that have diary entries.
599 Each entry in the diary file visible in the calendar window is marked.
600 After the entries are marked, the hooks `nongregorian-diary-marking-hook' and
601 `mark-diary-entries-hook' are run."
603 (setq mark-diary-entries-in-calendar t)
604 (let ((d-file (substitute-in-file-name diary-file))
605 (marking-diary-entries t))
606 (if (and d-file (file-exists-p d-file))
607 (if (file-readable-p d-file)
609 (message "Marking diary entries...")
610 (set-buffer (find-file-noselect d-file t))
611 (let ((d diary-date-forms)
612 (old-diary-syntax-table))
613 (setq old-diary-syntax-table (syntax-table))
614 (set-syntax-table diary-syntax-table)
617 ((date-form (if (equal (car (car d)) 'backup)
619 (car d)));; ignore 'backup directive
620 (dayname (diary-name-pattern calendar-day-name-array))
623 (diary-name-pattern calendar-month-name-array)
625 (month "[0-9]+\\|\\*")
627 (year "[0-9]+\\|\\*")
628 (l (length date-form))
629 (d-name-pos (- l (length (memq 'dayname date-form))))
630 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
631 (m-name-pos (- l (length (memq 'monthname date-form))))
632 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
633 (d-pos (- l (length (memq 'day date-form))))
634 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
635 (m-pos (- l (length (memq 'month date-form))))
636 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
637 (y-pos (- l (length (memq 'year date-form))))
638 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
641 "\\(\\`\\|\^M\\|\n\\)\\("
642 (mapconcat 'eval date-form "\\)\\(")
644 (case-fold-search t))
645 (goto-char (point-min))
646 (while (re-search-forward regexp nil t)
649 (buffer-substring-no-properties
650 (match-beginning d-name-pos)
651 (match-end d-name-pos))))
654 (buffer-substring-no-properties
655 (match-beginning m-name-pos)
656 (match-end m-name-pos))))
659 (buffer-substring-no-properties
660 (match-beginning m-pos)
665 (buffer-substring-no-properties
666 (match-beginning d-pos)
670 (buffer-substring-no-properties
671 (match-beginning y-pos)
675 (if (and (= (length y-str) 2)
676 abbreviated-calendar-year)
678 (extract-calendar-year
679 (calendar-current-date)))
680 (y (+ (string-to-int y-str)
682 (/ current-y 100)))))
683 (if (> (- y current-y) 50)
685 (if (> (- current-y y) 50)
688 (string-to-int y-str)))))
690 (mark-calendar-days-named
691 (cdr (assoc (capitalize (substring dd-name 0 3))
693 calendar-day-name-array
695 '(lambda (x) (substring x 0 3))))))
697 (if (string-equal mm-name "*")
702 (substring mm-name 0 3))
704 calendar-month-name-array
706 '(lambda (x) (substring x 0 3)))
708 (mark-calendar-date-pattern mm dd yy))))
710 (mark-sexp-diary-entries)
711 (run-hooks 'nongregorian-diary-marking-hook
712 'mark-diary-entries-hook)
713 (set-syntax-table old-diary-syntax-table)
714 (message "Marking diary entries...done")))
715 (error "Your diary file is not readable!"))
716 (error "You don't have a diary file!"))))
718 (defun mark-sexp-diary-entries ()
719 "Mark days in the calendar window that have sexp diary entries.
720 Each entry in the diary file (or included files) visible in the calendar window
721 is marked. See the documentation for the function `list-sexp-diary-entries'."
722 (let* ((sexp-mark (regexp-quote sexp-diary-entry-symbol))
723 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)\\("
724 (regexp-quote sexp-mark) "(\\)\\|\\("
725 (regexp-quote diary-nonmarking-symbol)
726 (regexp-quote sexp-mark) "(diary-remind\\)"))
732 (set-buffer calendar-buffer)
733 (setq m displayed-month)
734 (setq y displayed-year))
735 (increment-calendar-month m y -1)
737 (calendar-absolute-from-gregorian (list m 1 y)))
738 (increment-calendar-month m y 2)
740 (calendar-absolute-from-gregorian
741 (list m (calendar-last-day-of-month m y) y)))
742 (goto-char (point-min))
743 (while (re-search-forward s-entry nil t)
744 (if (char-equal (preceding-char) ?\()
745 (setq marking-diary-entry t)
746 (setq marking-diary-entry nil))
747 (re-search-backward "(")
748 (let ((sexp-start (point))
754 (setq sexp (buffer-substring-no-properties sexp-start (point)))
756 (re-search-backward "\^M\\|\n\\|\\`")
757 (setq line-start (point)))
759 (if (and (or (char-equal (preceding-char) ?\^M)
760 (char-equal (preceding-char) ?\n))
761 (not (looking-at " \\|\^I")))
762 (progn;; Diary entry consists only of the sexp
765 (setq entry-start (point))
766 (re-search-forward "\^M\\|\n" nil t)
767 (while (looking-at " \\|\^I")
768 (re-search-forward "\^M\\|\n" nil t))
770 (setq entry (buffer-substring-no-properties entry-start (point)))
771 (while (string-match "[\^M]" entry)
772 (aset entry (match-beginning 0) ?\n )))
773 (calendar-for-loop date from first-date to last-date do
774 (if (diary-sexp-entry sexp entry
775 (calendar-gregorian-from-absolute date))
776 (mark-visible-calendar-date
777 (calendar-gregorian-from-absolute date))))))))
779 (defun mark-included-diary-files ()
780 "Mark the diary entries from other diary files with those of the diary file.
781 This function is suitable for use as the `mark-diary-entries-hook'; it enables
782 you to use shared diary files together with your own. The files included are
783 specified in the diary-file by lines of this form:
784 #include \"filename\"
785 This is recursive; that is, #include directives in diary files thus included
786 are obeyed. You can change the `#include' to some other string by
787 changing the variable `diary-include-string'."
788 (goto-char (point-min))
789 (while (re-search-forward
791 "\\(\\`\\|\^M\\|\n\\)"
792 (regexp-quote diary-include-string)
795 (let ((diary-file (substitute-in-file-name
796 (buffer-substring-no-properties
797 (match-beginning 2) (match-end 2))))
798 (mark-diary-entries-hook 'mark-included-diary-files))
799 (if (file-exists-p diary-file)
800 (if (file-readable-p diary-file)
803 (kill-buffer (find-buffer-visiting diary-file)))
805 (message "Can't read included diary file %s" diary-file)
808 (message "Can't find included diary file %s" diary-file)
810 (goto-char (point-min)))
812 (defun mark-calendar-days-named (dayname)
813 "Mark all dates in the calendar window that are day DAYNAME of the week.
814 0 means all Sundays, 1 means all Mondays, and so on."
816 (set-buffer calendar-buffer)
817 (let ((prev-month displayed-month)
818 (prev-year displayed-year)
819 (succ-month displayed-month)
820 (succ-year displayed-year)
823 (increment-calendar-month succ-month succ-year 1)
824 (increment-calendar-month prev-month prev-year -1)
825 (setq day (calendar-absolute-from-gregorian
826 (calendar-nth-named-day 1 dayname prev-month prev-year)))
827 (setq last-day (calendar-absolute-from-gregorian
828 (calendar-nth-named-day -1 dayname succ-month succ-year)))
829 (while (<= day last-day)
830 (mark-visible-calendar-date (calendar-gregorian-from-absolute day))
831 (setq day (+ day 7))))))
833 (defun mark-calendar-date-pattern (month day year)
834 "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR.
835 A value of 0 in any position is a wildcard."
837 (set-buffer calendar-buffer)
838 (let ((m displayed-month)
840 (increment-calendar-month m y -1)
841 (calendar-for-loop i from 0 to 2 do
842 (mark-calendar-month m y month day year)
843 (increment-calendar-month m y 1)))))
845 (defun mark-calendar-month (month year p-month p-day p-year)
846 "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR.
847 A value of 0 in any position of the pattern is a wildcard."
848 (if (or (and (= month p-month)
849 (or (= p-year 0) (= year p-year)))
851 (or (= p-year 0) (= year p-year))))
854 i from 1 to (calendar-last-day-of-month month year) do
855 (mark-visible-calendar-date (list month i year)))
856 (mark-visible-calendar-date (list month p-day year)))))
858 (defun sort-diary-entries ()
859 "Sort the list of diary entries by time of day."
860 (setq diary-entries-list (sort diary-entries-list 'diary-entry-compare)))
862 (defun diary-entry-compare (e1 e2)
863 "Returns t if E1 is earlier than E2."
864 (or (calendar-date-compare e1 e2)
865 (and (calendar-date-equal (car e1) (car e2))
866 (< (diary-entry-time (car (cdr e1)))
867 (diary-entry-time (car (cdr e2)))))))
869 (defun diary-entry-time (s)
870 "Time at the beginning of the string S in a military-style integer.
871 For example, returns 1325 for 1:25pm. Returns -9999 if no time is recognized.
872 The recognized forms are XXXX or X:XX or XX:XX (military time), XXam or XXpm,
873 and XX:XXam or XX:XXpm."
874 (cond ((string-match;; Military time
875 "^[ \t]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s)
876 (+ (* 100 (string-to-int
877 (substring s (match-beginning 1) (match-end 1))))
878 (string-to-int (substring s (match-beginning 2) (match-end 2)))))
879 ((string-match;; Hour only XXam or XXpm
880 "^[ \t]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s)
881 (+ (* 100 (% (string-to-int
882 (substring s (match-beginning 1) (match-end 1)))
884 (if (string-equal "a"
885 (substring s (match-beginning 2) (match-end 2)))
887 ((string-match;; Hour and minute XX:XXam or XX:XXpm
888 "^[ \t]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
889 (+ (* 100 (% (string-to-int
890 (substring s (match-beginning 1) (match-end 1)))
892 (string-to-int (substring s (match-beginning 2) (match-end 2)))
893 (if (string-equal "a"
894 (substring s (match-beginning 3) (match-end 3)))
896 (t -9999)));; Unrecognizable
898 (defun list-sexp-diary-entries (date)
899 "Add sexp entries for DATE from the diary file to `diary-entries-list'.
900 Also, Make them visible in the diary file. Returns t if any entries were
903 Sexp diary entries must be prefaced by a `sexp-diary-entry-symbol' (normally
904 `%%'). The form of a sexp diary entry is
908 Both ENTRY and DATE are globally available when the SEXP is evaluated. If the
909 SEXP yields the value nil, the diary entry does not apply. If it yields a
910 non-nil value, ENTRY will be taken to apply to DATE; if the non-nil value is a
911 string, that string will be the diary entry in the fancy diary display.
913 For example, the following diary entry will apply to the 21st of the month
914 if it is a weekday and the Friday before if the 21st is on a weekend:
916 &%%(let ((dayname (calendar-day-of-week date))
917 (day (extract-calendar-day date)))
919 (and (= day 21) (memq dayname '(1 2 3 4 5)))
920 (and (memq day '(19 20)) (= dayname 5)))
921 ) UIUC pay checks deposited
923 A number of built-in functions are available for this type of diary entry:
925 %%(diary-date MONTH DAY YEAR) text
926 Entry applies if date is MONTH, DAY, YEAR if
927 `european-calendar-style' is nil, and DAY, MONTH, YEAR if
928 `european-calendar-style' is t. DAY, MONTH, and YEAR
929 can be lists of integers, the constant t, or an integer.
930 The constant t means all values.
932 %%(diary-float MONTH DAYNAME N) text
933 Entry will appear on the Nth DAYNAME of MONTH.
934 (DAYNAME=0 means Sunday, 1 means Monday, and so on;
935 if N is negative it counts backward from the end of
936 the month. MONTH can be a list of months, a single
937 month, or t to specify all months.
939 %%(diary-block M1 D1 Y1 M2 D2 Y2) text
940 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2,
941 inclusive. (If `european-calendar-style' is t, the
942 order of the parameters should be changed to D1, M1, Y1,
945 %%(diary-anniversary MONTH DAY YEAR) text
946 Entry will appear on anniversary dates of MONTH DAY, YEAR.
947 (If `european-calendar-style' is t, the order of the
948 parameters should be changed to DAY, MONTH, YEAR.) Text
949 can contain %d or %d%s; %d will be replaced by the number
950 of years since the MONTH DAY, YEAR and %s will be replaced
951 by the ordinal ending of that number (that is, `st', `nd',
952 `rd' or `th', as appropriate. The anniversary of February
953 29 is considered to be March 1 in a non-leap year.
955 %%(diary-cyclic N MONTH DAY YEAR) text
956 Entry will appear every N days, starting MONTH DAY, YEAR.
957 (If `european-calendar-style' is t, the order of the
958 parameters should be changed to N, DAY, MONTH, YEAR.) Text
959 can contain %d or %d%s; %d will be replaced by the number
960 of repetitions since the MONTH DAY, YEAR and %s will
961 be replaced by the ordinal ending of that number (that is,
962 `st', `nd', `rd' or `th', as appropriate.
964 %%(diary-remind SEXP DAYS &optional MARKING) text
965 Entry is a reminder for diary sexp SEXP. DAYS is either a
966 single number or a list of numbers indicating the number(s)
967 of days before the event that the warning(s) should occur.
968 If the current date is (one of) DAYS before the event
969 indicated by EXPR, then a suitable message (as specified
970 by `diary-remind-message') appears. In addition to the
971 reminders beforehand, the diary entry also appears on
972 the date itself. If optional MARKING is non-nil then the
973 *reminders* are marked on the calendar. Marking of
974 reminders is independent of whether the entry *itself* is
975 a marking or nonmarking one.
977 %%(diary-day-of-year)
978 Diary entries giving the day of the year and the number of
979 days remaining in the year will be made every day. Note
980 that since there is no text, it makes sense only if the
981 fancy diary display is used.
984 Diary entries giving the corresponding ISO commercial date
985 will be made every day. Note that since there is no text,
986 it makes sense only if the fancy diary display is used.
988 %%(diary-french-date)
989 Diary entries giving the corresponding French Revolutionary
990 date will be made every day. Note that since there is no
991 text, it makes sense only if the fancy diary display is used.
993 %%(diary-islamic-date)
994 Diary entries giving the corresponding Islamic date will be
995 made every day. Note that since there is no text, it
996 makes sense only if the fancy diary display is used.
998 %%(diary-hebrew-date)
999 Diary entries giving the corresponding Hebrew date will be
1000 made every day. Note that since there is no text, it
1001 makes sense only if the fancy diary display is used.
1003 %%(diary-astro-day-number) Diary entries giving the corresponding
1004 astronomical (Julian) day number will be made every day.
1005 Note that since there is no text, it makes sense only if the
1006 fancy diary display is used.
1008 %%(diary-julian-date) Diary entries giving the corresponding
1009 Julian date will be made every day. Note that since
1010 there is no text, it makes sense only if the fancy diary
1013 %%(diary-sunrise-sunset)
1014 Diary entries giving the local times of sunrise and sunset
1015 will be made every day. Note that since there is no text,
1016 it makes sense only if the fancy diary display is used.
1017 Floating point required.
1019 %%(diary-phases-of-moon)
1020 Diary entries giving the times of the phases of the moon
1021 will be when appropriate. Note that since there is no text,
1022 it makes sense only if the fancy diary display is used.
1023 Floating point required.
1025 %%(diary-yahrzeit MONTH DAY YEAR) text
1026 Text is assumed to be the name of the person; the date is
1027 the date of death on the *civil* calendar. The diary entry
1028 will appear on the proper Hebrew-date anniversary and on the
1029 day before. (If `european-calendar-style' is t, the order
1030 of the parameters should be changed to DAY, MONTH, YEAR.)
1032 %%(diary-rosh-hodesh)
1033 Diary entries will be made on the dates of Rosh Hodesh on
1034 the Hebrew calendar. Note that since there is no text, it
1035 makes sense only if the fancy diary display is used.
1038 Diary entries giving the weekly parasha will be made on
1039 every Saturday. Note that since there is no text, it
1040 makes sense only if the fancy diary display is used.
1043 Diary entries giving the omer count will be made every day
1044 from Passover to Shavuot. Note that since there is no text,
1045 it makes sense only if the fancy diary display is used.
1047 Marking these entries is *extremely* time consuming, so these entries are
1048 best if they are nonmarking."
1049 (let* ((mark (regexp-quote diary-nonmarking-symbol))
1050 (sexp-mark (regexp-quote sexp-diary-entry-symbol))
1051 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" mark "?" sexp-mark "("))
1053 (goto-char (point-min))
1054 (while (re-search-forward s-entry nil t)
1056 (let ((sexp-start (point))
1062 (setq sexp (buffer-substring-no-properties sexp-start (point)))
1064 (re-search-backward "\^M\\|\n\\|\\`")
1065 (setq line-start (point)))
1067 (if (and (or (char-equal (preceding-char) ?\^M)
1068 (char-equal (preceding-char) ?\n))
1069 (not (looking-at " \\|\^I")))
1070 (progn;; Diary entry consists only of the sexp
1073 (setq entry-start (point))
1074 (re-search-forward "\^M\\|\n" nil t)
1075 (while (looking-at " \\|\^I")
1076 (re-search-forward "\^M\\|\n" nil t))
1078 (setq entry (buffer-substring-no-properties entry-start (point)))
1079 (while (string-match "[\^M]" entry)
1080 (aset entry (match-beginning 0) ?\n )))
1081 (let ((diary-entry (diary-sexp-entry sexp entry date)))
1083 (subst-char-in-region line-start (point) ?\^M ?\n t))
1084 (add-to-diary-list date diary-entry)
1085 (setq entry-found (or entry-found diary-entry)))))
1088 (defun diary-sexp-entry (sexp entry date)
1089 "Process a SEXP diary ENTRY for DATE."
1090 (let ((result (if calendar-debug-sexp
1091 (let ((stack-trace-on-error t))
1092 (eval (car (read-from-string sexp))))
1094 (eval (car (read-from-string sexp)))
1097 (message "Bad sexp at line %d in %s: %s"
1100 (narrow-to-region 1 (point))
1101 (goto-char (point-min))
1103 (while (re-search-forward "\n\\|\^M" nil t)
1104 (setq lines (1+ lines)))
1108 (if (stringp result)
1114 (defun diary-date (month day year)
1115 "Specific date(s) diary entry.
1116 Entry applies if date is MONTH, DAY, YEAR if `european-calendar-style' is nil,
1117 and DAY, MONTH, YEAR if `european-calendar-style' is t. DAY, MONTH, and YEAR
1118 can be lists of integers, the constant t, or an integer. The constant t means
1120 (let* ((dd (if european-calendar-style
1123 (mm (if european-calendar-style
1126 (m (extract-calendar-month date))
1127 (y (extract-calendar-year date))
1128 (d (extract-calendar-day date)))
1130 (or (and (listp dd) (memq d dd))
1133 (or (and (listp mm) (memq m mm))
1136 (or (and (listp year) (memq y year))
1141 (defun diary-block (m1 d1 y1 m2 d2 y2)
1143 Entry applies if date is between two dates. Order of the parameters is
1144 M1, D1, Y1, M2, D2, Y2 `european-calendar-style' is nil, and
1145 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t."
1146 (let ((date1 (calendar-absolute-from-gregorian
1147 (if european-calendar-style
1150 (date2 (calendar-absolute-from-gregorian
1151 (if european-calendar-style
1154 (d (calendar-absolute-from-gregorian date)))
1155 (if (and (<= date1 d) (<= d date2))
1158 (defun diary-float (month dayname n)
1159 "Floating diary entry--entry applies if date is the nth dayname of month.
1160 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant
1161 t, or an integer. The constant t means all months. If N is negative, count
1162 backward from the end of the month."
1163 (let ((m (extract-calendar-month date))
1164 (y (extract-calendar-year date)))
1166 (or (and (listp month) (memq m month))
1169 (calendar-date-equal date (calendar-nth-named-day n dayname m y)))
1172 (defun diary-anniversary (month day year)
1173 "Anniversary diary entry.
1174 Entry applies if date is the anniversary of MONTH, DAY, YEAR if
1175 `european-calendar-style' is nil, and DAY, MONTH, YEAR if
1176 `european-calendar-style' is t. Diary entry can contain `%d' or `%d%s'; the
1177 %d will be replaced by the number of years since the MONTH DAY, YEAR and the
1178 %s will be replaced by the ordinal ending of that number (that is, `st', `nd',
1179 `rd' or `th', as appropriate. The anniversary of February 29 is considered
1180 to be March 1 in non-leap years."
1181 (let* ((d (if european-calendar-style
1184 (m (if european-calendar-style
1187 (y (extract-calendar-year date))
1189 (if (and (= m 2) (= d 29) (not (calendar-leap-year-p y)))
1192 (if (and (> diff 0) (calendar-date-equal (list m d y) date))
1193 (format entry diff (diary-ordinal-suffix diff)))))
1195 (defun diary-cyclic (n month day year)
1196 "Cycle diary entry--entry applies every N days starting at MONTH, DAY, YEAR.
1197 If `european-calendar-style' is t, parameters are N, DAY, MONTH, YEAR.
1198 ENTRY can contain `%d' or `%d%s'; the %d will be replaced by the number of
1199 years since the MONTH DAY, YEAR and the %s will be replaced by the ordinal
1200 ending of that number (that is, `st', `nd', `rd' or `th', as appropriate."
1201 (let* ((d (if european-calendar-style
1204 (m (if european-calendar-style
1207 (diff (- (calendar-absolute-from-gregorian date)
1208 (calendar-absolute-from-gregorian
1211 (if (and (>= diff 0) (zerop (% diff n)))
1212 (format entry cycle (diary-ordinal-suffix cycle)))))
1214 (defun diary-ordinal-suffix (n)
1215 "Ordinal suffix for N. (That is, `st', `nd', `rd', or `th', as appropriate.)"
1216 (if (or (memq (% n 100) '(11 12 13))
1219 (aref ["th" "st" "nd" "rd"] (% n 10))))
1221 (defun diary-day-of-year ()
1222 "Day of year and number of days remaining in the year of date diary entry."
1223 (calendar-day-of-year-string date))
1225 (defvar diary-remind-message
1227 (if (= 0 (% days 7))
1228 (concat (int-to-string (/ days 7)) (if (= 7 days) " week" " weeks"))
1229 (concat (int-to-string days) (if (= 1 days) " day" " days")))
1232 "*Pseudo-pattern giving form of reminder messages in the fancy diary
1235 Used by the function `diary-remind', a pseudo-pattern is a list of
1236 expressions that can involve the keywords `days' (a number), `date' (a list of
1237 month, day, year), and `diary-entry' (a string).")
1239 (defun diary-remind (sexp days &optional marking)
1240 "Provide a reminder of a diary entry.
1241 SEXP is a diary-sexp. DAYS is either a single number or a list of numbers
1242 indicating the number(s) of days before the event that the warning(s) should
1243 occur on. If the current date is (one of) DAYS before the event indicated by
1244 SEXP, then a suitable message (as specified by `diary-remind-message' is
1247 In addition to the reminders beforehand, the diary entry also appears on
1250 If optional parameter MARKING is non-nil then the reminders are marked on the
1251 calendar. Marking of reminders is independent of whether the entry itself is
1252 a marking or nonmarking one."
1253 (let ((diary-entry))
1254 (if (or (not marking-diary-entries) marking)
1257 (let ((date (calendar-gregorian-from-absolute
1258 (+ (calendar-absolute-from-gregorian date) days))))
1259 (if (setq diary-entry (eval sexp))
1260 (setq diary-entry (mapconcat 'eval diary-remind-message "")))))
1261 ((and (listp days) days)
1262 (setq diary-entry (diary-remind sexp (car days) marking))
1263 (if (not diary-entry)
1264 (setq diary-entry (diary-remind sexp (cdr days) marking))))))
1266 (and (or (not marking-diary-entries) marking-diary-entry)
1269 (defun add-to-diary-list (date string)
1270 "Add the entry (DATE STRING) to `diary-entries-list'.
1271 Do nothing if DATE or STRING is nil."
1273 (setq diary-entries-list
1274 (append diary-entries-list (list (list date string))))))
1276 (defun make-diary-entry (string &optional nonmarking file)
1277 "Insert a diary entry STRING which may be NONMARKING in FILE.
1278 If omitted, NONMARKING defaults to nil and FILE defaults to diary-file."
1279 (find-file-other-window
1280 (substitute-in-file-name (if file file diary-file)))
1281 (goto-char (point-max))
1284 (if nonmarking diary-nonmarking-symbol "")
1287 (defun insert-diary-entry (arg)
1288 "Insert a diary entry for the date indicated by point.
1289 Prefix arg will make the entry nonmarking."
1291 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t t)
1294 (defun insert-weekly-diary-entry (arg)
1295 "Insert a weekly diary entry for the day of the week indicated by point.
1296 Prefix arg will make the entry nonmarking."
1298 (make-diary-entry (calendar-day-name (calendar-cursor-to-date t))
1301 (defun insert-monthly-diary-entry (arg)
1302 "Insert a monthly diary entry for the day of the month indicated by point.
1303 Prefix arg will make the entry nonmarking."
1305 (let* ((calendar-date-display-form
1306 (if european-calendar-style
1309 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t)
1312 (defun insert-yearly-diary-entry (arg)
1313 "Insert an annual diary entry for the day of the year indicated by point.
1314 Prefix arg will make the entry nonmarking."
1316 (let* ((calendar-date-display-form
1317 (if european-calendar-style
1318 '(day " " monthname)
1319 '(monthname " " day))))
1320 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t) t)
1323 (defun insert-anniversary-diary-entry (arg)
1324 "Insert an anniversary diary entry for the date given by point.
1325 Prefix arg will make the entry nonmarking."
1327 (let* ((calendar-date-display-form
1328 (if european-calendar-style
1329 '(day " " month " " year)
1330 '(month " " day " " year))))
1332 (format "%s(diary-anniversary %s)"
1333 sexp-diary-entry-symbol
1334 (calendar-date-string (calendar-cursor-to-date t) nil t))
1337 (defun insert-block-diary-entry (arg)
1338 "Insert a block diary entry for the days between the point and marked date.
1339 Prefix arg will make the entry nonmarking."
1341 (let* ((calendar-date-display-form
1342 (if european-calendar-style
1343 '(day " " month " " year)
1344 '(month " " day " " year)))
1345 (cursor (calendar-cursor-to-date t))
1346 (mark (or (car calendar-mark-ring)
1347 (error "No mark set in this buffer")))
1350 (if (< (calendar-absolute-from-gregorian mark)
1351 (calendar-absolute-from-gregorian cursor))
1357 (format "%s(diary-block %s %s)"
1358 sexp-diary-entry-symbol
1359 (calendar-date-string start nil t)
1360 (calendar-date-string end nil t))
1363 (defun insert-cyclic-diary-entry (arg)
1364 "Insert a cyclic diary entry starting at the date given by point.
1365 Prefix arg will make the entry nonmarking."
1367 (let* ((calendar-date-display-form
1368 (if european-calendar-style
1369 '(day " " month " " year)
1370 '(month " " day " " year))))
1372 (format "%s(diary-cyclic %d %s)"
1373 sexp-diary-entry-symbol
1374 (calendar-read "Repeat every how many days: "
1375 '(lambda (x) (> x 0)))
1376 (calendar-date-string (calendar-cursor-to-date t) nil t))
1379 (provide 'diary-lib)
1381 ;;; diary-lib.el ends here