1 ;;; diary.el --- diary functions.
3 ;; Copyright (C) 1989, 1990, 1992, 1993 Free Software Foundation, Inc.
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY. No author or distributor
12 ;; accepts responsibility to anyone for the consequences of using it
13 ;; or for whether it serves any particular purpose or works at all,
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public
15 ;; License for full details.
17 ;; Everyone is granted permission to copy, modify and redistribute
18 ;; GNU Emacs, but only under the conditions described in the
19 ;; GNU Emacs General Public License. A copy of this license is
20 ;; supposed to have been given to you along with GNU Emacs so you
21 ;; can know your rights and responsibilities. It should be in a
22 ;; file named COPYING. Among other things, the copyright notice
23 ;; and this notice must be preserved on all copies.
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 "Your diary file is not readable!"))
72 (error "You don't have a diary file!"))))
74 (autoload 'check-calendar-holidays
"holidays"
75 "Check the list of holidays for any that occur on DATE.
76 The value returned is a list of strings of relevant holiday descriptions.
77 The holidays are those in the list `calendar-holidays'."
81 (autoload 'calendar-holiday-list
"holidays"
82 "Form the list of holidays that occur on dates in the calendar window.
83 The holidays are those in the list `calendar-holidays'."
86 (autoload 'diary-french-date
"cal-french"
87 "French calendar equivalent of date diary entry."
90 (autoload 'diary-mayan-date
"cal-mayan"
91 "Mayan calendar equivalent of date diary entry."
94 (autoload 'diary-phases-of-moon
"lunar" "Moon phases diary entry." t
)
96 (autoload 'diary-sunrise-sunset
"solar"
97 "Local time of sunrise and sunset as a diary entry."
100 (autoload 'diary-sabbath-candles
"solar"
101 "Local time of candle lighting diary entry--applies if date is a Friday.
102 No diary entry if there is no sunset on that date."
105 (defvar diary-syntax-table
(copy-syntax-table (standard-syntax-table))
106 "The syntax table used when parsing dates in the diary file.
107 It is the standard syntax table used in Fundamental mode, but with the
108 syntax of `*' changed to be a word constituent.")
110 (modify-syntax-entry ?
* "w" diary-syntax-table
)
112 (defun list-diary-entries (date number
)
113 "Create and display a buffer containing the relevant lines in diary-file.
114 The arguments are DATE and NUMBER; the entries selected are those
115 for NUMBER days starting with date DATE. The other entries are hidden
116 using selective display.
118 Returns a list of all relevant diary entries found, if any, in order by date.
119 The list entries have the form ((month day year) string). If the variable
120 `diary-list-include-blanks' is t, this list includes a dummy diary entry
121 \(consisting of the empty string) for a date with no diary entries.
123 After the list is prepared, the hooks `nongregorian-diary-listing-hook',
124 `list-diary-entries-hook', `diary-display-hook', and `diary-hook' are run.
125 These hooks have the following distinct roles:
127 `nongregorian-diary-listing-hook' can cull dates from the diary
128 and each included file. Usually used for Hebrew or Islamic
129 diary entries in files. Applied to *each* file.
131 `list-diary-entries-hook' adds or manipulates diary entries from
132 external sources. Used, for example, to include diary entries
133 from other files or to sort the diary entries. Invoked *once* only,
134 before the display hook is run.
136 `diary-display-hook' does the actual display of information. If this is
137 nil, simple-diary-display will be used. Use add-hook to set this to
138 fancy-diary-display, if desired. If you want no diary display, use
139 add-hook to set this to ignore.
141 `diary-hook' is run last. This can be used for an appointment
142 notification function."
145 (let* ((original-date date
);; save for possible use in the hooks
146 (old-diary-syntax-table)
148 (date-string (calendar-date-string date
))
149 (d-file (substitute-in-file-name diary-file
)))
150 (message "Preparing diary...")
152 (let ((diary-buffer (get-file-buffer d-file
)))
153 (set-buffer (if diary-buffer
155 (find-file-noselect d-file t
))))
156 (setq selective-display t
)
157 (setq selective-display-ellipses nil
)
158 (setq old-diary-syntax-table
(syntax-table))
159 (set-syntax-table diary-syntax-table
)
161 (let ((buffer-read-only nil
)
162 (diary-modified (buffer-modified-p))
163 (mark (regexp-quote diary-nonmarking-symbol
)))
164 (goto-char (1- (point-max)))
165 (if (not (looking-at "\^M\\|\n"))
168 (insert-string "\^M")))
169 (goto-char (point-min))
170 (if (not (looking-at "\^M\\|\n"))
171 (insert-string "\^M"))
172 (subst-char-in-region (point-min) (point-max) ?
\n ?\^M t
)
173 (calendar-for-loop i from
1 to number do
174 (let ((d diary-date-forms
)
175 (month (extract-calendar-month date
))
176 (day (extract-calendar-day date
))
177 (year (extract-calendar-year date
))
178 (entry-found (list-sexp-diary-entries date
)))
181 ((date-form (if (equal (car (car d
)) 'backup
)
184 (backup (equal (car (car d
)) 'backup
))
187 (calendar-day-name date
) "\\|"
188 (substring (calendar-day-name date
) 0 3) ".?"))
192 (calendar-month-name month
) "\\|"
193 (substring (calendar-month-name month
) 0 3) ".?"))
194 (month (concat "\\*\\|0*" (int-to-string month
)))
195 (day (concat "\\*\\|0*" (int-to-string day
)))
198 "\\*\\|0*" (int-to-string year
)
199 (if abbreviated-calendar-year
200 (concat "\\|" (int-to-string (% year
100)))
204 "\\(\\`\\|\^M\\|\n\\)" mark
"?\\("
205 (mapconcat 'eval date-form
"\\)\\(")
207 (case-fold-search t
))
208 (goto-char (point-min))
209 (while (re-search-forward regexp nil t
)
210 (if backup
(re-search-backward "\\<" nil t
))
211 (if (and (or (char-equal (preceding-char) ?\^M
)
212 (char-equal (preceding-char) ?
\n))
213 (not (looking-at " \\|\^I")))
214 ;; Diary entry that consists only of date.
216 ;; Found a nonempty diary entry--make it visible and
217 ;; add it to the list.
219 (let ((entry-start (point))
221 (re-search-backward "\^M\\|\n\\|\\`")
222 (setq date-start
(point))
223 (re-search-forward "\^M\\|\n" nil t
2)
224 (while (looking-at " \\|\^I")
225 (re-search-forward "\^M\\|\n" nil t
))
227 (subst-char-in-region date-start
230 date
(buffer-substring entry-start
(point)))))))
233 (not diary-list-include-blanks
)
234 (setq diary-entries-list
235 (append diary-entries-list
236 (list (list date
"")))))
238 (calendar-gregorian-from-absolute
239 (1+ (calendar-absolute-from-gregorian date
))))
240 (setq entry-found nil
)))
241 (set-buffer-modified-p diary-modified
))
242 (set-syntax-table old-diary-syntax-table
))
243 (goto-char (point-min))
244 (run-hooks 'nongregorian-diary-listing-hook
245 'list-diary-entries-hook
)
246 (if diary-display-hook
247 (run-hooks 'diary-display-hook
)
248 (simple-diary-display))
249 (run-hooks 'diary-hook
)
250 diary-entries-list
))))
252 (defun include-other-diary-files ()
253 "Include the diary entries from other diary files with those of diary-file.
254 This function is suitable for use in `list-diary-entries-hook';
255 it enables you to use shared diary files together with your own.
256 The files included are specified in the diaryfile by lines of this form:
257 #include \"filename\"
258 This is recursive; that is, #include directives in diary files thus included
259 are obeyed. You can change the `#include' to some other string by
260 changing the variable `diary-include-string'."
261 (goto-char (point-min))
262 (while (re-search-forward
264 "\\(\\`\\|\^M\\|\n\\)"
265 (regexp-quote diary-include-string
)
268 (let ((diary-file (substitute-in-file-name
269 (buffer-substring (match-beginning 2) (match-end 2))))
270 (diary-list-include-blanks nil
)
271 (list-diary-entries-hook 'include-other-diary-files
)
272 (diary-display-hook 'ignore
)
274 (if (file-exists-p diary-file
)
275 (if (file-readable-p diary-file
)
277 (setq diary-entries-list
278 (append diary-entries-list
279 (list-diary-entries original-date number
)))
280 (kill-buffer (get-file-buffer diary-file
)))
282 (message "Can't read included diary file %s" diary-file
)
285 (message "Can't find included diary file %s" diary-file
)
287 (goto-char (point-min)))
289 (defun simple-diary-display ()
290 "Display the diary buffer if there are any relevant entries or holidays."
291 (let* ((holiday-list (if holidays-in-diary-buffer
292 (check-calendar-holidays original-date
)))
293 (msg (format "No diary entries for %s %s"
294 (concat date-string
(if holiday-list
":" ""))
295 (mapconcat 'identity holiday-list
"; "))))
296 (if (or (not diary-entries-list
)
297 (and (not (cdr diary-entries-list
))
298 (string-equal (car (cdr (car diary-entries-list
))) "")))
299 (if (<= (length msg
) (frame-width))
301 (set-buffer (get-buffer-create holiday-buffer
))
302 (setq buffer-read-only nil
)
303 (calendar-set-mode-line date-string
)
305 (insert (mapconcat 'identity holiday-list
"\n"))
306 (goto-char (point-min))
307 (set-buffer-modified-p nil
)
308 (setq buffer-read-only t
)
309 (display-buffer holiday-buffer
)
310 (message "No diary entries for %s" date-string
))
311 (calendar-set-mode-line
312 (concat "Diary for " date-string
313 (if holiday-list
": " "")
314 (mapconcat 'identity holiday-list
"; ")))
315 (display-buffer (get-file-buffer d-file
))
316 (message "Preparing diary...done"))))
318 (defun fancy-diary-display ()
319 "Prepare a diary buffer with relevant entries in a fancy, noneditable form.
320 This function is provided for optional use as the `diary-display-hook'."
321 (if (or (not diary-entries-list
)
322 (and (not (cdr diary-entries-list
))
323 (string-equal (car (cdr (car diary-entries-list
))) "")))
324 (let* ((holiday-list (if holidays-in-diary-buffer
325 (check-calendar-holidays original-date
)))
326 (msg (format "No diary entries for %s %s"
327 (concat date-string
(if holiday-list
":" ""))
328 (mapconcat 'identity holiday-list
"; "))))
329 (if (<= (length msg
) (frame-width))
331 (set-buffer (get-buffer-create holiday-buffer
))
332 (setq buffer-read-only nil
)
333 (calendar-set-mode-line date-string
)
335 (insert (mapconcat 'identity holiday-list
"\n"))
336 (goto-char (point-min))
337 (set-buffer-modified-p nil
)
338 (setq buffer-read-only t
)
339 (display-buffer holiday-buffer
)
340 (message "No diary entries for %s" date-string
)))
341 (save-excursion;; Turn off selective-display in the diary file's buffer.
342 (set-buffer (get-file-buffer (substitute-in-file-name diary-file
)))
343 (let ((diary-modified (buffer-modified-p)))
344 (subst-char-in-region (point-min) (point-max) ?\^M ?
\n t
)
345 (setq selective-display nil
)
346 (kill-local-variable 'mode-line-format
)
347 (set-buffer-modified-p diary-modified
)))
348 (save-excursion;; Prepare the fancy diary buffer.
349 (set-buffer (get-buffer-create fancy-diary-buffer
))
350 (setq buffer-read-only nil
)
351 (make-local-variable 'mode-line-format
)
352 (calendar-set-mode-line "Diary Entries")
354 (let ((entry-list diary-entries-list
)
356 (holiday-list-last-month 1)
357 (holiday-list-last-year 1)
360 (if (not (calendar-date-equal date
(car (car entry-list
))))
362 (setq date
(car (car entry-list
)))
363 (and holidays-in-diary-buffer
364 (calendar-date-compare
365 (list (list holiday-list-last-month
366 (calendar-last-day-of-month
367 holiday-list-last-month
368 holiday-list-last-year
)
369 holiday-list-last-year
))
371 ;; We need to get the holidays for the next 3 months.
372 (setq holiday-list-last-month
373 (extract-calendar-month date
))
374 (setq holiday-list-last-year
375 (extract-calendar-year date
))
376 (increment-calendar-month
377 holiday-list-last-month holiday-list-last-year
1)
379 (let ((displayed-month holiday-list-last-month
)
380 (displayed-year holiday-list-last-year
))
381 (calendar-holiday-list)))
382 (increment-calendar-month
383 holiday-list-last-month holiday-list-last-year
1))
384 (let* ((date-string (calendar-date-string date
))
386 (let ((h holiday-list
)
388 ;; Make a list of all holidays for date.
390 (if (calendar-date-equal date
(car (car h
)))
391 (setq d
(append d
(cdr (car h
)))))
394 (insert (if (= (point) (point-min)) "" ?
\n) date-string
)
395 (if date-holiday-list
(insert ": "))
396 (let ((l (current-column)))
397 (insert (mapconcat 'identity date-holiday-list
398 (concat "\n" (make-string l ?
)))))
399 (let ((l (current-column)))
400 (insert ?
\n (make-string l ?
=) ?
\n)))))
401 (if (< 0 (length (car (cdr (car entry-list
)))))
402 (insert (car (cdr (car entry-list
))) ?
\n))
403 (setq entry-list
(cdr entry-list
))))
404 (set-buffer-modified-p nil
)
405 (goto-char (point-min))
406 (setq buffer-read-only t
)
407 (display-buffer fancy-diary-buffer
)
408 (message "Preparing diary...done"))))
410 (defun print-diary-entries ()
411 "Print a hard copy of the diary display.
413 If the simple diary display is being used, prepare a temp buffer with the
414 visible lines of the diary buffer, add a heading line composed from the mode
415 line, print the temp buffer, and destroy it.
417 If the fancy diary display is being used, just print the buffer.
419 The hooks given by the variable `print-diary-entries-hook' are called to do
420 the actual printing."
422 (if (bufferp (get-buffer fancy-diary-buffer
))
424 (set-buffer (get-buffer fancy-diary-buffer
))
425 (run-hooks 'print-diary-entries-hook
))
427 (get-file-buffer (substitute-in-file-name diary-file
))))
429 (let ((temp-buffer (get-buffer-create "*Printable Diary Entries*"))
432 (set-buffer diary-buffer
)
434 (if (not (stringp mode-line-format
))
436 (string-match "^-*\\([^-].*[^-]\\)-*$" mode-line-format
)
437 (substring mode-line-format
438 (match-beginning 1) (match-end 1))))
439 (copy-to-buffer temp-buffer
(point-min) (point-max))
440 (set-buffer temp-buffer
)
441 (while (re-search-forward "\^M.*$" nil t
)
443 (goto-char (point-min))
445 (make-string (length heading
) ?
=) "\n")
446 (run-hooks 'print-diary-entries-hook
)
447 (kill-buffer temp-buffer
)))
448 (error "You don't have a diary buffer!")))))
450 (defun show-all-diary-entries ()
451 "Show all of the diary entries in the diary file.
452 This function gets rid of the selective display of the diary file so that
453 all entries, not just some, are visible. If there is no diary buffer, one
456 (let ((d-file (substitute-in-file-name diary-file
)))
457 (if (and d-file
(file-exists-p d-file
))
458 (if (file-readable-p d-file
)
460 (let ((diary-buffer (get-file-buffer d-file
)))
461 (set-buffer (if diary-buffer
463 (find-file-noselect d-file t
)))
464 (let ((buffer-read-only nil
)
465 (diary-modified (buffer-modified-p)))
466 (subst-char-in-region (point-min) (point-max) ?\^M ?
\n t
)
467 (setq selective-display nil
)
468 (make-local-variable 'mode-line-format
)
469 (setq mode-line-format default-mode-line-format
)
470 (display-buffer (current-buffer))
471 (set-buffer-modified-p diary-modified
))))
472 (error "Your diary file is not readable!"))
473 (error "You don't have a diary file!"))))
475 (defun diary-name-pattern (string-array &optional fullname
)
476 "Convert an STRING-ARRAY, an array of strings to a pattern.
477 The pattern will match any of the strings, either entirely or abbreviated
478 to three characters. An abbreviated form will match with or without a period;
479 If the optional FULLNAME is t, abbreviations will not match, just the full
482 (calendar-for-loop i from
0 to
(1- (length string-array
)) do
486 (if (string-equal pattern
"") "" "\\|")
487 (aref string-array i
)
492 (substring (aref string-array i
) 0 3) ".?")))))
495 (defun mark-diary-entries ()
496 "Mark days in the calendar window that have diary entries.
497 Each entry in the diary file visible in the calendar window is marked.
498 After the entries are marked, the hooks `nongregorian-diary-marking-hook' and
499 `mark-diary-entries-hook' are run."
501 (setq mark-diary-entries-in-calendar t
)
502 (let ((d-file (substitute-in-file-name diary-file
)))
503 (if (and d-file
(file-exists-p d-file
))
504 (if (file-readable-p d-file
)
506 (message "Marking diary entries...")
507 (set-buffer (find-file-noselect d-file t
))
508 (let ((d diary-date-forms
)
509 (old-diary-syntax-table))
510 (setq old-diary-syntax-table
(syntax-table))
511 (set-syntax-table diary-syntax-table
)
514 ((date-form (if (equal (car (car d
)) 'backup
)
516 (car d
)));; ignore 'backup directive
517 (dayname (diary-name-pattern calendar-day-name-array
))
520 (diary-name-pattern calendar-month-name-array
)
522 (month "[0-9]+\\|\\*")
524 (year "[0-9]+\\|\\*")
525 (l (length date-form
))
526 (d-name-pos (- l
(length (memq 'dayname date-form
))))
527 (d-name-pos (if (/= l d-name-pos
) (+ 2 d-name-pos
)))
528 (m-name-pos (- l
(length (memq 'monthname date-form
))))
529 (m-name-pos (if (/= l m-name-pos
) (+ 2 m-name-pos
)))
530 (d-pos (- l
(length (memq 'day date-form
))))
531 (d-pos (if (/= l d-pos
) (+ 2 d-pos
)))
532 (m-pos (- l
(length (memq 'month date-form
))))
533 (m-pos (if (/= l m-pos
) (+ 2 m-pos
)))
534 (y-pos (- l
(length (memq 'year date-form
))))
535 (y-pos (if (/= l y-pos
) (+ 2 y-pos
)))
538 "\\(\\`\\|\^M\\|\n\\)\\("
539 (mapconcat 'eval date-form
"\\)\\(")
541 (case-fold-search t
))
542 (goto-char (point-min))
543 (while (re-search-forward regexp nil t
)
547 (match-beginning d-name-pos
)
548 (match-end d-name-pos
))))
552 (match-beginning m-name-pos
)
553 (match-end m-name-pos
))))
557 (match-beginning m-pos
)
563 (match-beginning d-pos
)
568 (match-beginning y-pos
)
572 (if (and (= (length y-str
) 2)
573 abbreviated-calendar-year
)
575 (extract-calendar-year
576 (calendar-current-date)))
577 (y (+ (string-to-int y-str
)
579 (/ current-y
100)))))
580 (if (> (- y current-y
) 50)
582 (if (> (- current-y y
) 50)
585 (string-to-int y-str
)))))
587 (mark-calendar-days-named
588 (cdr (assoc (capitalize (substring dd-name
0 3))
590 calendar-day-name-array
592 '(lambda (x) (substring x
0 3))))))
594 (if (string-equal mm-name
"*")
599 (substring mm-name
0 3))
601 calendar-month-name-array
603 '(lambda (x) (substring x
0 3)))
605 (mark-calendar-date-pattern mm dd yy
))))
607 (mark-sexp-diary-entries)
608 (run-hooks 'nongregorian-diary-marking-hook
609 'mark-diary-entries-hook
)
610 (set-syntax-table old-diary-syntax-table
)
611 (message "Marking diary entries...done")))
612 (error "Your diary file is not readable!"))
613 (error "You don't have a diary file!"))))
615 (defun mark-sexp-diary-entries ()
616 "Mark days in the calendar window that have sexp diary entries.
617 Each entry in the diary file (or included files) visible in the calendar window
618 is marked. See the documentation for the function `list-sexp-diary-entries'."
619 (let* ((sexp-mark (regexp-quote sexp-diary-entry-symbol
))
620 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" sexp-mark
"("))
626 (set-buffer calendar-buffer
)
627 (setq m displayed-month
)
628 (setq y displayed-year
))
629 (increment-calendar-month m y -
1)
631 (calendar-absolute-from-gregorian (list m
1 y
)))
632 (increment-calendar-month m y
2)
634 (calendar-absolute-from-gregorian
635 (list m
(calendar-last-day-of-month m y
) y
)))
636 (goto-char (point-min))
637 (while (re-search-forward s-entry nil t
)
639 (let ((sexp-start (point))
645 (setq sexp
(buffer-substring sexp-start
(point)))
647 (re-search-backward "\^M\\|\n\\|\\`")
648 (setq line-start
(point)))
650 (if (and (or (char-equal (preceding-char) ?\^M
)
651 (char-equal (preceding-char) ?
\n))
652 (not (looking-at " \\|\^I")))
653 (progn;; Diary entry consists only of the sexp
656 (setq entry-start
(point))
657 (re-search-forward "\^M\\|\n" nil t
)
658 (while (looking-at " \\|\^I")
659 (re-search-forward "\^M\\|\n" nil t
))
661 (setq entry
(buffer-substring entry-start
(point)))
662 (while (string-match "[\^M]" entry
)
663 (aset entry
(match-beginning 0) ?
\n )))
664 (calendar-for-loop date from first-date to last-date do
665 (if (diary-sexp-entry sexp entry
666 (calendar-gregorian-from-absolute date
))
667 (mark-visible-calendar-date
668 (calendar-gregorian-from-absolute date
))))))))
670 (defun mark-included-diary-files ()
671 "Mark the diary entries from other diary files with those of the diary file.
672 This function is suitable for use as the `mark-diary-entries-hook'; it enables
673 you to use shared diary files together with your own. The files included are
674 specified in the diary-file by lines of this form:
675 #include \"filename\"
676 This is recursive; that is, #include directives in diary files thus included
677 are obeyed. You can change the `#include' to some other string by
678 changing the variable `diary-include-string'."
679 (goto-char (point-min))
680 (while (re-search-forward
682 "\\(\\`\\|\^M\\|\n\\)"
683 (regexp-quote diary-include-string
)
686 (let ((diary-file (substitute-in-file-name
687 (buffer-substring (match-beginning 2) (match-end 2))))
688 (mark-diary-entries-hook 'mark-included-diary-files
))
689 (if (file-exists-p diary-file
)
690 (if (file-readable-p diary-file
)
693 (kill-buffer (get-file-buffer diary-file
)))
695 (message "Can't read included diary file %s" diary-file
)
698 (message "Can't find included diary file %s" diary-file
)
700 (goto-char (point-min)))
702 (defun mark-calendar-days-named (dayname)
703 "Mark all dates in the calendar window that are day DAYNAME of the week.
704 0 means all Sundays, 1 means all Mondays, and so on."
706 (set-buffer calendar-buffer
)
707 (let ((prev-month displayed-month
)
708 (prev-year displayed-year
)
709 (succ-month displayed-month
)
710 (succ-year displayed-year
)
713 (increment-calendar-month succ-month succ-year
1)
714 (increment-calendar-month prev-month prev-year -
1)
715 (setq day
(calendar-absolute-from-gregorian
716 (calendar-nth-named-day 1 dayname prev-month prev-year
)))
717 (setq last-day
(calendar-absolute-from-gregorian
718 (calendar-nth-named-day -
1 dayname succ-month succ-year
)))
719 (while (<= day last-day
)
720 (mark-visible-calendar-date (calendar-gregorian-from-absolute day
))
721 (setq day
(+ day
7))))))
723 (defun mark-calendar-date-pattern (month day year
)
724 "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR.
725 A value of 0 in any position is a wildcard."
727 (set-buffer calendar-buffer
)
728 (let ((m displayed-month
)
730 (increment-calendar-month m y -
1)
731 (calendar-for-loop i from
0 to
2 do
732 (mark-calendar-month m y month day year
)
733 (increment-calendar-month m y
1)))))
735 (defun mark-calendar-month (month year p-month p-day p-year
)
736 "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR.
737 A value of 0 in any position of the pattern is a wildcard."
738 (if (or (and (= month p-month
)
739 (or (= p-year
0) (= year p-year
)))
741 (or (= p-year
0) (= year p-year
))))
744 i from
1 to
(calendar-last-day-of-month month year
) do
745 (mark-visible-calendar-date (list month i year
)))
746 (mark-visible-calendar-date (list month p-day year
)))))
748 (defun sort-diary-entries ()
749 "Sort the list of diary entries by time of day."
750 (setq diary-entries-list
(sort diary-entries-list
'diary-entry-compare
)))
752 (defun diary-entry-compare (e1 e2
)
753 "Returns t if E1 is earlier than E2."
754 (or (calendar-date-compare e1 e2
)
755 (and (calendar-date-equal (car e1
) (car e2
))
756 (< (diary-entry-time (car (cdr e1
)))
757 (diary-entry-time (car (cdr e2
)))))))
759 (defun diary-entry-time (s)
760 "Time at the beginning of the string S in a military-style integer.
761 For example, returns 1325 for 1:25pm. Returns -9999 if no time is recognized.
762 The recognized forms are XXXX or X:XX or XX:XX (military time), XXam or XXpm,
763 and XX:XXam or XX:XXpm."
764 (cond ((string-match;; Military time
765 "^ *\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s
)
766 (+ (* 100 (string-to-int
767 (substring s
(match-beginning 1) (match-end 1))))
768 (string-to-int (substring s
(match-beginning 2) (match-end 2)))))
769 ((string-match;; Hour only XXam or XXpm
770 "^ *\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s
)
771 (+ (* 100 (%
(string-to-int
772 (substring s
(match-beginning 1) (match-end 1)))
774 (if (string-equal "a"
775 (substring s
(match-beginning 2) (match-end 2)))
777 ((string-match;; Hour and minute XX:XXam or XX:XXpm
778 "^ *\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s
)
779 (+ (* 100 (%
(string-to-int
780 (substring s
(match-beginning 1) (match-end 1)))
782 (string-to-int (substring s
(match-beginning 2) (match-end 2)))
783 (if (string-equal "a"
784 (substring s
(match-beginning 3) (match-end 3)))
786 (t -
9999)));; Unrecognizable
788 (defun list-hebrew-diary-entries ()
789 "Add any Hebrew date entries from the diary file to `diary-entries-list'.
790 Hebrew date diary entries must be prefaced by `hebrew-diary-entry-symbol'
791 (normally an `H'). The same diary date forms govern the style of the Hebrew
792 calendar entries, except that the Hebrew month names must be spelled in full.
793 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
794 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
795 common Hebrew year. If a Hebrew date diary entry begins with a
796 `diary-nonmarking-symbol', the entry will appear in the diary listing, but will
797 not be marked in the calendar. This function is provided for use with the
798 `nongregorian-diary-listing-hook'."
800 (let ((buffer-read-only nil
)
801 (diary-modified (buffer-modified-p))
802 (gdate original-date
)
803 (mark (regexp-quote diary-nonmarking-symbol
)))
804 (calendar-for-loop i from
1 to number do
805 (let* ((d diary-date-forms
)
806 (hdate (calendar-hebrew-from-absolute
807 (calendar-absolute-from-gregorian gdate
)))
808 (month (extract-calendar-month hdate
))
809 (day (extract-calendar-day hdate
))
810 (year (extract-calendar-year hdate
)))
813 ((date-form (if (equal (car (car d
)) 'backup
)
816 (backup (equal (car (car d
)) 'backup
))
819 (calendar-day-name gdate
) "\\|"
820 (substring (calendar-day-name gdate
) 0 3) ".?"))
821 (calendar-month-name-array
822 calendar-hebrew-month-name-array-leap-year
)
826 (calendar-month-name month
)))
827 (month (concat "\\*\\|0*" (int-to-string month
)))
828 (day (concat "\\*\\|0*" (int-to-string day
)))
831 "\\*\\|0*" (int-to-string year
)
832 (if abbreviated-calendar-year
833 (concat "\\|" (int-to-string (% year
100)))
837 "\\(\\`\\|\^M\\|\n\\)" mark
"?"
838 (regexp-quote hebrew-diary-entry-symbol
)
840 (mapconcat 'eval date-form
"\\)\\(")
842 (case-fold-search t
))
843 (goto-char (point-min))
844 (while (re-search-forward regexp nil t
)
845 (if backup
(re-search-backward "\\<" nil t
))
846 (if (and (or (char-equal (preceding-char) ?\^M
)
847 (char-equal (preceding-char) ?
\n))
848 (not (looking-at " \\|\^I")))
849 ;; Diary entry that consists only of date.
851 ;; Found a nonempty diary entry--make it visible and
852 ;; add it to the list.
853 (let ((entry-start (point))
855 (re-search-backward "\^M\\|\n\\|\\`")
856 (setq date-start
(point))
857 (re-search-forward "\^M\\|\n" nil t
2)
858 (while (looking-at " \\|\^I")
859 (re-search-forward "\^M\\|\n" nil t
))
861 (subst-char-in-region date-start
(point) ?\^M ?
\n t
)
863 gdate
(buffer-substring entry-start
(point)))))))
866 (calendar-gregorian-from-absolute
867 (1+ (calendar-absolute-from-gregorian gdate
)))))
868 (set-buffer-modified-p diary-modified
))
869 (goto-char (point-min))))
871 (defun mark-hebrew-diary-entries ()
872 "Mark days in the calendar window that have Hebrew date diary entries.
873 Each entry in diary-file (or included files) visible in the calendar window
874 is marked. Hebrew date entries are prefaced by a hebrew-diary-entry-symbol
875 (normally an `H'). The same diary-date-forms govern the style of the Hebrew
876 calendar entries, except that the Hebrew month names must be spelled in full.
877 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
878 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
879 common Hebrew year. Hebrew date diary entries that begin with a
880 diary-nonmarking symbol will not be marked in the calendar. This function
881 is provided for use as part of the nongregorian-diary-marking-hook."
882 (let ((d diary-date-forms
))
885 ((date-form (if (equal (car (car d
)) 'backup
)
887 (car d
)));; ignore 'backup directive
888 (dayname (diary-name-pattern calendar-day-name-array
))
891 (diary-name-pattern calendar-hebrew-month-name-array-leap-year t
)
893 (month "[0-9]+\\|\\*")
895 (year "[0-9]+\\|\\*")
896 (l (length date-form
))
897 (d-name-pos (- l
(length (memq 'dayname date-form
))))
898 (d-name-pos (if (/= l d-name-pos
) (+ 2 d-name-pos
)))
899 (m-name-pos (- l
(length (memq 'monthname date-form
))))
900 (m-name-pos (if (/= l m-name-pos
) (+ 2 m-name-pos
)))
901 (d-pos (- l
(length (memq 'day date-form
))))
902 (d-pos (if (/= l d-pos
) (+ 2 d-pos
)))
903 (m-pos (- l
(length (memq 'month date-form
))))
904 (m-pos (if (/= l m-pos
) (+ 2 m-pos
)))
905 (y-pos (- l
(length (memq 'year date-form
))))
906 (y-pos (if (/= l y-pos
) (+ 2 y-pos
)))
909 "\\(\\`\\|\^M\\|\n\\)"
910 (regexp-quote hebrew-diary-entry-symbol
)
912 (mapconcat 'eval date-form
"\\)\\(")
914 (case-fold-search t
))
915 (goto-char (point-min))
916 (while (re-search-forward regexp nil t
)
920 (match-beginning d-name-pos
)
921 (match-end d-name-pos
))))
925 (match-beginning m-name-pos
)
926 (match-end m-name-pos
))))
930 (match-beginning m-pos
)
936 (match-beginning d-pos
)
941 (match-beginning y-pos
)
945 (if (and (= (length y-str
) 2)
946 abbreviated-calendar-year
)
948 (extract-calendar-year
949 (calendar-hebrew-from-absolute
950 (calendar-absolute-from-gregorian
951 (calendar-current-date)))))
952 (y (+ (string-to-int y-str
)
953 (* 100 (/ current-y
100)))))
954 (if (> (- y current-y
) 50)
956 (if (> (- current-y y
) 50)
959 (string-to-int y-str
)))))
961 (mark-calendar-days-named
962 (cdr (assoc (capitalize (substring dd-name
0 3))
964 calendar-day-name-array
966 '(lambda (x) (substring x
0 3))))))
968 (if (string-equal mm-name
"*")
976 calendar-hebrew-month-name-array-leap-year
))))))
977 (mark-hebrew-calendar-date-pattern mm dd yy
)))))
980 (defun mark-hebrew-calendar-date-pattern (month day year
)
981 "Mark dates in calendar window that conform to Hebrew date MONTH/DAY/YEAR.
982 A value of 0 in any position is a wildcard."
984 (set-buffer calendar-buffer
)
985 (if (and (/= 0 month
) (/= 0 day
))
987 ;; Fully specified Hebrew date.
988 (let ((date (calendar-gregorian-from-absolute
989 (calendar-absolute-from-hebrew
990 (list month day year
)))))
991 (if (calendar-date-is-visible-p date
)
992 (mark-visible-calendar-date date
)))
993 ;; Month and day in any year--this taken from the holiday stuff.
994 (if (memq displayed-month
;; This test is only to speed things up a
995 (list ;; bit; it works fine without the test too.
996 (if (< 11 month
) (- month
11) (+ month
1))
997 (if (< 10 month
) (- month
10) (+ month
2))
998 (if (< 9 month
) (- month
9) (+ month
3))
999 (if (< 8 month
) (- month
8) (+ month
4))
1000 (if (< 7 month
) (- month
7) (+ month
5))))
1001 (let ((m1 displayed-month
)
1003 (m2 displayed-month
)
1006 (increment-calendar-month m1 y1 -
1)
1007 (increment-calendar-month m2 y2
1)
1008 (let* ((start-date (calendar-absolute-from-gregorian
1010 (end-date (calendar-absolute-from-gregorian
1012 (calendar-last-day-of-month m2 y2
)
1015 (calendar-hebrew-from-absolute start-date
))
1016 (hebrew-end (calendar-hebrew-from-absolute end-date
))
1017 (hebrew-y1 (extract-calendar-year hebrew-start
))
1018 (hebrew-y2 (extract-calendar-year hebrew-end
)))
1019 (setq year
(if (< 6 month
) hebrew-y2 hebrew-y1
))
1020 (let ((date (calendar-gregorian-from-absolute
1021 (calendar-absolute-from-hebrew
1022 (list month day year
)))))
1023 (if (calendar-date-is-visible-p date
)
1024 (mark-visible-calendar-date date
)))))))
1025 ;; Not one of the simple cases--check all visible dates for match.
1026 ;; Actually, the following code takes care of ALL of the cases, but
1027 ;; it's much too slow to be used for the simple (common) cases.
1028 (let ((m displayed-month
)
1032 (increment-calendar-month m y -
1)
1034 (calendar-absolute-from-gregorian
1036 (increment-calendar-month m y
2)
1038 (calendar-absolute-from-gregorian
1039 (list m
(calendar-last-day-of-month m y
) y
)))
1040 (calendar-for-loop date from first-date to last-date do
1041 (let* ((h-date (calendar-hebrew-from-absolute date
))
1042 (h-month (extract-calendar-month h-date
))
1043 (h-day (extract-calendar-day h-date
))
1044 (h-year (extract-calendar-year h-date
)))
1045 (and (or (zerop month
)
1051 (mark-visible-calendar-date
1052 (calendar-gregorian-from-absolute date
)))))))))
1054 (defun list-sexp-diary-entries (date)
1055 "Add sexp entries for DATE from the diary file to `diary-entries-list'.
1056 Also, Make them visible in the diary file. Returns t if any entries were
1059 Sexp diary entries must be prefaced by a `sexp-diary-entry-symbol' (normally
1060 `%%'). The form of a sexp diary entry is
1064 Both ENTRY and DATE are globally available when the SEXP is evaluated. If the
1065 SEXP yields the value nil, the diary entry does not apply. If it yields a
1066 non-nil value, ENTRY will be taken to apply to DATE; if the non-nil value is a
1067 string, that string will be the diary entry in the fancy diary display.
1069 For example, the following diary entry will apply to the 21st of the month
1070 if it is a weekday and the Friday before if the 21st is on a weekend:
1072 &%%(let ((dayname (calendar-day-of-week date))
1073 (day (extract-calendar-day date)))
1075 (and (= day 21) (memq dayname '(1 2 3 4 5)))
1076 (and (memq day '(19 20)) (= dayname 5)))
1077 ) UIUC pay checks deposited
1079 A number of built-in functions are available for this type of diary entry:
1081 %%(diary-float MONTH DAYNAME N) text
1082 Entry will appear on the Nth DAYNAME of MONTH.
1083 (DAYNAME=0 means Sunday, 1 means Monday, and so on;
1084 if N is negative it counts backward from the end of
1085 the month. MONTH can be a list of months, a single
1086 month, or t to specify all months.
1088 %%(diary-block M1 D1 Y1 M2 D2 Y2) text
1089 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2,
1090 inclusive. (If `european-calendar-style' is t, the
1091 order of the parameters should be changed to D1, M1, Y1,
1094 %%(diary-anniversary MONTH DAY YEAR) text
1095 Entry will appear on anniversary dates of MONTH DAY, YEAR.
1096 (If `european-calendar-style' is t, the order of the
1097 parameters should be changed to DAY, MONTH, YEAR.) Text
1098 can contain %d or %d%s; %d will be replaced by the number
1099 of years since the MONTH DAY, YEAR and %s will be replaced
1100 by the ordinal ending of that number (that is, `st', `nd',
1101 `rd' or `th', as appropriate. The anniversary of February
1102 29 is considered to be March 1 in a non-leap year.
1104 %%(diary-cyclic N MONTH DAY YEAR) text
1105 Entry will appear every N days, starting MONTH DAY, YEAR.
1106 (If `european-calendar-style' is t, the order of the
1107 parameters should be changed to N, DAY, MONTH, YEAR.) Text
1108 can contain %d or %d%s; %d will be replaced by the number
1109 of repetitions since the MONTH DAY, YEAR and %s will
1110 be replaced by the ordinal ending of that number (that is,
1111 `st', `nd', `rd' or `th', as appropriate.
1113 %%(diary-day-of-year)
1114 Diary entries giving the day of the year and the number of
1115 days remaining in the year will be made every day. Note
1116 that since there is no text, it makes sense only if the
1117 fancy diary display is used.
1120 Diary entries giving the corresponding ISO commercial date
1121 will be made every day. Note that since there is no text,
1122 it makes sense only if the fancy diary display is used.
1124 %%(diary-french-date)
1125 Diary entries giving the corresponding French Revolutionary
1126 date will be made every day. Note that since there is no
1127 text, it makes sense only if the fancy diary display is used.
1129 %%(diary-islamic-date)
1130 Diary entries giving the corresponding Islamic date will be
1131 made every day. Note that since there is no text, it
1132 makes sense only if the fancy diary display is used.
1134 %%(diary-hebrew-date)
1135 Diary entries giving the corresponding Hebrew date will be
1136 made every day. Note that since there is no text, it
1137 makes sense only if the fancy diary display is used.
1139 %%(diary-astro-day-number) Diary entries giving the corresponding
1140 astronomical (Julian) day number will be made every day.
1141 Note that since there is no text, it makes sense only if the
1142 fancy diary display is used.
1144 %%(diary-julian-date) Diary entries giving the corresponding
1145 Julian date will be made every day. Note that since
1146 there is no text, it makes sense only if the fancy diary
1149 %%(diary-sunrise-sunset)
1150 Diary entries giving the local times of sunrise and sunset
1151 will be made every day. Note that since there is no text,
1152 it makes sense only if the fancy diary display is used.
1153 Floating point required.
1155 %%(diary-phases-of-moon)
1156 Diary entries giving the times of the phases of the moon
1157 will be when appropriate. Note that since there is no text,
1158 it makes sense only if the fancy diary display is used.
1159 Floating point required.
1161 %%(diary-yahrzeit MONTH DAY YEAR) text
1162 Text is assumed to be the name of the person; the date is
1163 the date of death on the *civil* calendar. The diary entry
1164 will appear on the proper Hebrew-date anniversary and on the
1165 day before. (If `european-calendar-style' is t, the order
1166 of the parameters should be changed to DAY, MONTH, YEAR.)
1168 %%(diary-rosh-hodesh)
1169 Diary entries will be made on the dates of Rosh Hodesh on
1170 the Hebrew calendar. Note that since there is no text, it
1171 makes sense only if the fancy diary display is used.
1174 Diary entries giving the weekly parasha will be made on
1175 every Saturday. Note that since there is no text, it
1176 makes sense only if the fancy diary display is used.
1179 Diary entries giving the omer count will be made every day
1180 from Passover to Shavuoth. Note that since there is no text,
1181 it makes sense only if the fancy diary display is used.
1183 Marking these entries is *extremely* time consuming, so these entries are
1184 best if they are nonmarking."
1185 (let* ((mark (regexp-quote diary-nonmarking-symbol
))
1186 (sexp-mark (regexp-quote sexp-diary-entry-symbol
))
1187 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" mark
"?" sexp-mark
"("))
1189 (goto-char (point-min))
1190 (while (re-search-forward s-entry nil t
)
1192 (let ((sexp-start (point))
1198 (setq sexp
(buffer-substring sexp-start
(point)))
1200 (re-search-backward "\^M\\|\n\\|\\`")
1201 (setq line-start
(point)))
1203 (if (and (or (char-equal (preceding-char) ?\^M
)
1204 (char-equal (preceding-char) ?
\n))
1205 (not (looking-at " \\|\^I")))
1206 (progn;; Diary entry consists only of the sexp
1209 (setq entry-start
(point))
1210 (re-search-forward "\^M\\|\n" nil t
)
1211 (while (looking-at " \\|\^I")
1212 (re-search-forward "\^M\\|\n" nil t
))
1214 (setq entry
(buffer-substring entry-start
(point)))
1215 (while (string-match "[\^M]" entry
)
1216 (aset entry
(match-beginning 0) ?
\n )))
1217 (let ((diary-entry (diary-sexp-entry sexp entry date
)))
1219 (subst-char-in-region line-start
(point) ?\^M ?
\n t
))
1220 (add-to-diary-list date diary-entry
)
1221 (setq entry-found
(or entry-found diary-entry
)))))
1224 (defun diary-sexp-entry (sexp entry date
)
1225 "Process a SEXP diary ENTRY for DATE."
1226 (let ((result (if calendar-debug-sexp
1227 (let ((stack-trace-on-error t
))
1228 (eval (car (read-from-string sexp
))))
1230 (eval (car (read-from-string sexp
)))
1233 (message "Bad sexp at line %d in %s: %s"
1236 (narrow-to-region 1 (point))
1237 (goto-char (point-min))
1239 (while (re-search-forward "\n\\|\^M" nil t
)
1240 (setq lines
(1+ lines
)))
1244 (if (stringp result
)
1250 (defun diary-block (m1 d1 y1 m2 d2 y2
)
1252 Entry applies if date is between two dates. Order of the parameters is
1253 M1, D1, Y1, M2, D2, Y2 `european-calendar-style' is nil, and
1254 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t."
1255 (let ((date1 (calendar-absolute-from-gregorian
1256 (if european-calendar-style
1259 (date2 (calendar-absolute-from-gregorian
1260 (if european-calendar-style
1263 (d (calendar-absolute-from-gregorian date
)))
1264 (if (and (<= date1 d
) (<= d date2
))
1267 (defun diary-float (month dayname n
)
1268 "Floating diary entry--entry applies if date is the nth dayname of month.
1269 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant
1270 t, or an integer. The constant t means all months. If N is negative, count
1271 backward from the end of the month."
1272 (let ((m (extract-calendar-month date
))
1273 (y (extract-calendar-year date
)))
1275 (or (and (listp month
) (memq m month
))
1278 (calendar-date-equal date
(calendar-nth-named-day n dayname m y
)))
1281 (defun diary-anniversary (month day year
)
1282 "Anniversary diary entry.
1283 Entry applies if date is the anniversary of MONTH, DAY, YEAR if
1284 `european-calendar-style' is nil, and DAY, MONTH, YEAR if
1285 `european-calendar-style' is t. Diary entry can contain `%d' or `%d%s'; the
1286 %d will be replaced by the number of years since the MONTH DAY, YEAR and the
1287 %s will be replaced by the ordinal ending of that number (that is, `st', `nd',
1288 `rd' or `th', as appropriate. The anniversary of February 29 is considered
1289 to be March 1 in non-leap years."
1290 (let* ((d (if european-calendar-style
1293 (m (if european-calendar-style
1296 (y (extract-calendar-year date
))
1298 (if (and (= m
2) (= d
29) (not (calendar-leap-year-p y
)))
1301 (if (and (> diff
0) (calendar-date-equal (list m d y
) date
))
1302 (format entry diff
(diary-ordinal-suffix diff
)))))
1304 (defun diary-cyclic (n month day year
)
1305 "Cycle diary entry--entry applies every N days starting at MONTH, DAY, YEAR.
1306 If `european-calendar-style' is t, parameters are N, DAY, MONTH, YEAR.
1307 ENTRY can contain `%d' or `%d%s'; the %d will be replaced by the number of
1308 years since the MONTH DAY, YEAR and the %s will be replaced by the ordinal
1309 ending of that number (that is, `st', `nd', `rd' or `th', as appropriate."
1310 (let* ((d (if european-calendar-style
1313 (m (if european-calendar-style
1316 (diff (- (calendar-absolute-from-gregorian date
)
1317 (calendar-absolute-from-gregorian
1320 (if (and (>= diff
0) (zerop (% diff n
)))
1321 (format entry cycle
(diary-ordinal-suffix cycle
)))))
1323 (defun diary-ordinal-suffix (n)
1324 "Ordinal suffix for N. (That is, `st', `nd', `rd', or `th', as appropriate.)"
1325 (if (or (memq (% n
100) '(11 12 13))
1328 (aref ["th" "st" "nd" "rd"] (% n
10))))
1330 (defun diary-day-of-year ()
1331 "Day of year and number of days remaining in the year of date diary entry."
1332 (calendar-day-of-year-string date
))
1334 (defun diary-iso-date ()
1335 "ISO calendar equivalent of date diary entry."
1336 (format "ISO date: %s" (calendar-iso-date-string date
)))
1338 (defun diary-islamic-date ()
1339 "Islamic calendar equivalent of date diary entry."
1340 (let ((i (calendar-islamic-date-string (calendar-cursor-to-date t
))))
1341 (if (string-equal i
"")
1342 "Date is pre-Islamic"
1343 (format "Islamic date (until sunset): %s" i
))))
1345 (defun diary-hebrew-date ()
1346 "Hebrew calendar equivalent of date diary entry."
1347 (format "Hebrew date (until sunset): %s" (calendar-hebrew-date-string date
)))
1349 (defun diary-julian-date ()
1350 "Julian calendar equivalent of date diary entry."
1351 (format "Julian date: %s" (calendar-julian-date-string date
)))
1353 (defun diary-astro-day-number ()
1354 "Astronomical (Julian) day number diary entry."
1355 (format "Astronomical (Julian) day number %s"
1356 (calendar-astro-date-string date
)))
1358 (defun diary-omer ()
1359 "Omer count diary entry.
1360 Entry applies if date is within 50 days after Passover."
1362 (calendar-absolute-from-hebrew
1363 (list 1 15 (+ (extract-calendar-year date
) 3760))))
1364 (omer (- (calendar-absolute-from-gregorian date
) passover
))
1367 (if (and (> omer
0) (< omer
50))
1368 (format "Day %d%s of the omer (until sunset)"
1372 (format ", that is, %d week%s%s"
1374 (if (= week
1) "" "s")
1377 (format " and %d day%s"
1378 day
(if (= day
1) "" "s")))))))))
1380 (defun diary-yahrzeit (death-month death-day death-year
)
1381 "Yahrzeit diary entry--entry applies if date is yahrzeit or the day before.
1382 Parameters are DEATH-MONTH, DEATH-DAY, DEATH-YEAR; the diary entry is assumed
1383 to be the name of the person. Date of death is on the *civil* calendar;
1384 although the date of death is specified by the civil calendar, the proper
1385 Hebrew calendar yahrzeit is determined. If `european-calendar-style' is t, the
1386 order of the parameters is changed to DEATH-DAY, DEATH-MONTH, DEATH-YEAR."
1387 (let* ((h-date (calendar-hebrew-from-absolute
1388 (calendar-absolute-from-gregorian
1389 (if european-calendar-style
1390 (list death-day death-month death-year
)
1391 (list death-month death-day death-year
)))))
1392 (h-month (extract-calendar-month h-date
))
1393 (h-day (extract-calendar-day h-date
))
1394 (h-year (extract-calendar-year h-date
))
1395 (d (calendar-absolute-from-gregorian date
))
1396 (yr (extract-calendar-year (calendar-hebrew-from-absolute d
)))
1397 (diff (- yr h-year
))
1398 (y (hebrew-calendar-yahrzeit h-date yr
)))
1399 (if (and (> diff
0) (or (= y d
) (= y
(1+ d
))))
1400 (format "Yahrzeit of %s%s: %d%s anniversary"
1402 (if (= y d
) "" " (evening)")
1404 (cond ((= (% diff
10) 1) "st")
1405 ((= (% diff
10) 2) "nd")
1406 ((= (% diff
10) 3) "rd")
1409 (defun diary-rosh-hodesh ()
1410 "Rosh Hodesh diary entry.
1411 Entry applies if date is Rosh Hodesh, the day before, or the Saturday before."
1412 (let* ((d (calendar-absolute-from-gregorian date
))
1413 (h-date (calendar-hebrew-from-absolute d
))
1414 (h-month (extract-calendar-month h-date
))
1415 (h-day (extract-calendar-day h-date
))
1416 (h-year (extract-calendar-year h-date
))
1417 (leap-year (hebrew-calendar-leap-year-p h-year
))
1418 (last-day (hebrew-calendar-last-day-of-month h-month h-year
))
1421 calendar-hebrew-month-name-array-leap-year
1422 calendar-hebrew-month-name-array-common-year
))
1423 (this-month (aref h-month-names
(1- h-month
)))
1424 (h-yesterday (extract-calendar-day
1425 (calendar-hebrew-from-absolute (1- d
)))))
1426 (if (or (= h-day
30) (and (= h-day
1) (/= h-month
7)))
1432 ;; next month must be in the same year since this
1433 ;; month can't be the last month of the year since
1435 (aref h-month-names h-month
))
1436 (if (= h-yesterday
30)
1437 (format "%s (second day)" this-month
)
1439 (if (= (% d
7) 6);; Saturday--check for Shabbat Mevarhim
1440 (cond ((and (> h-day
22) (/= h-month
6) (= 29 last-day
))
1441 (format "Mevarhim Rosh Hodesh %s (%s)"
1444 (hebrew-calendar-last-month-of-year
1447 (aref calendar-day-name-array
(- 29 h-day
))))
1448 ((and (< h-day
30) (> h-day
22) (= 30 last-day
))
1449 (format "Mevarhim Rosh Hodesh %s (%s-%s)"
1450 (aref h-month-names h-month
)
1453 (aref calendar-day-name-array
(- 29 h-day
)))
1454 (aref calendar-day-name-array
1455 (%
(- 30 h-day
) 7)))))
1456 (if (and (= h-day
29) (/= h-month
6))
1457 (format "Erev Rosh Hodesh %s"
1460 (hebrew-calendar-last-month-of-year
1464 (defun diary-parasha ()
1465 "Parasha diary entry--entry applies if date is a Saturday."
1466 (let ((d (calendar-absolute-from-gregorian date
)))
1467 (if (= (% d
7) 6);; Saturday
1469 ((h-year (extract-calendar-year
1470 (calendar-hebrew-from-absolute d
)))
1472 (calendar-absolute-from-hebrew (list 7 1 h-year
)))
1474 (calendar-absolute-from-hebrew (list 1 15 h-year
)))
1476 (aref calendar-day-name-array
(% rosh-hashannah
7)))
1478 (aref calendar-day-name-array
(% passover
7)))
1479 (long-h (hebrew-calendar-long-heshvan-p h-year
))
1480 (short-k (hebrew-calendar-short-kislev-p h-year
))
1481 (type (cond ((and long-h
(not short-k
)) "complete")
1482 ((and (not long-h
) short-k
) "incomplete")
1486 (intern (format "hebrew-calendar-year-%s-%s-%s";; keviah
1487 rosh-hashannah-day type passover-day
))))
1488 (first-saturday;; of Hebrew year
1489 (calendar-dayname-on-or-before 6 (+ 6 rosh-hashannah
)))
1490 (saturday;; which Saturday of the Hebrew year
1491 (/ (- d first-saturday
) 7))
1492 (parasha (aref year-format saturday
)))
1496 (if (listp parasha
);; Israel differs from diaspora
1498 (format "%s (diaspora), %s (Israel)"
1499 (hebrew-calendar-parasha-name (car parasha
))
1500 (hebrew-calendar-parasha-name (cdr parasha
)))
1501 (format "%s (Israel)"
1502 (hebrew-calendar-parasha-name (cdr parasha
))))
1503 (hebrew-calendar-parasha-name parasha
))))))))
1505 (defun add-to-diary-list (date string
)
1506 "Add the entry (DATE STRING) to `diary-entries-list'.
1507 Do nothing if DATE or STRING is nil."
1509 (setq diary-entries-list
1510 (append diary-entries-list
(list (list date string
))))))
1512 (defvar hebrew-calendar-parashiot-names
1513 ["Bereshith" "Noah" "Lech L'cha" "Vayera" "Hayei Sarah" "Toledoth"
1514 "Vayetze" "Vayishlah" "Vayeshev" "Mikketz" "Vayiggash" "Vayhi"
1515 "Shemoth" "Vaera" "Bo" "Beshallah" "Yithro" "Mishpatim"
1516 "Terumah" "Tetzavveh" "Ki Tissa" "Vayakhel" "Pekudei" "Vayikra"
1517 "Tzav" "Shemini" "Tazria" "Metzora" "Aharei Moth" "Kedoshim"
1518 "Emor" "Behar" "Behukkotai" "Bemidbar" "Naso" "Behaalot'cha"
1519 "Shelah L'cha" "Korah" "Hukkath" "Balak" "Pinhas" "Mattoth"
1520 "Masei" "Devarim" "Vaethanan" "Ekev" "Reeh" "Shofetim"
1521 "Ki Tetze" "Ki Tavo" "Nitzavim" "Vayelech" "Haazinu"]
1522 "The names of the parashiot in the Torah.")
1524 ;; The seven ordinary year types (keviot)
1526 (defconst hebrew-calendar-year-Saturday-incomplete-Sunday
1527 [nil
52 nil nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1528 23 24 nil
25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1529 43 44 45 46 47 48 49 50]
1530 "The structure of the parashiot.
1531 Hebrew year starts on Saturday, is `incomplete' (Heshvan and Kislev each have
1532 29 days), and has Passover start on Sunday.")
1534 (defconst hebrew-calendar-year-Saturday-complete-Tuesday
1535 [nil
52 nil nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1536 23 24 nil
25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1537 43 44 45 46 47 48 49 [50 51]]
1538 "The structure of the parashiot.
1539 Hebrew year that starts on Saturday, is `complete' (Heshvan and Kislev each
1540 have 30 days), and has Passover start on Tuesday.")
1542 (defconst hebrew-calendar-year-Monday-incomplete-Tuesday
1543 [51 52 nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1544 23 24 nil
25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1545 43 44 45 46 47 48 49 [50 51]]
1546 "The structure of the parashiot.
1547 Hebrew year that starts on Monday, is `incomplete' (Heshvan and Kislev each
1548 have 29 days), and has Passover start on Tuesday.")
1550 (defconst hebrew-calendar-year-Monday-complete-Thursday
1551 [51 52 nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1552 23 24 nil
25 [26 27] [28 29] 30 [31 32] 33 (nil .
34) (34 .
35) (35 .
36)
1553 (36 .
37) (37 .
38) ([38 39] .
39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1554 "The structure of the parashiot.
1555 Hebrew year that starts on Monday, is `complete' (Heshvan and Kislev each have
1556 30 days), and has Passover start on Thursday.")
1558 (defconst hebrew-calendar-year-Tuesday-regular-Thursday
1559 [51 52 nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
1560 23 24 nil
25 [26 27] [28 29] 30 [31 32] 33 (nil .
34) (34 .
35) (35 .
36)
1561 (36 .
37) (37 .
38) ([38 39] .
39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1562 "The structure of the parashiot.
1563 Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29 days and
1564 Kislev has 30 days), and has Passover start on Thursday.")
1566 (defconst hebrew-calendar-year-Thursday-regular-Saturday
1567 [52 nil nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22] 23
1568 24 nil
(nil .
25) (25 .
[26 27]) ([26 27] .
[28 29]) ([28 29] .
30)
1569 (30 .
31) ([31 32] .
32) 33 34 35 36 37 38 39 40 [41 42] 43 44 45 46 47 48
1571 "The structure of the parashiot.
1572 Hebrew year that starts on Thursday, is `regular' (Heshvan has 29 days and
1573 Kislev has 30 days), and has Passover start on Saturday.")
1575 (defconst hebrew-calendar-year-Thursday-complete-Sunday
1576 [52 nil nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1577 23 24 nil
25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
1578 43 44 45 46 47 48 49 50]
1579 "The structure of the parashiot.
1580 Hebrew year that starts on Thursday, is `complete' (Heshvan and Kislev each
1581 have 30 days), and has Passover start on Sunday.")
1583 ;; The seven leap year types (keviot)
1585 (defconst hebrew-calendar-year-Saturday-incomplete-Tuesday
1586 [nil
52 nil nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1587 23 24 25 26 27 nil
28 29 30 31 32 33 34 35 36 37 38 39 40 [41 42]
1588 43 44 45 46 47 48 49 [50 51]]
1589 "The structure of the parashiot.
1590 Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev each
1591 have 29 days), and has Passover start on Tuesday.")
1593 (defconst hebrew-calendar-year-Saturday-complete-Thursday
1594 [nil
52 nil nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1595 23 24 25 26 27 nil
28 29 30 31 32 33 (nil .
34) (34 .
35) (35 .
36)
1596 (36 .
37) (37 .
38) ([38 39] .
39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1597 "The structure of the parashiot.
1598 Hebrew year that starts on Saturday, is `complete' (Heshvan and Kislev each
1599 have 30 days), and has Passover start on Thursday.")
1601 (defconst hebrew-calendar-year-Monday-incomplete-Thursday
1602 [51 52 nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1603 23 24 25 26 27 nil
28 29 30 31 32 33 (nil .
34) (34 .
35) (35 .
36)
1604 (36 .
37) (37 .
38) ([38 39] .
39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
1605 "The structure of the parashiot.
1606 Hebrew year that starts on Monday, is `incomplete' (Heshvan and Kislev each
1607 have 29 days), and has Passover start on Thursday.")
1609 (defconst hebrew-calendar-year-Monday-complete-Saturday
1610 [51 52 nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1611 23 24 25 26 27 nil
(nil .
28) (28 .
29) (29 .
30) (30 .
31) (31 .
32)
1612 (32 .
33) (33 .
34) (34 .
35) (35 .
36) (36 .
37) (37 .
38) (38 .
39)
1613 (39 .
40) (40 .
41) ([41 42] .
42) 43 44 45 46 47 48 49 50]
1614 "The structure of the parashiot.
1615 Hebrew year that starts on Monday, is `complete' (Heshvan and Kislev each have
1616 30 days), and has Passover start on Saturday.")
1618 (defconst hebrew-calendar-year-Tuesday-regular-Saturday
1619 [51 52 nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1620 23 24 25 26 27 nil
(nil .
28) (28 .
29) (29 .
30) (30 .
31) (31 .
32)
1621 (32 .
33) (33 .
34) (34 .
35) (35 .
36) (36 .
37) (37 .
38) (38 .
39)
1622 (39 .
40) (40 .
41) ([41 42] .
42) 43 44 45 46 47 48 49 50]
1623 "The structure of the parashiot.
1624 Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29 days and
1625 Kislev has 30 days), and has Passover start on Saturday.")
1627 (defconst hebrew-calendar-year-Thursday-incomplete-Sunday
1628 [52 nil nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1629 23 24 25 26 27 28 nil
29 30 31 32 33 34 35 36 37 38 39 40 41 42
1630 43 44 45 46 47 48 49 50]
1631 "The structure of the parashiot.
1632 Hebrew year that starts on Thursday, is `incomplete' (Heshvan and Kislev both
1633 have 29 days), and has Passover start on Sunday.")
1635 (defconst hebrew-calendar-year-Thursday-complete-Tuesday
1636 [52 nil nil
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1637 23 24 25 26 27 28 nil
29 30 31 32 33 34 35 36 37 38 39 40 41 42
1638 43 44 45 46 47 48 49 [50 51]]
1639 "The structure of the parashiot.
1640 Hebrew year that starts on Thursday, is `complete' (Heshvan and Kislev both
1641 have 30 days), and has Passover start on Tuesday.")
1643 (defun hebrew-calendar-parasha-name (p)
1644 "Name(s) corresponding to parasha P."
1645 (if (arrayp p
);; combined parasha
1647 (aref hebrew-calendar-parashiot-names
(aref p
0))
1648 (aref hebrew-calendar-parashiot-names
(aref p
1)))
1649 (aref hebrew-calendar-parashiot-names p
)))
1651 (defun list-islamic-diary-entries ()
1652 "Add any Islamic date entries from the diary file to `diary-entries-list'.
1653 Islamic date diary entries must be prefaced by an `islamic-diary-entry-symbol'
1654 (normally an `I'). The same diary date forms govern the style of the Islamic
1655 calendar entries, except that the Islamic month names must be spelled in full.
1656 The Islamic months are numbered from 1 to 12 with Muharram being 1 and 12 being
1657 Dhu al-Hijjah. If an Islamic date diary entry begins with a
1658 `diary-nonmarking-symbol', the entry will appear in the diary listing, but will
1659 not be marked in the calendar. This function is provided for use with the
1660 `nongregorian-diary-listing-hook'."
1662 (let ((buffer-read-only nil
)
1663 (diary-modified (buffer-modified-p))
1664 (gdate original-date
)
1665 (mark (regexp-quote diary-nonmarking-symbol
)))
1666 (calendar-for-loop i from
1 to number do
1667 (let* ((d diary-date-forms
)
1668 (idate (calendar-islamic-from-absolute
1669 (calendar-absolute-from-gregorian gdate
)))
1670 (month (extract-calendar-month idate
))
1671 (day (extract-calendar-day idate
))
1672 (year (extract-calendar-year idate
)))
1675 ((date-form (if (equal (car (car d
)) 'backup
)
1678 (backup (equal (car (car d
)) 'backup
))
1681 (calendar-day-name gdate
) "\\|"
1682 (substring (calendar-day-name gdate
) 0 3) ".?"))
1683 (calendar-month-name-array
1684 calendar-islamic-month-name-array
)
1688 (calendar-month-name month
)))
1689 (month (concat "\\*\\|0*" (int-to-string month
)))
1690 (day (concat "\\*\\|0*" (int-to-string day
)))
1693 "\\*\\|0*" (int-to-string year
)
1694 (if abbreviated-calendar-year
1695 (concat "\\|" (int-to-string (% year
100)))
1699 "\\(\\`\\|\^M\\|\n\\)" mark
"?"
1700 (regexp-quote islamic-diary-entry-symbol
)
1702 (mapconcat 'eval date-form
"\\)\\(")
1704 (case-fold-search t
))
1705 (goto-char (point-min))
1706 (while (re-search-forward regexp nil t
)
1707 (if backup
(re-search-backward "\\<" nil t
))
1708 (if (and (or (char-equal (preceding-char) ?\^M
)
1709 (char-equal (preceding-char) ?
\n))
1710 (not (looking-at " \\|\^I")))
1711 ;; Diary entry that consists only of date.
1713 ;; Found a nonempty diary entry--make it visible and
1714 ;; add it to the list.
1715 (let ((entry-start (point))
1717 (re-search-backward "\^M\\|\n\\|\\`")
1718 (setq date-start
(point))
1719 (re-search-forward "\^M\\|\n" nil t
2)
1720 (while (looking-at " \\|\^I")
1721 (re-search-forward "\^M\\|\n" nil t
))
1723 (subst-char-in-region date-start
(point) ?\^M ?
\n t
)
1725 gdate
(buffer-substring entry-start
(point)))))))
1728 (calendar-gregorian-from-absolute
1729 (1+ (calendar-absolute-from-gregorian gdate
)))))
1730 (set-buffer-modified-p diary-modified
))
1731 (goto-char (point-min))))
1733 (defun mark-islamic-diary-entries ()
1734 "Mark days in the calendar window that have Islamic date diary entries.
1735 Each entry in diary-file (or included files) visible in the calendar window
1736 is marked. Islamic date entries are prefaced by a islamic-diary-entry-symbol
1737 (normally an `I'). The same diary-date-forms govern the style of the Islamic
1738 calendar entries, except that the Islamic month names must be spelled in full.
1739 The Islamic months are numbered from 1 to 12 with Muharram being 1 and 12 being
1740 Dhu al-Hijjah. Islamic date diary entries that begin with a
1741 diary-nonmarking-symbol will not be marked in the calendar. This function is
1742 provided for use as part of the nongregorian-diary-marking-hook."
1743 (let ((d diary-date-forms
))
1746 ((date-form (if (equal (car (car d
)) 'backup
)
1748 (car d
)));; ignore 'backup directive
1749 (dayname (diary-name-pattern calendar-day-name-array
))
1752 (diary-name-pattern calendar-islamic-month-name-array t
)
1754 (month "[0-9]+\\|\\*")
1755 (day "[0-9]+\\|\\*")
1756 (year "[0-9]+\\|\\*")
1757 (l (length date-form
))
1758 (d-name-pos (- l
(length (memq 'dayname date-form
))))
1759 (d-name-pos (if (/= l d-name-pos
) (+ 2 d-name-pos
)))
1760 (m-name-pos (- l
(length (memq 'monthname date-form
))))
1761 (m-name-pos (if (/= l m-name-pos
) (+ 2 m-name-pos
)))
1762 (d-pos (- l
(length (memq 'day date-form
))))
1763 (d-pos (if (/= l d-pos
) (+ 2 d-pos
)))
1764 (m-pos (- l
(length (memq 'month date-form
))))
1765 (m-pos (if (/= l m-pos
) (+ 2 m-pos
)))
1766 (y-pos (- l
(length (memq 'year date-form
))))
1767 (y-pos (if (/= l y-pos
) (+ 2 y-pos
)))
1770 "\\(\\`\\|\^M\\|\n\\)"
1771 (regexp-quote islamic-diary-entry-symbol
)
1773 (mapconcat 'eval date-form
"\\)\\(")
1775 (case-fold-search t
))
1776 (goto-char (point-min))
1777 (while (re-search-forward regexp nil t
)
1781 (match-beginning d-name-pos
)
1782 (match-end d-name-pos
))))
1786 (match-beginning m-name-pos
)
1787 (match-end m-name-pos
))))
1791 (match-beginning m-pos
)
1797 (match-beginning d-pos
)
1802 (match-beginning y-pos
)
1803 (match-end y-pos
))))
1806 (if (and (= (length y-str
) 2)
1807 abbreviated-calendar-year
)
1809 (extract-calendar-year
1810 (calendar-islamic-from-absolute
1811 (calendar-absolute-from-gregorian
1812 (calendar-current-date)))))
1813 (y (+ (string-to-int y-str
)
1814 (* 100 (/ current-y
100)))))
1815 (if (> (- y current-y
) 50)
1817 (if (> (- current-y y
) 50)
1820 (string-to-int y-str
)))))
1822 (mark-calendar-days-named
1823 (cdr (assoc (capitalize (substring dd-name
0 3))
1824 (calendar-make-alist
1825 calendar-day-name-array
1827 '(lambda (x) (substring x
0 3))))))
1829 (if (string-equal mm-name
"*")
1833 (capitalize mm-name
)
1834 (calendar-make-alist
1835 calendar-islamic-month-name-array
))))))
1836 (mark-islamic-calendar-date-pattern mm dd yy
)))))
1839 (defun mark-islamic-calendar-date-pattern (month day year
)
1840 "Mark dates in calendar window that conform to Islamic date MONTH/DAY/YEAR.
1841 A value of 0 in any position is a wildcard."
1843 (set-buffer calendar-buffer
)
1844 (if (and (/= 0 month
) (/= 0 day
))
1846 ;; Fully specified Islamic date.
1847 (let ((date (calendar-gregorian-from-absolute
1848 (calendar-absolute-from-islamic
1849 (list month day year
)))))
1850 (if (calendar-date-is-visible-p date
)
1851 (mark-visible-calendar-date date
)))
1852 ;; Month and day in any year--this taken from the holiday stuff.
1853 (let* ((islamic-date (calendar-islamic-from-absolute
1854 (calendar-absolute-from-gregorian
1855 (list displayed-month
15 displayed-year
))))
1856 (m (extract-calendar-month islamic-date
))
1857 (y (extract-calendar-year islamic-date
))
1860 nil
;; Islamic calendar doesn't apply.
1861 (increment-calendar-month m y
(- 10 month
))
1862 (if (> m
7);; Islamic date might be visible
1863 (let ((date (calendar-gregorian-from-absolute
1864 (calendar-absolute-from-islamic
1865 (list month day y
)))))
1866 (if (calendar-date-is-visible-p date
)
1867 (mark-visible-calendar-date date
)))))))
1868 ;; Not one of the simple cases--check all visible dates for match.
1869 ;; Actually, the following code takes care of ALL of the cases, but
1870 ;; it's much too slow to be used for the simple (common) cases.
1871 (let ((m displayed-month
)
1875 (increment-calendar-month m y -
1)
1877 (calendar-absolute-from-gregorian
1879 (increment-calendar-month m y
2)
1881 (calendar-absolute-from-gregorian
1882 (list m
(calendar-last-day-of-month m y
) y
)))
1883 (calendar-for-loop date from first-date to last-date do
1884 (let* ((i-date (calendar-islamic-from-absolute date
))
1885 (i-month (extract-calendar-month i-date
))
1886 (i-day (extract-calendar-day i-date
))
1887 (i-year (extract-calendar-year i-date
)))
1888 (and (or (zerop month
)
1894 (mark-visible-calendar-date
1895 (calendar-gregorian-from-absolute date
)))))))))
1899 ;;; diary.el ends here