1 ;;; diary-lib.el --- diary functions.
3 ;; Copyright (C) 1989, 1990, 1992, 1993, 1994, 1995 Free Software
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 the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; This collection of functions implements the diary features as described
31 ;; Comments, corrections, and improvements should be sent to
32 ;; Edward M. Reingold Department of Computer Science
33 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
34 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
35 ;; Urbana, Illinois 61801
42 (defun diary (&optional arg
)
43 "Generate the diary window for ARG days starting with the current date.
44 If no argument is provided, the number of days of diary entries is governed
45 by the variable `number-of-diary-entries'. This function is suitable for
46 execution in a `.emacs' file."
48 (let ((d-file (substitute-in-file-name diary-file
))
49 (date (calendar-current-date)))
50 (if (and d-file
(file-exists-p d-file
))
51 (if (file-readable-p d-file
)
55 (arg (prefix-numeric-value arg
))
56 ((vectorp number-of-diary-entries
)
57 (aref number-of-diary-entries
(calendar-day-of-week date
)))
58 (t number-of-diary-entries
)))
59 (error "Your diary file is not readable!"))
60 (error "You don't have a diary file!"))))
62 (defun view-diary-entries (arg)
63 "Prepare and display a buffer with diary entries.
64 Searches the file named in `diary-file' for entries that
65 match ARG days starting with the date indicated by the cursor position
66 in the displayed three-month calendar."
68 (let ((d-file (substitute-in-file-name diary-file
)))
69 (if (and d-file
(file-exists-p d-file
))
70 (if (file-readable-p d-file
)
71 (list-diary-entries (calendar-cursor-to-date t
) arg
)
72 (error "Diary file is not readable!"))
73 (error "You don't have a diary file!"))))
75 (defun view-other-diary-entries (arg diary-file
)
76 "Prepare and display buffer of diary entries from an alternative diary file.
77 Prompts for a file name and searches that file for entries that match ARG
78 days starting with the date indicated by the cursor position in the displayed
79 three-month calendar."
81 (list (cond ((null current-prefix-arg
) 1)
82 ((listp current-prefix-arg
) (car current-prefix-arg
))
83 (t current-prefix-arg
))
84 (setq diary-file
(read-file-name "Enter diary file name: "
85 default-directory nil t
))))
86 (view-diary-entries arg
))
88 (autoload 'check-calendar-holidays
"holidays"
89 "Check the list of holidays for any that occur on DATE.
90 The value returned is a list of strings of relevant holiday descriptions.
91 The holidays are those in the list `calendar-holidays'."
94 (autoload 'calendar-holiday-list
"holidays"
95 "Form the list of holidays that occur on dates in the calendar window.
96 The holidays are those in the list `calendar-holidays'."
99 (autoload 'diary-french-date
"cal-french"
100 "French calendar equivalent of date diary entry."
103 (autoload 'diary-mayan-date
"cal-mayan"
104 "Mayan calendar equivalent of date diary entry."
107 (autoload 'diary-iso-date
"cal-iso"
108 "ISO calendar equivalent of date diary entry."
111 (autoload 'diary-julian-date
"cal-julian"
112 "Julian calendar equivalent of date diary entry."
115 (autoload 'diary-astro-day-number
"cal-julian"
116 "Astronomical (Julian) day number diary entry."
119 (autoload 'diary-chinese-date
"cal-chinese"
120 "Chinese calendar equivalent of date diary entry."
123 (autoload 'diary-islamic-date
"cal-islamic"
124 "Islamic calendar equivalent of date diary entry."
127 (autoload 'list-islamic-diary-entries
"cal-islamic"
128 "Add any Islamic date entries from the diary file to `diary-entries-list'."
131 (autoload 'mark-islamic-diary-entries
"cal-islamic"
132 "Mark days in the calendar window that have Islamic date diary entries."
135 (autoload 'mark-islamic-calendar-date-pattern
"cal-islamic"
136 "Mark dates in calendar window that conform to Islamic date MONTH/DAY/YEAR."
139 (autoload 'diary-hebrew-date
"cal-hebrew"
140 "Hebrew calendar equivalent of date diary entry."
143 (autoload 'diary-omer
"cal-hebrew"
144 "Omer count diary entry."
147 (autoload 'diary-yahrzeit
"cal-hebrew"
148 "Yahrzeit diary entry--entry applies if date is yahrzeit or the day before."
151 (autoload 'diary-parasha
"cal-hebrew"
152 "Parasha diary entry--entry applies if date is a Saturday."
155 (autoload 'diary-rosh-hodesh
"cal-hebrew"
156 "Rosh Hodesh diary entry."
159 (autoload 'list-hebrew-diary-entries
"cal-hebrew"
160 "Add any Hebrew date entries from the diary file to `diary-entries-list'."
163 (autoload 'mark-hebrew-diary-entries
"cal-hebrew"
164 "Mark days in the calendar window that have Hebrew date diary entries."
167 (autoload 'mark-hebrew-calendar-date-pattern
"cal-hebrew"
168 "Mark dates in calendar window that conform to Hebrew date MONTH/DAY/YEAR."
171 (autoload 'diary-coptic-date
"cal-coptic"
172 "Coptic calendar equivalent of date diary entry."
175 (autoload 'diary-ethiopic-date
"cal-coptic"
176 "Ethiopic calendar equivalent of date diary entry."
179 (autoload 'diary-phases-of-moon
"lunar" "Moon phases diary entry." t
)
181 (autoload 'diary-sunrise-sunset
"solar"
182 "Local time of sunrise and sunset as a diary entry."
185 (autoload 'diary-sabbath-candles
"solar"
186 "Local time of candle lighting diary entry--applies if date is a Friday.
187 No diary entry if there is no sunset on that date."
190 (defvar diary-syntax-table
(copy-syntax-table (standard-syntax-table))
191 "The syntax table used when parsing dates in the diary file.
192 It is the standard syntax table used in Fundamental mode, but with the
193 syntax of `*' changed to be a word constituent.")
195 (modify-syntax-entry ?
* "w" diary-syntax-table
)
197 (defun list-diary-entries (date number
)
198 "Create and display a buffer containing the relevant lines in diary-file.
199 The arguments are DATE and NUMBER; the entries selected are those
200 for NUMBER days starting with date DATE. The other entries are hidden
201 using selective display.
203 Returns a list of all relevant diary entries found, if any, in order by date.
204 The list entries have the form ((month day year) string). If the variable
205 `diary-list-include-blanks' is t, this list includes a dummy diary entry
206 \(consisting of the empty string) for a date with no diary entries.
208 After the list is prepared, the hooks `nongregorian-diary-listing-hook',
209 `list-diary-entries-hook', `diary-display-hook', and `diary-hook' are run.
210 These hooks have the following distinct roles:
212 `nongregorian-diary-listing-hook' can cull dates from the diary
213 and each included file. Usually used for Hebrew or Islamic
214 diary entries in files. Applied to *each* file.
216 `list-diary-entries-hook' adds or manipulates diary entries from
217 external sources. Used, for example, to include diary entries
218 from other files or to sort the diary entries. Invoked *once* only,
219 before the display hook is run.
221 `diary-display-hook' does the actual display of information. If this is
222 nil, simple-diary-display will be used. Use add-hook to set this to
223 fancy-diary-display, if desired. If you want no diary display, use
224 add-hook to set this to ignore.
226 `diary-hook' is run last. This can be used for an appointment
227 notification function."
230 (let* ((original-date date
);; save for possible use in the hooks
231 (old-diary-syntax-table)
233 (date-string (calendar-date-string date
))
234 (d-file (substitute-in-file-name diary-file
)))
235 (message "Preparing diary...")
237 (let ((diary-buffer (find-buffer-visiting d-file
)))
238 (set-buffer (if diary-buffer
240 (find-file-noselect d-file t
))))
241 (setq selective-display t
)
242 (setq selective-display-ellipses nil
)
243 (setq old-diary-syntax-table
(syntax-table))
244 (set-syntax-table diary-syntax-table
)
246 (let ((buffer-read-only nil
)
247 (diary-modified (buffer-modified-p))
248 (mark (regexp-quote diary-nonmarking-symbol
)))
249 (goto-char (1- (point-max)))
250 (if (not (looking-at "\^M\\|\n"))
253 (insert-string "\^M")))
254 (goto-char (point-min))
255 (if (not (looking-at "\^M\\|\n"))
256 (insert-string "\^M"))
257 (subst-char-in-region (point-min) (point-max) ?
\n ?\^M t
)
258 (calendar-for-loop i from
1 to number do
259 (let ((d diary-date-forms
)
260 (month (extract-calendar-month date
))
261 (day (extract-calendar-day date
))
262 (year (extract-calendar-year date
))
263 (entry-found (list-sexp-diary-entries date
)))
266 ((date-form (if (equal (car (car d
)) 'backup
)
269 (backup (equal (car (car d
)) 'backup
))
272 (calendar-day-name date
) "\\|"
273 (substring (calendar-day-name date
) 0 3) ".?"))
277 (calendar-month-name month
) "\\|"
278 (substring (calendar-month-name month
) 0 3) ".?"))
279 (month (concat "\\*\\|0*" (int-to-string month
)))
280 (day (concat "\\*\\|0*" (int-to-string day
)))
283 "\\*\\|0*" (int-to-string year
)
284 (if abbreviated-calendar-year
285 (concat "\\|" (int-to-string (% year
100)))
289 "\\(\\`\\|\^M\\|\n\\)" mark
"?\\("
290 (mapconcat 'eval date-form
"\\)\\(")
292 (case-fold-search t
))
293 (goto-char (point-min))
294 (while (re-search-forward regexp nil t
)
295 (if backup
(re-search-backward "\\<" nil t
))
296 (if (and (or (char-equal (preceding-char) ?\^M
)
297 (char-equal (preceding-char) ?
\n))
298 (not (looking-at " \\|\^I")))
299 ;; Diary entry that consists only of date.
301 ;; Found a nonempty diary entry--make it visible and
302 ;; add it to the list.
304 (let ((entry-start (point))
306 (re-search-backward "\^M\\|\n\\|\\`")
307 (setq date-start
(point))
308 (re-search-forward "\^M\\|\n" nil t
2)
309 (while (looking-at " \\|\^I")
310 (re-search-forward "\^M\\|\n" nil t
))
312 (subst-char-in-region date-start
316 (buffer-substring-no-properties
317 entry-start
(point)))))))
320 (not diary-list-include-blanks
)
321 (setq diary-entries-list
322 (append diary-entries-list
323 (list (list date
"")))))
325 (calendar-gregorian-from-absolute
326 (1+ (calendar-absolute-from-gregorian date
))))
327 (setq entry-found nil
)))
328 (set-buffer-modified-p diary-modified
))
329 (set-syntax-table old-diary-syntax-table
))
330 (goto-char (point-min))
331 (run-hooks 'nongregorian-diary-listing-hook
332 'list-diary-entries-hook
)
333 (if diary-display-hook
334 (run-hooks 'diary-display-hook
)
335 (simple-diary-display))
336 (run-hooks 'diary-hook
)
337 diary-entries-list
))))
339 (defun include-other-diary-files ()
340 "Include the diary entries from other diary files with those of diary-file.
341 This function is suitable for use in `list-diary-entries-hook';
342 it enables you to use shared diary files together with your own.
343 The files included are specified in the diaryfile by lines of this form:
344 #include \"filename\"
345 This is recursive; that is, #include directives in diary files thus included
346 are obeyed. You can change the `#include' to some other string by
347 changing the variable `diary-include-string'."
348 (goto-char (point-min))
349 (while (re-search-forward
351 "\\(\\`\\|\^M\\|\n\\)"
352 (regexp-quote diary-include-string
)
355 (let ((diary-file (substitute-in-file-name
356 (buffer-substring-no-properties
357 (match-beginning 2) (match-end 2))))
358 (diary-list-include-blanks nil
)
359 (list-diary-entries-hook 'include-other-diary-files
)
360 (diary-display-hook 'ignore
)
362 (if (file-exists-p diary-file
)
363 (if (file-readable-p diary-file
)
365 (setq diary-entries-list
366 (append diary-entries-list
367 (list-diary-entries original-date number
)))
368 (kill-buffer (find-buffer-visiting diary-file
)))
370 (message "Can't read included diary file %s" diary-file
)
373 (message "Can't find included diary file %s" diary-file
)
375 (goto-char (point-min)))
377 (defun simple-diary-display ()
378 "Display the diary buffer if there are any relevant entries or holidays."
379 (let* ((holiday-list (if holidays-in-diary-buffer
380 (check-calendar-holidays original-date
)))
381 (msg (format "No diary entries for %s %s"
382 (concat date-string
(if holiday-list
":" ""))
383 (mapconcat 'identity holiday-list
"; "))))
384 (if (or (not diary-entries-list
)
385 (and (not (cdr diary-entries-list
))
386 (string-equal (car (cdr (car diary-entries-list
))) "")))
387 (if (<= (length msg
) (frame-width))
389 (set-buffer (get-buffer-create holiday-buffer
))
390 (setq buffer-read-only nil
)
391 (calendar-set-mode-line date-string
)
393 (insert (mapconcat 'identity holiday-list
"\n"))
394 (goto-char (point-min))
395 (set-buffer-modified-p nil
)
396 (setq buffer-read-only t
)
397 (display-buffer holiday-buffer
)
398 (message "No diary entries for %s" date-string
))
399 (calendar-set-mode-line
400 (concat "Diary for " date-string
401 (if holiday-list
": " "")
402 (mapconcat 'identity holiday-list
"; ")))
403 (display-buffer (find-buffer-visiting d-file
))
404 (message "Preparing diary...done"))))
406 (defun fancy-diary-display ()
407 "Prepare a diary buffer with relevant entries in a fancy, noneditable form.
408 This function is provided for optional use as the `diary-display-hook'."
409 (save-excursion;; Turn off selective-display in the diary file's buffer.
410 (set-buffer (find-buffer-visiting (substitute-in-file-name diary-file
)))
411 (let ((diary-modified (buffer-modified-p)))
412 (subst-char-in-region (point-min) (point-max) ?\^M ?
\n t
)
413 (setq selective-display nil
)
414 (kill-local-variable 'mode-line-format
)
415 (set-buffer-modified-p diary-modified
)))
416 (if (or (not diary-entries-list
)
417 (and (not (cdr diary-entries-list
))
418 (string-equal (car (cdr (car diary-entries-list
))) "")))
419 (let* ((holiday-list (if holidays-in-diary-buffer
420 (check-calendar-holidays original-date
)))
421 (msg (format "No diary entries for %s %s"
422 (concat date-string
(if holiday-list
":" ""))
423 (mapconcat 'identity holiday-list
"; "))))
424 (if (<= (length msg
) (frame-width))
426 (set-buffer (get-buffer-create holiday-buffer
))
427 (setq buffer-read-only nil
)
428 (calendar-set-mode-line date-string
)
430 (insert (mapconcat 'identity holiday-list
"\n"))
431 (goto-char (point-min))
432 (set-buffer-modified-p nil
)
433 (setq buffer-read-only t
)
434 (display-buffer holiday-buffer
)
435 (message "No diary entries for %s" date-string
)))
436 (save-excursion;; Prepare the fancy diary buffer.
437 (set-buffer (make-fancy-diary-buffer))
438 (setq buffer-read-only nil
)
439 (let ((entry-list diary-entries-list
)
441 (holiday-list-last-month 1)
442 (holiday-list-last-year 1)
445 (if (not (calendar-date-equal date
(car (car entry-list
))))
447 (setq date
(car (car entry-list
)))
448 (and holidays-in-diary-buffer
449 (calendar-date-compare
450 (list (list holiday-list-last-month
451 (calendar-last-day-of-month
452 holiday-list-last-month
453 holiday-list-last-year
)
454 holiday-list-last-year
))
456 ;; We need to get the holidays for the next 3 months.
457 (setq holiday-list-last-month
458 (extract-calendar-month date
))
459 (setq holiday-list-last-year
460 (extract-calendar-year date
))
461 (increment-calendar-month
462 holiday-list-last-month holiday-list-last-year
1)
464 (let ((displayed-month holiday-list-last-month
)
465 (displayed-year holiday-list-last-year
))
466 (calendar-holiday-list)))
467 (increment-calendar-month
468 holiday-list-last-month holiday-list-last-year
1))
469 (let* ((date-string (calendar-date-string date
))
471 (let ((h holiday-list
)
473 ;; Make a list of all holidays for date.
475 (if (calendar-date-equal date
(car (car h
)))
476 (setq d
(append d
(cdr (car h
)))))
479 (insert (if (= (point) (point-min)) "" ?
\n) date-string
)
480 (if date-holiday-list
(insert ": "))
481 (let ((l (current-column)))
482 (insert (mapconcat 'identity date-holiday-list
483 (concat "\n" (make-string l ?
)))))
484 (let ((l (current-column)))
485 (insert ?
\n (make-string l ?
=) ?
\n)))))
486 (if (< 0 (length (car (cdr (car entry-list
)))))
487 (insert (car (cdr (car entry-list
))) ?
\n))
488 (setq entry-list
(cdr entry-list
))))
489 (set-buffer-modified-p nil
)
490 (goto-char (point-min))
491 (setq buffer-read-only t
)
492 (display-buffer fancy-diary-buffer
)
493 (message "Preparing diary...done"))))
495 (defun make-fancy-diary-buffer ()
496 "Create and return the initial fancy diary buffer."
498 (set-buffer (get-buffer-create fancy-diary-buffer
))
499 (setq buffer-read-only nil
)
500 (make-local-variable 'mode-line-format
)
501 (calendar-set-mode-line "Diary Entries")
503 (set-buffer-modified-p nil
)
504 (setq buffer-read-only t
)
505 (get-buffer fancy-diary-buffer
)))
507 (defun print-diary-entries ()
508 "Print a hard copy of the diary display.
510 If the simple diary display is being used, prepare a temp buffer with the
511 visible lines of the diary buffer, add a heading line composed from the mode
512 line, print the temp buffer, and destroy it.
514 If the fancy diary display is being used, just print the buffer.
516 The hooks given by the variable `print-diary-entries-hook' are called to do
517 the actual printing."
519 (if (bufferp (get-buffer fancy-diary-buffer
))
521 (set-buffer (get-buffer fancy-diary-buffer
))
522 (run-hooks 'print-diary-entries-hook
))
524 (find-buffer-visiting (substitute-in-file-name diary-file
))))
526 (let ((temp-buffer (get-buffer-create "*Printable Diary Entries*"))
529 (set-buffer diary-buffer
)
531 (if (not (stringp mode-line-format
))
533 (string-match "^-*\\([^-].*[^-]\\)-*$" mode-line-format
)
534 (substring mode-line-format
535 (match-beginning 1) (match-end 1))))
536 (copy-to-buffer temp-buffer
(point-min) (point-max))
537 (set-buffer temp-buffer
)
538 (while (re-search-forward "\^M.*$" nil t
)
540 (goto-char (point-min))
542 (make-string (length heading
) ?
=) "\n")
543 (run-hooks 'print-diary-entries-hook
)
544 (kill-buffer temp-buffer
)))
545 (error "You don't have a diary buffer!")))))
547 (defun show-all-diary-entries ()
548 "Show all of the diary entries in the diary file.
549 This function gets rid of the selective display of the diary file so that
550 all entries, not just some, are visible. If there is no diary buffer, one
553 (let ((d-file (substitute-in-file-name diary-file
)))
554 (if (and d-file
(file-exists-p d-file
))
555 (if (file-readable-p d-file
)
557 (let ((diary-buffer (find-buffer-visiting d-file
)))
558 (set-buffer (if diary-buffer
560 (find-file-noselect d-file t
)))
561 (let ((buffer-read-only nil
)
562 (diary-modified (buffer-modified-p)))
563 (subst-char-in-region (point-min) (point-max) ?\^M ?
\n t
)
564 (setq selective-display nil
)
565 (make-local-variable 'mode-line-format
)
566 (setq mode-line-format default-mode-line-format
)
567 (display-buffer (current-buffer))
568 (set-buffer-modified-p diary-modified
))))
569 (error "Your diary file is not readable!"))
570 (error "You don't have a diary file!"))))
572 (defun diary-name-pattern (string-array &optional fullname
)
573 "Convert an STRING-ARRAY, an array of strings to a pattern.
574 The pattern will match any of the strings, either entirely or abbreviated
575 to three characters. An abbreviated form will match with or without a period;
576 If the optional FULLNAME is t, abbreviations will not match, just the full
579 (calendar-for-loop i from
0 to
(1- (length string-array
)) do
583 (if (string-equal pattern
"") "" "\\|")
584 (aref string-array i
)
589 (substring (aref string-array i
) 0 3) ".?")))))
592 (defvar marking-diary-entries nil
593 "True during the marking of diary entries, nil otherwise.")
595 (defvar marking-diary-entry nil
596 "True during the marking of diary entries, if current entry is marking.")
598 (defun mark-diary-entries ()
599 "Mark days in the calendar window that have diary entries.
600 Each entry in the diary file visible in the calendar window is marked.
601 After the entries are marked, the hooks `nongregorian-diary-marking-hook' and
602 `mark-diary-entries-hook' are run."
604 (setq mark-diary-entries-in-calendar t
)
605 (let ((d-file (substitute-in-file-name diary-file
))
606 (marking-diary-entries t
))
607 (if (and d-file
(file-exists-p d-file
))
608 (if (file-readable-p d-file
)
610 (message "Marking diary entries...")
611 (set-buffer (find-file-noselect d-file t
))
612 (let ((d diary-date-forms
)
613 (old-diary-syntax-table))
614 (setq old-diary-syntax-table
(syntax-table))
615 (set-syntax-table diary-syntax-table
)
618 ((date-form (if (equal (car (car d
)) 'backup
)
620 (car d
)));; ignore 'backup directive
621 (dayname (diary-name-pattern calendar-day-name-array
))
624 (diary-name-pattern calendar-month-name-array
)
626 (month "[0-9]+\\|\\*")
628 (year "[0-9]+\\|\\*")
629 (l (length date-form
))
630 (d-name-pos (- l
(length (memq 'dayname date-form
))))
631 (d-name-pos (if (/= l d-name-pos
) (+ 2 d-name-pos
)))
632 (m-name-pos (- l
(length (memq 'monthname date-form
))))
633 (m-name-pos (if (/= l m-name-pos
) (+ 2 m-name-pos
)))
634 (d-pos (- l
(length (memq 'day date-form
))))
635 (d-pos (if (/= l d-pos
) (+ 2 d-pos
)))
636 (m-pos (- l
(length (memq 'month date-form
))))
637 (m-pos (if (/= l m-pos
) (+ 2 m-pos
)))
638 (y-pos (- l
(length (memq 'year date-form
))))
639 (y-pos (if (/= l y-pos
) (+ 2 y-pos
)))
642 "\\(\\`\\|\^M\\|\n\\)\\("
643 (mapconcat 'eval date-form
"\\)\\(")
645 (case-fold-search t
))
646 (goto-char (point-min))
647 (while (re-search-forward regexp nil t
)
650 (buffer-substring-no-properties
651 (match-beginning d-name-pos
)
652 (match-end d-name-pos
))))
655 (buffer-substring-no-properties
656 (match-beginning m-name-pos
)
657 (match-end m-name-pos
))))
660 (buffer-substring-no-properties
661 (match-beginning m-pos
)
666 (buffer-substring-no-properties
667 (match-beginning d-pos
)
671 (buffer-substring-no-properties
672 (match-beginning y-pos
)
676 (if (and (= (length y-str
) 2)
677 abbreviated-calendar-year
)
679 (extract-calendar-year
680 (calendar-current-date)))
681 (y (+ (string-to-int y-str
)
683 (/ current-y
100)))))
684 (if (> (- y current-y
) 50)
686 (if (> (- current-y y
) 50)
689 (string-to-int y-str
)))))
691 (mark-calendar-days-named
692 (cdr (assoc (capitalize (substring dd-name
0 3))
694 calendar-day-name-array
696 '(lambda (x) (substring x
0 3))))))
698 (if (string-equal mm-name
"*")
703 (substring mm-name
0 3))
705 calendar-month-name-array
707 '(lambda (x) (substring x
0 3)))
709 (mark-calendar-date-pattern mm dd yy
))))
711 (mark-sexp-diary-entries)
712 (run-hooks 'nongregorian-diary-marking-hook
713 'mark-diary-entries-hook
)
714 (set-syntax-table old-diary-syntax-table
)
715 (message "Marking diary entries...done")))
716 (error "Your diary file is not readable!"))
717 (error "You don't have a diary file!"))))
719 (defun mark-sexp-diary-entries ()
720 "Mark days in the calendar window that have sexp diary entries.
721 Each entry in the diary file (or included files) visible in the calendar window
722 is marked. See the documentation for the function `list-sexp-diary-entries'."
723 (let* ((sexp-mark (regexp-quote sexp-diary-entry-symbol
))
724 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)\\("
725 (regexp-quote sexp-mark
) "(\\)\\|\\("
726 (regexp-quote diary-nonmarking-symbol
)
727 (regexp-quote sexp-mark
) "(diary-remind\\)"))
733 (set-buffer calendar-buffer
)
734 (setq m displayed-month
)
735 (setq y displayed-year
))
736 (increment-calendar-month m y -
1)
738 (calendar-absolute-from-gregorian (list m
1 y
)))
739 (increment-calendar-month m y
2)
741 (calendar-absolute-from-gregorian
742 (list m
(calendar-last-day-of-month m y
) y
)))
743 (goto-char (point-min))
744 (while (re-search-forward s-entry nil t
)
745 (if (char-equal (preceding-char) ?\
()
746 (setq marking-diary-entry t
)
747 (setq marking-diary-entry nil
))
748 (re-search-backward "(")
749 (let ((sexp-start (point))
755 (setq sexp
(buffer-substring-no-properties sexp-start
(point)))
757 (re-search-backward "\^M\\|\n\\|\\`")
758 (setq line-start
(point)))
760 (if (and (or (char-equal (preceding-char) ?\^M
)
761 (char-equal (preceding-char) ?
\n))
762 (not (looking-at " \\|\^I")))
763 (progn;; Diary entry consists only of the sexp
766 (setq entry-start
(point))
767 (re-search-forward "\^M\\|\n" nil t
)
768 (while (looking-at " \\|\^I")
769 (re-search-forward "\^M\\|\n" nil t
))
771 (setq entry
(buffer-substring-no-properties entry-start
(point)))
772 (while (string-match "[\^M]" entry
)
773 (aset entry
(match-beginning 0) ?
\n )))
774 (calendar-for-loop date from first-date to last-date do
775 (if (diary-sexp-entry sexp entry
776 (calendar-gregorian-from-absolute date
))
777 (mark-visible-calendar-date
778 (calendar-gregorian-from-absolute date
))))))))
780 (defun mark-included-diary-files ()
781 "Mark the diary entries from other diary files with those of the diary file.
782 This function is suitable for use as the `mark-diary-entries-hook'; it enables
783 you to use shared diary files together with your own. The files included are
784 specified in the diary-file by lines of this form:
785 #include \"filename\"
786 This is recursive; that is, #include directives in diary files thus included
787 are obeyed. You can change the `#include' to some other string by
788 changing the variable `diary-include-string'."
789 (goto-char (point-min))
790 (while (re-search-forward
792 "\\(\\`\\|\^M\\|\n\\)"
793 (regexp-quote diary-include-string
)
796 (let ((diary-file (substitute-in-file-name
797 (buffer-substring-no-properties
798 (match-beginning 2) (match-end 2))))
799 (mark-diary-entries-hook 'mark-included-diary-files
))
800 (if (file-exists-p diary-file
)
801 (if (file-readable-p diary-file
)
804 (kill-buffer (find-buffer-visiting diary-file
)))
806 (message "Can't read included diary file %s" diary-file
)
809 (message "Can't find included diary file %s" diary-file
)
811 (goto-char (point-min)))
813 (defun mark-calendar-days-named (dayname)
814 "Mark all dates in the calendar window that are day DAYNAME of the week.
815 0 means all Sundays, 1 means all Mondays, and so on."
817 (set-buffer calendar-buffer
)
818 (let ((prev-month displayed-month
)
819 (prev-year displayed-year
)
820 (succ-month displayed-month
)
821 (succ-year displayed-year
)
824 (increment-calendar-month succ-month succ-year
1)
825 (increment-calendar-month prev-month prev-year -
1)
826 (setq day
(calendar-absolute-from-gregorian
827 (calendar-nth-named-day 1 dayname prev-month prev-year
)))
828 (setq last-day
(calendar-absolute-from-gregorian
829 (calendar-nth-named-day -
1 dayname succ-month succ-year
)))
830 (while (<= day last-day
)
831 (mark-visible-calendar-date (calendar-gregorian-from-absolute day
))
832 (setq day
(+ day
7))))))
834 (defun mark-calendar-date-pattern (month day year
)
835 "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR.
836 A value of 0 in any position is a wildcard."
838 (set-buffer calendar-buffer
)
839 (let ((m displayed-month
)
841 (increment-calendar-month m y -
1)
842 (calendar-for-loop i from
0 to
2 do
843 (mark-calendar-month m y month day year
)
844 (increment-calendar-month m y
1)))))
846 (defun mark-calendar-month (month year p-month p-day p-year
)
847 "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR.
848 A value of 0 in any position of the pattern is a wildcard."
849 (if (or (and (= month p-month
)
850 (or (= p-year
0) (= year p-year
)))
852 (or (= p-year
0) (= year p-year
))))
855 i from
1 to
(calendar-last-day-of-month month year
) do
856 (mark-visible-calendar-date (list month i year
)))
857 (mark-visible-calendar-date (list month p-day year
)))))
859 (defun sort-diary-entries ()
860 "Sort the list of diary entries by time of day."
861 (setq diary-entries-list
(sort diary-entries-list
'diary-entry-compare
)))
863 (defun diary-entry-compare (e1 e2
)
864 "Returns t if E1 is earlier than E2."
865 (or (calendar-date-compare e1 e2
)
866 (and (calendar-date-equal (car e1
) (car e2
))
867 (< (diary-entry-time (car (cdr e1
)))
868 (diary-entry-time (car (cdr e2
)))))))
870 (defun diary-entry-time (s)
871 "Time at the beginning of the string S in a military-style integer.
872 For example, returns 1325 for 1:25pm. Returns -9999 if no time is recognized.
873 The recognized forms are XXXX or X:XX or XX:XX (military time), XXam or XXpm,
874 and XX:XXam or XX:XXpm."
875 (cond ((string-match;; Military time
876 "^[ \t]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s
)
877 (+ (* 100 (string-to-int
878 (substring s
(match-beginning 1) (match-end 1))))
879 (string-to-int (substring s
(match-beginning 2) (match-end 2)))))
880 ((string-match;; Hour only XXam or XXpm
881 "^[ \t]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s
)
882 (+ (* 100 (%
(string-to-int
883 (substring s
(match-beginning 1) (match-end 1)))
885 (if (string-equal "a"
886 (substring s
(match-beginning 2) (match-end 2)))
888 ((string-match;; Hour and minute XX:XXam or XX:XXpm
889 "^[ \t]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s
)
890 (+ (* 100 (%
(string-to-int
891 (substring s
(match-beginning 1) (match-end 1)))
893 (string-to-int (substring s
(match-beginning 2) (match-end 2)))
894 (if (string-equal "a"
895 (substring s
(match-beginning 3) (match-end 3)))
897 (t -
9999)));; Unrecognizable
899 (defun list-sexp-diary-entries (date)
900 "Add sexp entries for DATE from the diary file to `diary-entries-list'.
901 Also, Make them visible in the diary file. Returns t if any entries were
904 Sexp diary entries must be prefaced by a `sexp-diary-entry-symbol' (normally
905 `%%'). The form of a sexp diary entry is
909 Both ENTRY and DATE are globally available when the SEXP is evaluated. If the
910 SEXP yields the value nil, the diary entry does not apply. If it yields a
911 non-nil value, ENTRY will be taken to apply to DATE; if the non-nil value is a
912 string, that string will be the diary entry in the fancy diary display.
914 For example, the following diary entry will apply to the 21st of the month
915 if it is a weekday and the Friday before if the 21st is on a weekend:
917 &%%(let ((dayname (calendar-day-of-week date))
918 (day (extract-calendar-day date)))
920 (and (= day 21) (memq dayname '(1 2 3 4 5)))
921 (and (memq day '(19 20)) (= dayname 5)))
922 ) UIUC pay checks deposited
924 A number of built-in functions are available for this type of diary entry:
926 %%(diary-date MONTH DAY YEAR) text
927 Entry applies if date is MONTH, DAY, YEAR if
928 `european-calendar-style' is nil, and DAY, MONTH, YEAR if
929 `european-calendar-style' is t. DAY, MONTH, and YEAR
930 can be lists of integers, the constant t, or an integer.
931 The constant t means all values.
933 %%(diary-float MONTH DAYNAME N) text
934 Entry will appear on the Nth DAYNAME of MONTH.
935 (DAYNAME=0 means Sunday, 1 means Monday, and so on;
936 if N is negative it counts backward from the end of
937 the month. MONTH can be a list of months, a single
938 month, or t to specify all months.
940 %%(diary-block M1 D1 Y1 M2 D2 Y2) text
941 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2,
942 inclusive. (If `european-calendar-style' is t, the
943 order of the parameters should be changed to D1, M1, Y1,
946 %%(diary-anniversary MONTH DAY YEAR) text
947 Entry will appear on anniversary dates of MONTH DAY, YEAR.
948 (If `european-calendar-style' is t, the order of the
949 parameters should be changed to DAY, MONTH, YEAR.) Text
950 can contain %d or %d%s; %d will be replaced by the number
951 of years since the MONTH DAY, YEAR and %s will be replaced
952 by the ordinal ending of that number (that is, `st', `nd',
953 `rd' or `th', as appropriate. The anniversary of February
954 29 is considered to be March 1 in a non-leap year.
956 %%(diary-cyclic N MONTH DAY YEAR) text
957 Entry will appear every N days, starting MONTH DAY, YEAR.
958 (If `european-calendar-style' is t, the order of the
959 parameters should be changed to N, DAY, MONTH, YEAR.) Text
960 can contain %d or %d%s; %d will be replaced by the number
961 of repetitions since the MONTH DAY, YEAR and %s will
962 be replaced by the ordinal ending of that number (that is,
963 `st', `nd', `rd' or `th', as appropriate.
965 %%(diary-remind SEXP DAYS &optional MARKING) text
966 Entry is a reminder for diary sexp SEXP. DAYS is either a
967 single number or a list of numbers indicating the number(s)
968 of days before the event that the warning(s) should occur.
969 If the current date is (one of) DAYS before the event
970 indicated by EXPR, then a suitable message (as specified
971 by `diary-remind-message') appears. In addition to the
972 reminders beforehand, the diary entry also appears on
973 the date itself. If optional MARKING is non-nil then the
974 *reminders* are marked on the calendar. Marking of
975 reminders is independent of whether the entry *itself* is
976 a marking or nonmarking one.
978 %%(diary-day-of-year)
979 Diary entries giving the day of the year and the number of
980 days remaining in the year will be made every day. Note
981 that since there is no text, it makes sense only if the
982 fancy diary display is used.
985 Diary entries giving the corresponding ISO commercial date
986 will be made every day. Note that since there is no text,
987 it makes sense only if the fancy diary display is used.
989 %%(diary-french-date)
990 Diary entries giving the corresponding French Revolutionary
991 date will be made every day. Note that since there is no
992 text, it makes sense only if the fancy diary display is used.
994 %%(diary-islamic-date)
995 Diary entries giving the corresponding Islamic date will be
996 made every day. Note that since there is no text, it
997 makes sense only if the fancy diary display is used.
999 %%(diary-hebrew-date)
1000 Diary entries giving the corresponding Hebrew date will be
1001 made every day. Note that since there is no text, it
1002 makes sense only if the fancy diary display is used.
1004 %%(diary-astro-day-number) Diary entries giving the corresponding
1005 astronomical (Julian) day number will be made every day.
1006 Note that since there is no text, it makes sense only if the
1007 fancy diary display is used.
1009 %%(diary-julian-date) Diary entries giving the corresponding
1010 Julian date will be made every day. Note that since
1011 there is no text, it makes sense only if the fancy diary
1014 %%(diary-sunrise-sunset)
1015 Diary entries giving the local times of sunrise and sunset
1016 will be made every day. Note that since there is no text,
1017 it makes sense only if the fancy diary display is used.
1018 Floating point required.
1020 %%(diary-phases-of-moon)
1021 Diary entries giving the times of the phases of the moon
1022 will be when appropriate. Note that since there is no text,
1023 it makes sense only if the fancy diary display is used.
1024 Floating point required.
1026 %%(diary-yahrzeit MONTH DAY YEAR) text
1027 Text is assumed to be the name of the person; the date is
1028 the date of death on the *civil* calendar. The diary entry
1029 will appear on the proper Hebrew-date anniversary and on the
1030 day before. (If `european-calendar-style' is t, the order
1031 of the parameters should be changed to DAY, MONTH, YEAR.)
1033 %%(diary-rosh-hodesh)
1034 Diary entries will be made on the dates of Rosh Hodesh on
1035 the Hebrew calendar. Note that since there is no text, it
1036 makes sense only if the fancy diary display is used.
1039 Diary entries giving the weekly parasha will be made on
1040 every Saturday. Note that since there is no text, it
1041 makes sense only if the fancy diary display is used.
1044 Diary entries giving the omer count will be made every day
1045 from Passover to Shavuot. Note that since there is no text,
1046 it makes sense only if the fancy diary display is used.
1048 Marking these entries is *extremely* time consuming, so these entries are
1049 best if they are nonmarking."
1050 (let* ((mark (regexp-quote diary-nonmarking-symbol
))
1051 (sexp-mark (regexp-quote sexp-diary-entry-symbol
))
1052 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" mark
"?" sexp-mark
"("))
1054 (goto-char (point-min))
1055 (while (re-search-forward s-entry nil t
)
1057 (let ((sexp-start (point))
1063 (setq sexp
(buffer-substring-no-properties sexp-start
(point)))
1065 (re-search-backward "\^M\\|\n\\|\\`")
1066 (setq line-start
(point)))
1068 (if (and (or (char-equal (preceding-char) ?\^M
)
1069 (char-equal (preceding-char) ?
\n))
1070 (not (looking-at " \\|\^I")))
1071 (progn;; Diary entry consists only of the sexp
1074 (setq entry-start
(point))
1075 (re-search-forward "\^M\\|\n" nil t
)
1076 (while (looking-at " \\|\^I")
1077 (re-search-forward "\^M\\|\n" nil t
))
1079 (setq entry
(buffer-substring-no-properties entry-start
(point)))
1080 (while (string-match "[\^M]" entry
)
1081 (aset entry
(match-beginning 0) ?
\n )))
1082 (let ((diary-entry (diary-sexp-entry sexp entry date
)))
1084 (subst-char-in-region line-start
(point) ?\^M ?
\n t
))
1085 (add-to-diary-list date diary-entry
)
1086 (setq entry-found
(or entry-found diary-entry
)))))
1089 (defun diary-sexp-entry (sexp entry date
)
1090 "Process a SEXP diary ENTRY for DATE."
1091 (let ((result (if calendar-debug-sexp
1092 (let ((stack-trace-on-error t
))
1093 (eval (car (read-from-string sexp
))))
1095 (eval (car (read-from-string sexp
)))
1098 (message "Bad sexp at line %d in %s: %s"
1101 (narrow-to-region 1 (point))
1102 (goto-char (point-min))
1104 (while (re-search-forward "\n\\|\^M" nil t
)
1105 (setq lines
(1+ lines
)))
1109 (if (stringp result
)
1115 (defun diary-date (month day year
)
1116 "Specific date(s) diary entry.
1117 Entry applies if date is MONTH, DAY, YEAR if `european-calendar-style' is nil,
1118 and DAY, MONTH, YEAR if `european-calendar-style' is t. DAY, MONTH, and YEAR
1119 can be lists of integers, the constant t, or an integer. The constant t means
1121 (let* ((dd (if european-calendar-style
1124 (mm (if european-calendar-style
1127 (m (extract-calendar-month date
))
1128 (y (extract-calendar-year date
))
1129 (d (extract-calendar-day date
)))
1131 (or (and (listp dd
) (memq d dd
))
1134 (or (and (listp mm
) (memq m mm
))
1137 (or (and (listp year
) (memq y year
))
1142 (defun diary-block (m1 d1 y1 m2 d2 y2
)
1144 Entry applies if date is between two dates. Order of the parameters is
1145 M1, D1, Y1, M2, D2, Y2 `european-calendar-style' is nil, and
1146 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t."
1147 (let ((date1 (calendar-absolute-from-gregorian
1148 (if european-calendar-style
1151 (date2 (calendar-absolute-from-gregorian
1152 (if european-calendar-style
1155 (d (calendar-absolute-from-gregorian date
)))
1156 (if (and (<= date1 d
) (<= d date2
))
1159 (defun diary-float (month dayname n
)
1160 "Floating diary entry--entry applies if date is the nth dayname of month.
1161 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant
1162 t, or an integer. The constant t means all months. If N is negative, count
1163 backward from the end of the month."
1164 (let ((m (extract-calendar-month date
))
1165 (y (extract-calendar-year date
)))
1167 (or (and (listp month
) (memq m month
))
1170 (calendar-date-equal date
(calendar-nth-named-day n dayname m y
)))
1173 (defun diary-anniversary (month day year
)
1174 "Anniversary diary entry.
1175 Entry applies if date is the anniversary of MONTH, DAY, YEAR if
1176 `european-calendar-style' is nil, and DAY, MONTH, YEAR if
1177 `european-calendar-style' is t. Diary entry can contain `%d' or `%d%s'; the
1178 %d will be replaced by the number of years since the MONTH DAY, YEAR and the
1179 %s will be replaced by the ordinal ending of that number (that is, `st', `nd',
1180 `rd' or `th', as appropriate. The anniversary of February 29 is considered
1181 to be March 1 in non-leap years."
1182 (let* ((d (if european-calendar-style
1185 (m (if european-calendar-style
1188 (y (extract-calendar-year date
))
1190 (if (and (= m
2) (= d
29) (not (calendar-leap-year-p y
)))
1193 (if (and (> diff
0) (calendar-date-equal (list m d y
) date
))
1194 (format entry diff
(diary-ordinal-suffix diff
)))))
1196 (defun diary-cyclic (n month day year
)
1197 "Cycle diary entry--entry applies every N days starting at MONTH, DAY, YEAR.
1198 If `european-calendar-style' is t, parameters are N, DAY, MONTH, YEAR.
1199 ENTRY can contain `%d' or `%d%s'; the %d will be replaced by the number of
1200 years since the MONTH DAY, YEAR and the %s will be replaced by the ordinal
1201 ending of that number (that is, `st', `nd', `rd' or `th', as appropriate."
1202 (let* ((d (if european-calendar-style
1205 (m (if european-calendar-style
1208 (diff (- (calendar-absolute-from-gregorian date
)
1209 (calendar-absolute-from-gregorian
1212 (if (and (>= diff
0) (zerop (% diff n
)))
1213 (format entry cycle
(diary-ordinal-suffix cycle
)))))
1215 (defun diary-ordinal-suffix (n)
1216 "Ordinal suffix for N. (That is, `st', `nd', `rd', or `th', as appropriate.)"
1217 (if (or (memq (% n
100) '(11 12 13))
1220 (aref ["th" "st" "nd" "rd"] (% n
10))))
1222 (defun diary-day-of-year ()
1223 "Day of year and number of days remaining in the year of date diary entry."
1224 (calendar-day-of-year-string date
))
1226 (defvar diary-remind-message
1228 (if (= 0 (% days
7))
1229 (concat (int-to-string (/ days
7)) (if (= 7 days
) " week" " weeks"))
1230 (concat (int-to-string days
) (if (= 1 days
) " day" " days")))
1233 "*Pseudo-pattern giving form of reminder messages in the fancy diary
1236 Used by the function `diary-remind', a pseudo-pattern is a list of
1237 expressions that can involve the keywords `days' (a number), `date' (a list of
1238 month, day, year), and `diary-entry' (a string).")
1240 (defun diary-remind (sexp days
&optional marking
)
1241 "Provide a reminder of a diary entry.
1242 SEXP is a diary-sexp. DAYS is either a single number or a list of numbers
1243 indicating the number(s) of days before the event that the warning(s) should
1244 occur on. If the current date is (one of) DAYS before the event indicated by
1245 SEXP, then a suitable message (as specified by `diary-remind-message' is
1248 In addition to the reminders beforehand, the diary entry also appears on
1251 If optional parameter MARKING is non-nil then the reminders are marked on the
1252 calendar. Marking of reminders is independent of whether the entry itself is
1253 a marking or nonmarking one."
1254 (let ((diary-entry))
1255 (if (or (not marking-diary-entries
) marking
)
1258 (let ((date (calendar-gregorian-from-absolute
1259 (+ (calendar-absolute-from-gregorian date
) days
))))
1260 (if (setq diary-entry
(eval sexp
))
1261 (setq diary-entry
(mapconcat 'eval diary-remind-message
"")))))
1262 ((and (listp days
) days
)
1263 (setq diary-entry
(diary-remind sexp
(car days
) marking
))
1264 (if (not diary-entry
)
1265 (setq diary-entry
(diary-remind sexp
(cdr days
) marking
))))))
1267 (and (or (not marking-diary-entries
) marking-diary-entry
)
1270 (defun add-to-diary-list (date string
)
1271 "Add the entry (DATE STRING) to `diary-entries-list'.
1272 Do nothing if DATE or STRING is nil."
1274 (setq diary-entries-list
1275 (append diary-entries-list
(list (list date string
))))))
1277 (defun make-diary-entry (string &optional nonmarking file
)
1278 "Insert a diary entry STRING which may be NONMARKING in FILE.
1279 If omitted, NONMARKING defaults to nil and FILE defaults to diary-file."
1280 (find-file-other-window
1281 (substitute-in-file-name (if file file diary-file
)))
1282 (goto-char (point-max))
1285 (if nonmarking diary-nonmarking-symbol
"")
1288 (defun insert-diary-entry (arg)
1289 "Insert a diary entry for the date indicated by point.
1290 Prefix arg will make the entry nonmarking."
1292 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t t
)
1295 (defun insert-weekly-diary-entry (arg)
1296 "Insert a weekly diary entry for the day of the week indicated by point.
1297 Prefix arg will make the entry nonmarking."
1299 (make-diary-entry (calendar-day-name (calendar-cursor-to-date t
))
1302 (defun insert-monthly-diary-entry (arg)
1303 "Insert a monthly diary entry for the day of the month indicated by point.
1304 Prefix arg will make the entry nonmarking."
1306 (let* ((calendar-date-display-form
1307 (if european-calendar-style
1310 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t
)
1313 (defun insert-yearly-diary-entry (arg)
1314 "Insert an annual diary entry for the day of the year indicated by point.
1315 Prefix arg will make the entry nonmarking."
1317 (let* ((calendar-date-display-form
1318 (if european-calendar-style
1319 '(day " " monthname
)
1320 '(monthname " " day
))))
1321 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t
)
1324 (defun insert-anniversary-diary-entry (arg)
1325 "Insert an anniversary diary entry for the date given by point.
1326 Prefix arg will make the entry nonmarking."
1328 (let* ((calendar-date-display-form
1329 (if european-calendar-style
1330 '(day " " month
" " year
)
1331 '(month " " day
" " year
))))
1333 (format "%s(diary-anniversary %s)"
1334 sexp-diary-entry-symbol
1335 (calendar-date-string (calendar-cursor-to-date t
) nil t
))
1338 (defun insert-block-diary-entry (arg)
1339 "Insert a block diary entry for the days between the point and marked date.
1340 Prefix arg will make the entry nonmarking."
1342 (let* ((calendar-date-display-form
1343 (if european-calendar-style
1344 '(day " " month
" " year
)
1345 '(month " " day
" " year
)))
1346 (cursor (calendar-cursor-to-date t
))
1347 (mark (or (car calendar-mark-ring
)
1348 (error "No mark set in this buffer")))
1351 (if (< (calendar-absolute-from-gregorian mark
)
1352 (calendar-absolute-from-gregorian cursor
))
1358 (format "%s(diary-block %s %s)"
1359 sexp-diary-entry-symbol
1360 (calendar-date-string start nil t
)
1361 (calendar-date-string end nil t
))
1364 (defun insert-cyclic-diary-entry (arg)
1365 "Insert a cyclic diary entry starting at the date given by point.
1366 Prefix arg will make the entry nonmarking."
1368 (let* ((calendar-date-display-form
1369 (if european-calendar-style
1370 '(day " " month
" " year
)
1371 '(month " " day
" " year
))))
1373 (format "%s(diary-cyclic %d %s)"
1374 sexp-diary-entry-symbol
1375 (calendar-read "Repeat every how many days: "
1376 '(lambda (x) (> x
0)))
1377 (calendar-date-string (calendar-cursor-to-date t
) nil t
))
1380 (provide 'diary-lib
)
1382 ;;; diary-lib.el ends here