annotate lisp/=diary-lib.el @ 830:d7f1e2db9faf

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Tue, 21 Jul 1992 19:48:07 +0000
parents e694e0879463
children 20674ae6bf52
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; diary.el --- diary functions.
795
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
2
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
3 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
4 ;; Last-Modified: 30 Jun 1992
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 795
diff changeset
5 ;; Keyword: calendar
795
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
6
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
7 ;; Copyright (C) 1989, 1990 Free Software Foundation, Inc.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; GNU Emacs is distributed in the hope that it will be useful,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; but WITHOUT ANY WARRANTY. No author or distributor
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; accepts responsibility to anyone for the consequences of using it
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; or for whether it serves any particular purpose or works at all,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; unless he says so in writing. Refer to the GNU Emacs General Public
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; License for full details.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; Everyone is granted permission to copy, modify and redistribute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; GNU Emacs, but only under the conditions described in the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; GNU Emacs General Public License. A copy of this license is
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; supposed to have been given to you along with GNU Emacs so you
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; can know your rights and responsibilities. It should be in a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 ;; file named COPYING. Among other things, the copyright notice
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 ;; and this notice must be preserved on all copies.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
795
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
26 ;;; Commentary:
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
27
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;; This collection of functions implements the diary features as described
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;; in calendar.el.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;; Comments, corrections, and improvements should be sent to
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ;; Edward M. Reingold Department of Computer Science
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;; Urbana, Illinois 61801
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
795
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
37 ;;; Code:
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
38
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 (require 'calendar)
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
40
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
41 ;;;###autoload
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 (defun diary (&optional arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 "Generate the diary window for ARG days starting with the current date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 If no argument is provided, the number of days of diary entries is governed
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 by the variable `number-of-diary-entries'. This function is suitable for
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 execution in a .emacs file."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 (let ((d-file (substitute-in-file-name diary-file))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 (date (calendar-current-date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 (if (and d-file (file-exists-p d-file))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 (if (file-readable-p d-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (list-diary-entries
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (cond
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (arg (prefix-numeric-value arg))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 ((vectorp number-of-diary-entries)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (aref number-of-diary-entries (calendar-day-of-week date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (t number-of-diary-entries)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (error "Your diary file is not readable!"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (error "You don't have a diary file!"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 (defun view-diary-entries (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 "Prepare and display a buffer with diary entries.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 Searches the file diary-file for entries that match ARG days starting with
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 the date indicated by the cursor position in the displayed three-month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 calendar."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 (interactive "p")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 (let ((d-file (substitute-in-file-name diary-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (if (and d-file (file-exists-p d-file))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 (if (file-readable-p d-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (list-diary-entries (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (error "Cursor is not on a date!"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (error "Your diary file is not readable!"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 (error "You don't have a diary file!"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 (autoload 'check-calendar-holidays "holidays"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 "Check the list of holidays for any that occur on DATE.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 The value returned is a list of strings of relevant holiday descriptions.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 The holidays are those in the list calendar-holidays.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 (autoload 'calendar-holiday-list "holidays"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 "Form the list of holidays that occur on dates in the calendar window.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 The holidays are those in the list calendar-holidays.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (defvar diary-syntax-table
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 (standard-syntax-table)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 "The syntax table used when parsing dates in the diary file.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 It is the standard syntax table used in Fundamental mode, but with the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 syntax of `*' changed to be a word constituent.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 (modify-syntax-entry ?* "w" diary-syntax-table)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (defun list-diary-entries (date number)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 "Create and display a buffer containing the relevant lines in diary-file.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 All lines that apply to DATE and the next NUMBER-1 days are included.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 Makes all diary entries in the diary file invisible (using selective display),
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 *except* those that are relevant.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 Returns a list of all relevant diary entries found, if any, in order by date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 The list entries have the form ((month day year) string). If the variable
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 `diary-list-include-blanks' is t, this list will include a dummy diary entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 \(consisting of the empty string\) for a date with no diary entries.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 After the list is prepared, the hooks `nongregorian-diary-listing-hook',
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 `list-diary-entries-hook', and `diary-display-hook' are run. These hooks
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 have the following distinct roles:
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 `nongregorian-diary-listing-hook' can cull dates from the diary
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 and each included file. Usually used for Hebrew or Islamic
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 diary entries in files. Applied to *each* file.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 `list-diary-entries-hook' adds or manipulates diary entries from
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 external sources. Used, for example, to include diary entries
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 from other files or to sort the diary entries. Invoked *once* only.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 `diary-display-hook' does the actual display of information. Could be
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 used also for an appointment notification function."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (if (< 0 number)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 (let* ((original-date date);; save for possible use in the hooks
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 (old-diary-syntax-table)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 (diary-entries-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (date-string (calendar-date-string date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (d-file (substitute-in-file-name diary-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (message "Preparing diary...")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 (let ((diary-buffer (get-file-buffer d-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 (set-buffer (if diary-buffer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 diary-buffer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (find-file-noselect d-file t))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (setq selective-display t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (setq selective-display-ellipses nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (setq old-diary-syntax-table (syntax-table))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (set-syntax-table diary-syntax-table)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (unwind-protect
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 (let ((buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (diary-modified (buffer-modified-p))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (mark (regexp-quote diary-nonmarking-symbol)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (goto-char (1- (point-max)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (if (not (looking-at "\^M\\|\n"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 (progn
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (forward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 (insert-string "\^M")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (if (not (looking-at "\^M\\|\n"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (insert-string "\^M"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 (subst-char-in-region (point-min) (point-max) ?\n ?\^M t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (calendar-for-loop i from 1 to number do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (let ((d diary-date-forms)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (month (extract-calendar-month date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (day (extract-calendar-day date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (year (extract-calendar-year date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (entry-found (list-sexp-diary-entries date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (while d
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (let*
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 ((date-form (if (equal (car (car d)) 'backup)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (cdr (car d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (car d)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 (backup (equal (car (car d)) 'backup))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 (dayname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 (calendar-day-name date) "\\|"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 (substring (calendar-day-name date) 0 3) ".?"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (monthname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 "\\*\\|"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (calendar-month-name month) "\\|"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (substring (calendar-month-name month) 0 3) ".?"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 (month (concat "\\*\\|0*" (int-to-string month)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (day (concat "\\*\\|0*" (int-to-string day)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 (year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 "\\*\\|0*" (int-to-string year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (if abbreviated-calendar-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 (concat "\\|" (int-to-string (% year 100)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (regexp
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 "\\(\\`\\|\^M\\|\n\\)" mark "?\\("
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (mapconcat 'eval date-form "\\)\\(")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 "\\)"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 (case-fold-search t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 (while (re-search-forward regexp nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 (if backup (re-search-backward "\\<" nil t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (if (and (or (char-equal (preceding-char) ?\^M)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 (char-equal (preceding-char) ?\n))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (not (looking-at " \\|\^I")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 ;; Diary entry that consists only of date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 ;; Found a nonempty diary entry--make it visible and
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 ;; add it to the list.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 (setq entry-found t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 (let ((entry-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 (date-start))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (re-search-backward "\^M\\|\n\\|\\`")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (setq date-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (re-search-forward "\^M\\|\n" nil t 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (while (looking-at " \\|\^I")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (re-search-forward "\^M\\|\n" nil t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 (subst-char-in-region date-start
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (point) ?\^M ?\n t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (add-to-diary-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 date (buffer-substring entry-start (point)))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (setq d (cdr d)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (or entry-found
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 (not diary-list-include-blanks)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (setq diary-entries-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (append diary-entries-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (list (list date "")))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (setq date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (calendar-gregorian-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (1+ (calendar-absolute-from-gregorian date))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (setq entry-found nil)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (set-buffer-modified-p diary-modified))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (set-syntax-table old-diary-syntax-table))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (run-hooks 'nongregorian-diary-listing-hook
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 'list-diary-entries-hook
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 'diary-display-hook)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 diary-entries-list))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (defun include-other-diary-files ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 "Include the diary entries from other diary files with those of diary-file.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 This function is suitable for use just before fancy-diary-display as the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 list-diary-entries-hook; it enables you to use shared diary files together
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 with your own. The files included are specified in the diary-file by lines of
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 the form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 #include \"filename\"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 This is recursive; that is, #include directives in diary files thus included
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 are obeyed. You can change the \"#include\" to some other string by
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 changing the variable `diary-include-string'."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (while (re-search-forward
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 "\\(\\`\\|\^M\\|\n\\)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (regexp-quote diary-include-string)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 " \"\\([^\"]*\\)\"")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (let ((diary-file (substitute-in-file-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 (buffer-substring (match-beginning 2) (match-end 2))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 (diary-list-include-blanks nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 (list-diary-entries-hook 'include-other-diary-files)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 (diary-display-hook nil))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (if (file-exists-p diary-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (if (file-readable-p diary-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 (unwind-protect
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (setq diary-entries-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (append diary-entries-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (list-diary-entries original-date number)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (kill-buffer (get-file-buffer diary-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (beep)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (message "Can't read included diary file %s" diary-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (sleep-for 2))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (beep)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (message "Can't find included diary file %s" diary-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 (sleep-for 2))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (goto-char (point-min)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 (defun simple-diary-display ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 "Display the diary buffer if there are any relevant entries or holidays."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (let* ((holiday-list (if holidays-in-diary-buffer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (check-calendar-holidays original-date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (msg (format "No diary entries for %s %s"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (concat date-string (if holiday-list ":" ""))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (mapconcat 'identity holiday-list "; "))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 (if (or (not diary-entries-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 (and (not (cdr diary-entries-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (string-equal (car (cdr (car diary-entries-list))) "")))
778
cd00bdacc17b *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
273 (if (<= (length msg) (frame-width))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (message msg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (set-buffer (get-buffer-create holiday-buffer))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (setq buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (setq mode-line-format
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (format "--------------------------%s%%-" date-string))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (erase-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (insert (mapconcat 'identity holiday-list "\n"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (set-buffer-modified-p nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (setq buffer-read-only t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (display-buffer holiday-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (message "No diary entries for %s" date-string))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (setq mode-line-format
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 (format "%%*--%sDiary %s %s%s%s%%-"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (if holiday-list "" "---------------")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (if holiday-list "for" "entries for")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (if holiday-list ": " "")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (mapconcat 'identity holiday-list "; ")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (display-buffer (get-file-buffer d-file))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (message "Preparing diary...done"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (defun fancy-diary-display ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 "Prepare a diary buffer with relevant entries in a fancy, noneditable form.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 This function is provided for optional use as the `list-diary-entries-hook'."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (if (or (not diary-entries-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 (and (not (cdr diary-entries-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 (string-equal (car (cdr (car diary-entries-list))) "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 (let* ((holiday-list (if holidays-in-diary-buffer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 (check-calendar-holidays original-date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 (msg (format "No diary entries for %s %s"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (concat date-string (if holiday-list ":" ""))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (mapconcat 'identity holiday-list "; "))))
778
cd00bdacc17b *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
307 (if (<= (length msg) (frame-width))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 (message msg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 (set-buffer (get-buffer-create holiday-buffer))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (setq buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (setq mode-line-format
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (format "--------------------------%s%%-" date-string))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (erase-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (insert (mapconcat 'identity holiday-list "\n"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (set-buffer-modified-p nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 (setq buffer-read-only t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 (display-buffer holiday-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (message "No diary entries for %s" date-string)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (save-excursion;; Turn off selective-display in the diary file's buffer.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (set-buffer (get-file-buffer (substitute-in-file-name diary-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (let ((diary-modified (buffer-modified-p)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (setq selective-display nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (kill-local-variable 'mode-line-format)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 (set-buffer-modified-p diary-modified)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (save-excursion;; Prepare the fancy diary buffer.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (set-buffer (get-buffer-create fancy-diary-buffer))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (setq buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (make-local-variable 'mode-line-format)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (setq mode-line-format "---------------------------Diary Entries%-")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 (erase-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 (let ((entry-list diary-entries-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (holiday-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (holiday-list-last-month 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (holiday-list-last-year 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (date (list 0 0 0)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (while entry-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (if (not (calendar-date-equal date (car (car entry-list))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 (progn
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (setq date (car (car entry-list)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (and holidays-in-diary-buffer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (calendar-date-compare
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (list (list holiday-list-last-month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (calendar-last-day-of-month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 holiday-list-last-month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 holiday-list-last-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 holiday-list-last-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (list date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 ;; We need to get the holidays for the next 3 months.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (setq holiday-list-last-month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (extract-calendar-month date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (setq holiday-list-last-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 (extract-calendar-year date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 (increment-calendar-month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 holiday-list-last-month holiday-list-last-year 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 (setq holiday-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 (let ((displayed-month holiday-list-last-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 (displayed-year holiday-list-last-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (calendar-holiday-list)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 (increment-calendar-month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 holiday-list-last-month holiday-list-last-year 1))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 (let* ((date-string (calendar-date-string date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 (date-holiday-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 (let ((h holiday-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 (d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 ;; Make a list of all holidays for date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 (while h
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 (if (calendar-date-equal date (car (car h)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 (setq d (append d (cdr (car h)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 (setq h (cdr h)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 d)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (insert (if (= (point) (point-min)) "" ?\n) date-string)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (if date-holiday-list (insert ": "))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (let ((l (current-column)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (insert (mapconcat 'identity date-holiday-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 (concat "\n" (make-string l ? )))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (let ((l (current-column)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (insert ?\n (make-string l ?=) ?\n)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (if (< 0 (length (car (cdr (car entry-list)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 (insert (car (cdr (car entry-list))) ?\n))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 (setq entry-list (cdr entry-list))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 (set-buffer-modified-p nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 (setq buffer-read-only t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 (display-buffer fancy-diary-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (message "Preparing diary...done"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (defun print-diary-entries ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 "Print a hard copy of the entries visible in the diary window.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 The hooks given by the variable `print-diary-entries-hook' are called after
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 the temporary buffer of visible diary entries is prepared; it is the hooks
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 that do the actual printing and kill the buffer."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 (let ((diary-buffer (get-file-buffer (substitute-in-file-name diary-file))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 (if diary-buffer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 (let ((temp-buffer (get-buffer-create "*Printable Diary Entries*")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (set-buffer diary-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (copy-to-buffer temp-buffer (point-min) (point-max))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (set-buffer temp-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (while (re-search-forward "\^M.*$" nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 (replace-match ""))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 (run-hooks 'print-diary-entries-hook)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (error "You don't have a diary buffer!"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 (defun add-diary-heading ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 "Add a heading to the diary entries for printing.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 The heading is formed from the mode line of the diary buffer. This function
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 is used in the default value of the variable `print-diary-entry-hooks'."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (let ((heading))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (set-buffer diary-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (setq heading mode-line-format)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (string-match "%\\*-*\\([^-].*\\)%-$" heading)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (setq heading
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 (substring heading (match-beginning 1) (match-end 1)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (set-buffer temp-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (insert heading "\n"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 (make-string (length heading) ?=) "\n"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 (defun show-all-diary-entries ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 "Show all of the diary entries in the diary-file.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 This function gets rid of the selective display of the diary-file so that
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 all entries, not just some, are visible. If there is no diary buffer, one
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 is created."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (let ((d-file (substitute-in-file-name diary-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (if (and d-file (file-exists-p d-file))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (if (file-readable-p d-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (let ((diary-buffer (get-file-buffer d-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 (set-buffer (if diary-buffer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 diary-buffer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 (find-file-noselect d-file t)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (let ((buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 (diary-modified (buffer-modified-p)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (setq selective-display nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 (make-local-variable 'mode-line-format)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 (setq mode-line-format
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 "%*---------------------------All Diary Entries%-")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (display-buffer (current-buffer))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (set-buffer-modified-p diary-modified))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 (error "Your diary file is not readable!"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (error "You don't have a diary file!"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 (defun diary-name-pattern (string-array &optional fullname)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 "Convert an STRING-ARRAY, an array of strings to a pattern.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 The pattern will match any of the strings, either entirely or abbreviated
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 to three characters. An abbreviated form will match with or without a period;
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 If the optional FULLNAME is t, abbreviations will not match, just the full
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 name."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (let ((pattern ""))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (calendar-for-loop i from 0 to (1- (length string-array)) do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (setq pattern
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 pattern
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 (if (string-equal pattern "") "" "\\|")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (aref string-array i)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 (if fullname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 ""
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 "\\|"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (substring (aref string-array i) 0 3) ".?")))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 pattern))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (defun mark-diary-entries ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 "Mark days in the calendar window that have diary entries.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 Each entry in diary-file visible in the calendar window is marked. After the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 entries are marked, the hooks `nongregorian-diary-marking-hook' and
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 `mark-diary-entries-hook' are run."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (setq mark-diary-entries-in-calendar t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 (let ((d-file (substitute-in-file-name diary-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 (if (and d-file (file-exists-p d-file))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 (if (file-readable-p d-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 (message "Marking diary entries...")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 (set-buffer (find-file-noselect d-file t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 (let ((d diary-date-forms)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 (old-diary-syntax-table))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 (setq old-diary-syntax-table (syntax-table))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 (set-syntax-table diary-syntax-table)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 (while d
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 (let*
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 ((date-form (if (equal (car (car d)) 'backup)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 (cdr (car d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 (car d)));; ignore 'backup directive
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 (dayname (diary-name-pattern calendar-day-name-array))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 (monthname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 (diary-name-pattern calendar-month-name-array)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 "\\|\\*"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 (month "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 (day "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 (year "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 (l (length date-form))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 (d-name-pos (- l (length (memq 'dayname date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 (m-name-pos (- l (length (memq 'monthname date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 (d-pos (- l (length (memq 'day date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 (m-pos (- l (length (memq 'month date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 (y-pos (- l (length (memq 'year date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 (regexp
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 "\\(\\`\\|\^M\\|\n\\)\\("
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 (mapconcat 'eval date-form "\\)\\(")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 "\\)"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (case-fold-search t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 (while (re-search-forward regexp nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 (let* ((dd-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 (if d-name-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 (match-beginning d-name-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 (match-end d-name-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 (mm-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 (if m-name-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 (match-beginning m-name-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 (match-end m-name-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 (mm (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 (if m-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 (match-beginning m-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 (match-end m-pos))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 (dd (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 (if d-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 (match-beginning d-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 (match-end d-pos))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 (y-str (if y-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 (match-beginning y-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 (match-end y-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 (yy (if (not y-str)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 0
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 (if (and (= (length y-str) 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 abbreviated-calendar-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 (let* ((current-y
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (extract-calendar-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 (calendar-current-date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (y (+ (string-to-int y-str)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 (* 100
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (/ current-y 100)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 (if (> (- y current-y) 50)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 (- y 100)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 (if (> (- current-y y) 50)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (+ y 100)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (string-to-int y-str)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (if dd-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (mark-calendar-days-named
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 (cdr (assoc (capitalize (substring dd-name 0 3))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 (calendar-make-alist
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 calendar-day-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 0
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 '(lambda (x) (substring x 0 3))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 (if mm-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 (if (string-equal mm-name "*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 (setq mm 0)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 (setq mm
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 (cdr (assoc
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 (capitalize
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (substring mm-name 0 3))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 (calendar-make-alist
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 calendar-month-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 1
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 '(lambda (x) (substring x 0 3)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 )))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 (mark-calendar-date-pattern mm dd yy))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 (setq d (cdr d))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 (mark-sexp-diary-entries)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (run-hooks 'nongregorian-diary-marking-hook
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 'mark-diary-entries-hook)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 (set-syntax-table old-diary-syntax-table)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (message "Marking diary entries...done")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (error "Your diary file is not readable!"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 (error "You don't have a diary file!"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 (defun mark-sexp-diary-entries ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 "Mark days in the calendar window that have sexp diary entries.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 Each entry in diary-file (or included files) visible in the calendar window
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 is marked. See the documentation for the function `list-sexp-diary-entries'."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 (let* ((sexp-mark (regexp-quote sexp-diary-entry-symbol))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" sexp-mark "("))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 (m)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 (y)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 (first-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 (last-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 (set-buffer calendar-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 (setq m displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 (setq y displayed-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 (increment-calendar-month m y -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 (setq first-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 (calendar-absolute-from-gregorian (list m 1 y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 (increment-calendar-month m y 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 (setq last-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (list m (calendar-last-day-of-month m y) y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 (while (re-search-forward s-entry nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 (let ((sexp-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 (sexp)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 (entry)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 (entry-start)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 (line-start))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 (forward-sexp)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 (setq sexp (buffer-substring sexp-start (point)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 (re-search-backward "\^M\\|\n\\|\\`")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 (setq line-start (point)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 (forward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 (if (and (or (char-equal (preceding-char) ?\^M)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 (char-equal (preceding-char) ?\n))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 (not (looking-at " \\|\^I")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 (progn;; Diary entry consists only of the sexp
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 (setq entry ""))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 (setq entry-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 (re-search-forward "\^M\\|\n" nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 (while (looking-at " \\|\^I")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 (re-search-forward "\^M\\|\n" nil t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 (setq entry (buffer-substring entry-start (point)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 (while (string-match "[\^M]" entry)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 (aset entry (match-beginning 0) ?\n )))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 (calendar-for-loop date from first-date to last-date do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 (if (diary-sexp-entry sexp entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 (calendar-gregorian-from-absolute date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 (mark-visible-calendar-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 (calendar-gregorian-from-absolute date))))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 (defun mark-included-diary-files ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 "Mark the diary entries from other diary files with those of diary-file.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 This function is suitable for use as the mark-diary-entries-hook; it enables
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 you to use shared diary files together with your own. The files included are
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 specified in the diary-file by lines of the form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 #include \"filename\"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 This is recursive; that is, #include directives in diary files thus included
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 are obeyed. You can change the \"#include\" to some other string by
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 changing the variable `diary-include-string'."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 (while (re-search-forward
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 "\\(\\`\\|\^M\\|\n\\)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 (regexp-quote diary-include-string)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 " \"\\([^\"]*\\)\"")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 (let ((diary-file (substitute-in-file-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 (buffer-substring (match-beginning 2) (match-end 2))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 (mark-diary-entries-hook 'mark-included-diary-files))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 (if (file-exists-p diary-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 (if (file-readable-p diary-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 (progn
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 (mark-diary-entries)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 (kill-buffer (get-file-buffer diary-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 (beep)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 (message "Can't read included diary file %s" diary-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 (sleep-for 2))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 (beep)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 (message "Can't find included diary file %s" diary-file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 (sleep-for 2))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 (goto-char (point-min)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 (defun mark-calendar-days-named (dayname)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 "Mark all dates in the calendar window that are day DAYNAME of the week.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 0 means all Sundays, 1 means all Mondays, and so on."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 (set-buffer calendar-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 (let ((prev-month displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 (prev-year displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 (succ-month displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 (succ-year displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 (last-day)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 (day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 (increment-calendar-month succ-month succ-year 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 (increment-calendar-month prev-month prev-year -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 (setq day (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 (calendar-nth-named-day 1 dayname prev-month prev-year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 (setq last-day (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 (calendar-nth-named-day -1 dayname succ-month succ-year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 (while (<= day last-day)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 (mark-visible-calendar-date (calendar-gregorian-from-absolute day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 (setq day (+ day 7))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 (defun mark-calendar-date-pattern (month day year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 A value of 0 in any position is a wild-card."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 (set-buffer calendar-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702 (let ((m displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 (y displayed-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 (increment-calendar-month m y -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 (calendar-for-loop i from 0 to 2 do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 (mark-calendar-month m y month day year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 (increment-calendar-month m y 1)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 (defun mark-calendar-month (month year p-month p-day p-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 A value of 0 in any position of the pattern is a wild-card."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 (if (or (and (= month p-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 (or (= p-year 0) (= year p-year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 (and (= p-month 0)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 (or (= p-year 0) (= year p-year))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 (if (= p-day 0)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 (calendar-for-loop
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 i from 1 to (calendar-last-day-of-month month year) do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 (mark-visible-calendar-date (list month i year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 (mark-visible-calendar-date (list month p-day year)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 (defun diary-entry-compare (e1 e2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 "Returns t if E1 is earlier than E2."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 (or (calendar-date-compare e1 e2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 (and (calendar-date-equal (car e1) (car e2))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 (< (diary-entry-time (car (cdr e1)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 (diary-entry-time (car (cdr e2)))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 (defun diary-entry-time (s)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 "Time at the beginning of the string S in a military-style integer.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 For example, returns 1325 for 1:25pm. Returns -9999 if no time is recognized.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 The recognized forms are XXXX or X:XX or XX:XX (military time), XXam or XXpm,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 and XX:XXam or XX:XXpm."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 (cond ((string-match;; Military time
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 "^ *\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 (+ (* 100 (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 (substring s (match-beginning 1) (match-end 1))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 (string-to-int (substring s (match-beginning 2) (match-end 2)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 ((string-match;; Hour only XXam or XXpm
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 "^ *\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741 (+ (* 100 (% (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 (substring s (match-beginning 1) (match-end 1)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 12))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 (if (string-equal "a"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 (substring s (match-beginning 2) (match-end 2)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 0 1200)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 ((string-match;; Hour and minute XX:XXam or XX:XXpm
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 "^ *\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 (+ (* 100 (% (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 (substring s (match-beginning 1) (match-end 1)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 12))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 (string-to-int (substring s (match-beginning 2) (match-end 2)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 (if (string-equal "a"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 (substring s (match-beginning 3) (match-end 3)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 0 1200)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 (t -9999)));; Unrecognizable
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 (defun list-hebrew-diary-entries ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 "Add any Hebrew date entries from the diary-file to diary-entries-list.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 Hebrew date diary entries must be prefaced by a hebrew-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761 \(normally an `H'\). The same diary-date-forms govern the style of the Hebrew
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 calendar entries, except that the Hebrew month names must be spelled in full.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 common Hebrew year. If a Hebrew date diary entry begins with a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 diary-nonmarking-symbol the entry will appear in the diary listing, but will
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 not be marked in the calendar. This function is provided for use with the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 nongregorian-diary-listing-hook."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 (if (< 0 number)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770 (let ((buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
771 (diary-modified (buffer-modified-p))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 (gdate original-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773 (mark (regexp-quote diary-nonmarking-symbol)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 (calendar-for-loop i from 1 to number do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 (let* ((d diary-date-forms)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 (hdate (calendar-hebrew-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 (calendar-absolute-from-gregorian gdate)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 (month (extract-calendar-month hdate))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 (day (extract-calendar-day hdate))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 (year (extract-calendar-year hdate)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 (while d
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782 (let*
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 ((date-form (if (equal (car (car d)) 'backup)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 (cdr (car d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785 (car d)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 (backup (equal (car (car d)) 'backup))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 (dayname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 (calendar-day-name gdate) "\\|"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
790 (substring (calendar-day-name gdate) 0 3) ".?"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
791 (calendar-month-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792 calendar-hebrew-month-name-array-leap-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793 (monthname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 "\\*\\|"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
796 (calendar-month-name month)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
797 (month (concat "\\*\\|0*" (int-to-string month)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
798 (day (concat "\\*\\|0*" (int-to-string day)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
799 (year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
800 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
801 "\\*\\|0*" (int-to-string year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802 (if abbreviated-calendar-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
803 (concat "\\|" (int-to-string (% year 100)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805 (regexp
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
806 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807 "\\(\\`\\|\^M\\|\n\\)" mark "?"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808 (regexp-quote hebrew-diary-entry-symbol)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809 "\\("
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 (mapconcat 'eval date-form "\\)\\(")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 "\\)"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 (case-fold-search t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 (while (re-search-forward regexp nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 (if backup (re-search-backward "\\<" nil t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 (if (and (or (char-equal (preceding-char) ?\^M)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 (char-equal (preceding-char) ?\n))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818 (not (looking-at " \\|\^I")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
819 ;; Diary entry that consists only of date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821 ;; Found a nonempty diary entry--make it visible and
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822 ;; add it to the list.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823 (let ((entry-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
824 (date-start))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
825 (re-search-backward "\^M\\|\n\\|\\`")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826 (setq date-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 (re-search-forward "\^M\\|\n" nil t 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 (while (looking-at " \\|\^I")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829 (re-search-forward "\^M\\|\n" nil t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
831 (subst-char-in-region date-start (point) ?\^M ?\n t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 (add-to-diary-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
833 gdate (buffer-substring entry-start (point)))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
834 (setq d (cdr d))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835 (setq gdate
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836 (calendar-gregorian-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837 (1+ (calendar-absolute-from-gregorian gdate)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
838 (set-buffer-modified-p diary-modified))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
839 (goto-char (point-min))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
840
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
841 (defun mark-hebrew-diary-entries ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
842 "Mark days in the calendar window that have Hebrew date diary entries.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
843 Each entry in diary-file (or included files) visible in the calendar window
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
844 is marked. Hebrew date entries are prefaced by a hebrew-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845 \(normally an `H'\). The same diary-date-forms govern the style of the Hebrew
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846 calendar entries, except that the Hebrew month names must be spelled in full.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
848 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849 common Hebrew year. Hebrew date diary entries that begin with a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850 diary-nonmarking symbol will not be marked in the calendar. This function
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
851 is provided for use as part of the nongregorian-diary-marking-hook."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
852 (let ((d diary-date-forms))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
853 (while d
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
854 (let*
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855 ((date-form (if (equal (car (car d)) 'backup)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856 (cdr (car d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 (car d)));; ignore 'backup directive
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
858 (dayname (diary-name-pattern calendar-day-name-array))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859 (monthname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
860 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861 (diary-name-pattern calendar-hebrew-month-name-array-leap-year t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862 "\\|\\*"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
863 (month "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864 (day "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865 (year "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866 (l (length date-form))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
867 (d-name-pos (- l (length (memq 'dayname date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
869 (m-name-pos (- l (length (memq 'monthname date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
870 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
871 (d-pos (- l (length (memq 'day date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 (m-pos (- l (length (memq 'month date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
874 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
875 (y-pos (- l (length (memq 'year date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
876 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877 (regexp
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
878 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
879 "\\(\\`\\|\^M\\|\n\\)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
880 (regexp-quote hebrew-diary-entry-symbol)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
881 "\\("
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
882 (mapconcat 'eval date-form "\\)\\(")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 "\\)"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
884 (case-fold-search t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
885 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
886 (while (re-search-forward regexp nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887 (let* ((dd-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888 (if d-name-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890 (match-beginning d-name-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 (match-end d-name-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892 (mm-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 (if m-name-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895 (match-beginning m-name-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896 (match-end m-name-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897 (mm (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
898 (if m-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 (match-beginning m-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 (match-end m-pos))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 (dd (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904 (if d-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
906 (match-beginning d-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
907 (match-end d-pos))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 (y-str (if y-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 (match-beginning y-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
912 (match-end y-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
913 (yy (if (not y-str)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914 0
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915 (if (and (= (length y-str) 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916 abbreviated-calendar-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 (let* ((current-y
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 (extract-calendar-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919 (calendar-hebrew-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921 (calendar-current-date)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
922 (y (+ (string-to-int y-str)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923 (* 100 (/ current-y 100)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
924 (if (> (- y current-y) 50)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
925 (- y 100)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
926 (if (> (- current-y y) 50)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
927 (+ y 100)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928 y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929 (string-to-int y-str)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
930 (if dd-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 (mark-calendar-days-named
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 (cdr (assoc (capitalize (substring dd-name 0 3))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933 (calendar-make-alist
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 calendar-day-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 0
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 '(lambda (x) (substring x 0 3))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937 (if mm-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 (if (string-equal mm-name "*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 (setq mm 0)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940 (setq
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
941 mm
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942 (cdr
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943 (assoc
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 (capitalize mm-name)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945 (calendar-make-alist
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
946 calendar-hebrew-month-name-array-leap-year))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
947 (mark-hebrew-calendar-date-pattern mm dd yy)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948 (setq d (cdr d)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
950 (defun mark-hebrew-calendar-date-pattern (month day year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
951 "Mark all dates in the calendar window that conform to the Hebrew date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952 MONTH/DAY/YEAR. A value of 0 in any position is a wild-card."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
954 (set-buffer calendar-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
955 (if (and (/= 0 month) (/= 0 day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
956 (if (/= 0 year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
957 ;; Fully specified Hebrew date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
958 (let ((date (calendar-gregorian-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
959 (calendar-absolute-from-hebrew
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960 (list month day year)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 (if (calendar-date-is-visible-p date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
962 (mark-visible-calendar-date date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963 ;; Month and day in any year--this taken from the holiday stuff.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
964 (if (memq displayed-month;; This test is only to speed things up a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
965 (list ;; bit; it works fine without the test too.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
966 (if (< 11 month) (- month 11) (+ month 1))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
967 (if (< 10 month) (- month 10) (+ month 2))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
968 (if (< 9 month) (- month 9) (+ month 3))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
969 (if (< 8 month) (- month 8) (+ month 4))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970 (if (< 7 month) (- month 7) (+ month 5))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 (let ((m1 displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
972 (y1 displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973 (m2 displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 (y2 displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
975 (year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
976 (increment-calendar-month m1 y1 -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
977 (increment-calendar-month m2 y2 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
978 (let* ((start-date (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
979 (list m1 1 y1)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 (end-date (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 (list m2
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 (calendar-last-day-of-month m2 y2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983 y2)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984 (hebrew-start
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
985 (calendar-hebrew-from-absolute start-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
986 (hebrew-end (calendar-hebrew-from-absolute end-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
987 (hebrew-y1 (extract-calendar-year hebrew-start))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
988 (hebrew-y2 (extract-calendar-year hebrew-end)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
989 (setq year (if (< 6 month) hebrew-y2 hebrew-y1))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
990 (let ((date (calendar-gregorian-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
991 (calendar-absolute-from-hebrew
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
992 (list month day year)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
993 (if (calendar-date-is-visible-p date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
994 (mark-visible-calendar-date date)))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
995 ;; Not one of the simple cases--check all visible dates for match.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
996 ;; Actually, the following code takes care of ALL of the cases, but
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
997 ;; it's much too slow to be used for the simple (common) cases.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
998 (let ((m displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
999 (y displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1000 (first-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1001 (last-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1002 (increment-calendar-month m y -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1003 (setq first-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1005 (list m 1 y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1006 (increment-calendar-month m y 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1007 (setq last-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1008 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1009 (list m (calendar-last-day-of-month m y) y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1010 (calendar-for-loop date from first-date to last-date do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1011 (let* ((h-date (calendar-hebrew-from-absolute date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1012 (h-month (extract-calendar-month h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1013 (h-day (extract-calendar-day h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1014 (h-year (extract-calendar-year h-date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1015 (and (or (zerop month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1016 (= month h-month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1017 (or (zerop day)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1018 (= day h-day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1019 (or (zerop year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1020 (= year h-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1021 (mark-visible-calendar-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1022 (calendar-gregorian-from-absolute date)))))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1023
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1024 (defun list-sexp-diary-entries (date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1025 "Add any sexp entries for DATE from the diary-file to diary-entries-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1026 and make them visible in the diary file. Returns t if any entries were found.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1027
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1028 Sexp diary entries must be prefaced by a sexp-diary-entry-symbol (normally
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1029 `%%'). The form of a sexp diary entry is
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1030
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1031 %%(SEXP) ENTRY
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1032
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1033 Both ENTRY and DATE are globally available when the SEXP is evaluated. If the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1034 SEXP yields the value nil, the diary entry does not apply. If it yields a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1035 non-nil value, ENTRY will be taken to apply to DATE; if the non-nil value is a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1036 string, that string will be the diary entry in the fancy diary display.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1037
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1038 For example, the following diary entry will apply to the 21st of the month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1039 if it is a weekday and the Friday before if the 21st is on a weekend:
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1040
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1041 &%%(let ((dayname (calendar-day-of-week date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1042 (day (extract-calendar-day date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1043 (or
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1044 (and (= day 21) (memq dayname '(1 2 3 4 5)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1045 (and (memq day '(19 20)) (= dayname 5)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1046 ) UIUC pay checks deposited
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1047
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1048 A number of built-in functions are available for this type of diary entry:
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1049
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1050 %%(diary-float MONTH DAYNAME N) text
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1051 Entry will appear on the Nth DAYNAME of MONTH.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1052 (DAYNAME=0 means Sunday, 1 means Monday, and so on;
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1053 if N is negative it counts backward from the end of
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1054 the month. MONTH can be a list of months, a single
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1055 month, or t to specify all months.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1056
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1057 %%(diary-block M1 D1 Y1 M2 D2 Y2) text
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1058 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1059 inclusive. (If `european-calendar-style' is t, the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1060 order of the parameters should be changed to D1, M1, Y1,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1061 D2, M2, Y2.)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1062
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1063 %%(diary-anniversary MONTH DAY YEAR) text
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1064 Entry will appear on anniversary dates of MONTH DAY, YEAR.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065 (If `european-calendar-style' is t, the order of the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1066 parameters should be changed to DAY, MONTH, YEAR.) Text
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1067 can contain %d or %d%s; %d will be replaced by the number
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068 of years since the MONTH DAY, YEAR and %s will be replaced
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1069 by the ordinal ending of that number (that is, `st', `nd',
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1070 `rd' or `th', as appropriate. The anniversary of February
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1071 29 is considered to be March 1 in a non-leap year.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1072
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1073 %%(diary-cyclic N MONTH DAY YEAR) text
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1074 Entry will appear every N days, starting MONTH DAY, YEAR.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1075 (If `european-calendar-style' is t, the order of the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1076 parameters should be changed to N, DAY, MONTH, YEAR.) Text
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1077 can contain %d or %d%s; %d will be replaced by the number
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1078 of repetitions since the MONTH DAY, YEAR and %s will
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1079 be replaced by the ordinal ending of that number (that is,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1080 `st', `nd', `rd' or `th', as appropriate.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1081
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1082 %%(diary-day-of-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1083 Diary entries giving the day of the year and the number of
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1084 days remaining in the year will be made every day. Note
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1085 that since there is no text, it makes sense only if the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1086 fancy diary display is used.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1087
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1088 %%(diary-iso-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1089 Diary entries giving the corresponding ISO commercial date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1090 will be made every day. Note that since there is no text,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1091 it makes sense only if the fancy diary display is used.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1092
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1093 %%(diary-french-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1094 Diary entries giving the corresponding French Revolutionary
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1095 date will be made every day. Note that since there is no
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1096 text, it makes sense only if the fancy diary display is used.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1097
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1098 %%(diary-islamic-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1099 Diary entries giving the corresponding Islamic date will be
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1100 made every day. Note that since there is no text, it
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1101 makes sense only if the fancy diary display is used.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1102
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1103 %%(diary-hebrew-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1104 Diary entries giving the corresponding Hebrew date will be
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1105 made every day. Note that since there is no text, it
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1106 makes sense only if the fancy diary display is used.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1107
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1108 %%(diary-yahrzeit MONTH DAY YEAR) text
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1109 Text is assumed to be the name of the person; the date is
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1110 the date of death on the *civil* calendar. The diary entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1111 will appear on the proper Hebrew-date anniversary and on the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1112 day before. (If `european-calendar-style' is t, the order
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1113 of the parameters should be changed to DAY, MONTH, YEAR.)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1114
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1115 %%(diary-rosh-hodesh)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1116 Diary entries will be made on the dates of Rosh Hodesh on
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1117 the Hebrew calendar. Note that since there is no text, it
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1118 makes sense only if the fancy diary display is used.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1119
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1120 %%(diary-parasha)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1121 Diary entries giving the weekly parasha will be made on
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1122 every Saturday. Note that since there is no text, it
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1123 makes sense only if the fancy diary display is used.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1124
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1125 %%(diary-omer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1126 Diary entries giving the omer count will be made every day
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1127 from Passover to Shavuoth. Note that since there is no text,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1128 it makes sense only if the fancy diary display is used.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1129
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1130 Marking these entries is *extremely* time consuming, so these entries are
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1131 best if they are nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1132 (let* ((mark (regexp-quote diary-nonmarking-symbol))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1133 (sexp-mark (regexp-quote sexp-diary-entry-symbol))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1134 (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" mark "?" sexp-mark "("))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1135 (entry-found))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1136 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1137 (while (re-search-forward s-entry nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1138 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1139 (let ((sexp-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1140 (sexp)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1141 (entry)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1142 (entry-start)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1143 (line-start))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1144 (forward-sexp)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1145 (setq sexp (buffer-substring sexp-start (point)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1146 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1147 (re-search-backward "\^M\\|\n\\|\\`")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1148 (setq line-start (point)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1149 (forward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1150 (if (and (or (char-equal (preceding-char) ?\^M)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1151 (char-equal (preceding-char) ?\n))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1152 (not (looking-at " \\|\^I")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1153 (progn;; Diary entry consists only of the sexp
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1154 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1155 (setq entry ""))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1156 (setq entry-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1157 (re-search-forward "\^M\\|\n" nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1158 (while (looking-at " \\|\^I")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1159 (re-search-forward "\^M\\|\n" nil t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1160 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1161 (setq entry (buffer-substring entry-start (point)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1162 (while (string-match "[\^M]" entry)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1163 (aset entry (match-beginning 0) ?\n )))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1164 (let ((diary-entry (diary-sexp-entry sexp entry date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1165 (if diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1166 (subst-char-in-region line-start (point) ?\^M ?\n t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1167 (add-to-diary-list date diary-entry)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1168 (setq entry-found (or entry-found diary-entry)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1169 entry-found))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1170
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1171 (defun diary-sexp-entry (sexp entry date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1172 "Process a SEXP diary ENTRY for DATE."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1173 (let ((result (condition-case nil
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1174 (eval (car (read-from-string sexp)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1175 (error
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1176 (beep)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1177 (message "Bad sexp at line %d in %s: %s"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1178 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1179 (save-restriction
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1180 (narrow-to-region 1 (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1181 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1182 (let ((lines 1))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1183 (while (re-search-forward "\n\\|\^M" nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1184 (setq lines (1+ lines)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1185 lines)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1186 diary-file sexp)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1187 (sleep-for 2)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1188 (if (stringp result)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1189 result
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1190 (if result
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1191 entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1192 nil))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1193
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1194 (defun diary-block (m1 d1 y1 m2 d2 y2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1195 "Block diary entry--entry applies if date is between two dates. Order of
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1196 the parameters is M1, D1, Y1, M2, D2, Y2 `european-calendar-style' is nil, and
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1197 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1198 (let ((date1 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1199 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1200 (list d1 m1 y1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1201 (list m1 d1 y1))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1202 (date2 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1203 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1204 (list d2 m2 y2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1205 (list m2 d2 y2))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1206 (d (calendar-absolute-from-gregorian date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1207 (if (and (<= date1 d) (<= d date2))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1208 entry)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1209
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1210 (defun diary-float (month dayname n)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1211 "Floating diary entry--entry applies if date is the nth dayname of month.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1212 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1213 t, or an integer. The constant t means all months. If N is negative, count
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1214 backward from the end of the month."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1215 (let ((m (extract-calendar-month date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1216 (y (extract-calendar-year date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1217 (if (and
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1218 (or (and (listp month) (memq m month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1219 (equal m month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1220 (eq month t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1221 (calendar-date-equal date (calendar-nth-named-day n dayname m y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1222 entry)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1223
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1224 (defun diary-anniversary (month day year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1225 "Anniversary diary entry--entry applies if date is the anniversary of
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1226 MONTH, DAY, YEAR if `european-calendar-style' is nil, and DAY, MONTH, YEAR
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1227 if `european-calendar-style' is t. Diary entry can contain `%d' or `%d%s'; the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1228 %d will be replaced by the number of years since the MONTH DAY, YEAR and the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1229 %s will be replaced by the ordinal ending of that number (that is, `st', `nd',
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1230 `rd' or `th', as appropriate. The anniversary of February 29 is considered
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1231 to be March 1 in non-leap years."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1232 (let* ((d (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1233 month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1234 day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1235 (m (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1236 day
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1237 month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1238 (y (extract-calendar-year date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1239 (diff (- y year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1240 (if (and (= m 2) (= d 29) (not (calendar-leap-year-p y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1241 (setq m 3
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1242 d 1))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1243 (if (and (> diff 0) (calendar-date-equal (list m d y) date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1244 (format entry diff (diary-ordinal-suffix diff)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1245
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1246 (defun diary-cyclic (n month day year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1247 "Cycle diary entry--entry applies every N days starting at MONTH, DAY, YEAR.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1248 If `european-calendar-style' is t, parameters are N, DAY, MONTH, YEAR.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1249 ENTRY can contain `%d' or `%d%s'; the %d will be replaced by the number of
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1250 years since the MONTH DAY, YEAR and the %s will be replaced by the ordinal
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1251 ending of that number (that is, `st', `nd', `rd' or `th', as appropriate."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1252 (let* ((d (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1253 month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1254 day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1255 (m (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1256 day
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1257 month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1258 (diff (- (calendar-absolute-from-gregorian date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1259 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1260 (list m d year))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1261 (cycle (/ diff n)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1262 (if (and (>= diff 0) (zerop (% diff n)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1263 (format entry cycle (diary-ordinal-suffix cycle)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1264
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1265 (defun diary-ordinal-suffix (n)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1266 "Ordinal suffix for N. (That is, `st', `nd', `rd', or `th', as appropriate.)"
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1267 (if (or (memq (% n 100) '(11 12 13))
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1268 (< 3 (% n 10)))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1269 "th"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1270 (aref ["th" "st" "nd" "rd"] (% n 10))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1271
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1272 (defun diary-day-of-year ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1273 "Day of year and number of days remaining in the year of date diary entry."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1274 (let* ((year (extract-calendar-year date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1275 (day (calendar-day-number date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1276 (days-remaining (- (calendar-day-number (list 12 31 year)) day)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1277 (format "Day %d of %d; %d day%s remaining in the year"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1278 day year days-remaining (if (= days-remaining 1) "" "s"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1279
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1280 (defun diary-iso-date ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1281 "ISO calendar equivalent of date diary entry."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1282 (let ((day (% (calendar-absolute-from-gregorian date) 7))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1283 (iso-date (calendar-iso-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1284 (calendar-absolute-from-gregorian date))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1285 (format "ISO date: Day %s of week %d of %d."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1286 (if (zerop day) 7 day)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1287 (extract-calendar-month iso-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1288 (extract-calendar-year iso-date))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1289
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1290 (defun diary-islamic-date ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1291 "Islamic calendar equivalent of date diary entry."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1292 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1293 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1294 '(day " " monthname " " year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1295 '(monthname " " day ", " year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1296 (i-date (calendar-islamic-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1297 (calendar-absolute-from-gregorian date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1298 (calendar-month-name-array calendar-islamic-month-name-array))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1299 (if (>= (extract-calendar-year i-date) 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1300 (format "Islamic date: %s" (calendar-date-string i-date)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1301
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1302 (defun diary-hebrew-date ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1303 "Hebrew calendar equivalent of date diary entry."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1304 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1305 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1306 '(day " " monthname " " year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1307 '(monthname " " day ", " year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1308 (h-date (calendar-hebrew-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1309 (calendar-absolute-from-gregorian date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1310 (calendar-month-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1311 (if (hebrew-calendar-leap-year-p
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1312 (extract-calendar-year h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1313 calendar-hebrew-month-name-array-leap-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1314 calendar-hebrew-month-name-array-common-year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1315 (format "Hebrew date: %s" (calendar-date-string h-date))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1316
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1317 (defun diary-french-date ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1318 "French calendar equivalent of date diary entry."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1319 (let* ((french-date (calendar-french-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1320 (calendar-absolute-from-gregorian date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1321 (y (extract-calendar-year french-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1322 (m (extract-calendar-month french-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1323 (d (extract-calendar-day french-date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1324 (if (> y 0)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1325 (if (= m 13)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1326 (format "Jour %s de l'Annee %d de la Revolution"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1327 (aref french-calendar-special-days-array (1- d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1328 y)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1329 (format "Decade %s, %s de %s de l'Annee %d de la Revolution"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330 (make-string (1+ (/ (1- d) 10)) ?I)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1331 (aref french-calendar-day-name-array (% (1- d) 10))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1332 (aref french-calendar-month-name-array (1- m))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1333 y)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1334
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1335 (defun diary-omer ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1336 "Omer count diary entry--entry applies if date is within 50 days after
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1337 Passover."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1338 (let* ((passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1339 (calendar-absolute-from-hebrew
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1340 (list 1 15 (+ (extract-calendar-year date) 3760))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341 (omer (- (calendar-absolute-from-gregorian date) passover))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1342 (week (/ omer 7))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1343 (day (% omer 7)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1344 (if (and (> omer 0) (< omer 50))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1345 (format "Day %d%s of the omer (until sunset)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1346 omer
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1347 (if (zerop week)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1348 ""
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1349 (format ", that is, %d week%s%s"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1350 week
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1351 (if (= week 1) "" "s")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1352 (if (zerop day)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1353 ""
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1354 (format " and %d day%s"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1355 day (if (= day 1) "" "s")))))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1356
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1357 (defun diary-yahrzeit (death-month death-day death-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1358 "Yahrzeit diary entry--entry applies if date is yahrzeit or the day before.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1359 Parameters are DEATH-MONTH, DEATH-DAY, DEATH-YEAR; the diary entry is assumed
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1360 to be the name of the person. Date of death is on the *civil* calendar;
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1361 although the date of death is specified by the civil calendar, the proper
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1362 Hebrew calendar yahrzeit is determined. If european-calendar-style is t, the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1363 order of the parameters is changed to DEATH-DAY, DEATH-MONTH, DEATH-YEAR."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1364 (let* ((h-date (calendar-hebrew-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1365 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1366 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1367 (list death-day death-month death-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1368 (list death-month death-day death-year)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1369 (h-month (extract-calendar-month h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1370 (h-day (extract-calendar-day h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1371 (h-year (extract-calendar-year h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1372 (d (calendar-absolute-from-gregorian date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1373 (yr (extract-calendar-year (calendar-hebrew-from-absolute d)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1374 (diff (- yr h-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1375 (y (hebrew-calendar-yahrzeit h-date yr)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1376 (if (and (> diff 0) (or (= y d) (= y (1+ d))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1377 (format "Yahrzeit of %s%s: %d%s anniversary"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1378 entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1379 (if (= y d) "" " (evening)")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1380 diff
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1381 (cond ((= (% diff 10) 1) "st")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1382 ((= (% diff 10) 2) "nd")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1383 ((= (% diff 10) 3) "rd")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1384 (t "th"))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1385
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1386 (defun diary-rosh-hodesh ()
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1387 "Rosh Hodesh diary entry--entry applies if date is Rosh Hodesh, the day
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1388 before, or the Saturday before."
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1389 (let* ((d (calendar-absolute-from-gregorian date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1390 (h-date (calendar-hebrew-from-absolute d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1391 (h-month (extract-calendar-month h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1392 (h-day (extract-calendar-day h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1393 (h-year (extract-calendar-year h-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1394 (leap-year (hebrew-calendar-leap-year-p h-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1395 (last-day (hebrew-calendar-last-day-of-month h-month h-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1396 (h-month-names
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1397 (if leap-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1398 calendar-hebrew-month-name-array-leap-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1399 calendar-hebrew-month-name-array-common-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1400 (this-month (aref h-month-names (1- h-month)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1401 (h-yesterday (extract-calendar-day
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1402 (calendar-hebrew-from-absolute (1- d)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1403 (if (or (= h-day 30) (and (= h-day 1) (/= h-month 7)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1404 (format
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405 "Rosh Hodesh %s"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1406 (if (= h-day 30)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1407 (format
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1408 "%s (first day)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 ;; next month must be in the same year since this
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410 ;; month can't be the last month of the year since
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 ;; it has 30 days
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1412 (aref h-month-names h-month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1413 (if (= h-yesterday 30)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1414 (format "%s (second day)" this-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 this-month)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 (if (= (mod d 7) 6);; Saturday--check for Shabbat Mevarhim
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1417 (cond ((and (> h-day 22) (/= h-month 6) (= 29 last-day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1418 (format "Mevarhim Rosh Hodesh %s (%s)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1419 (aref h-month-names
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1420 (if (= h-month
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1421 (hebrew-calendar-last-month-of-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1422 h-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1423 0 h-month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1424 (aref calendar-day-name-array (- 29 h-day))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1425 ((and (< h-day 30) (> h-day 22) (= 30 last-day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426 (format "Mevarhim Rosh Hodesh %s (%s-%s)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1427 (aref h-month-names h-month)
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1428 (if (= h-day 29)
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1429 "tomorrow"
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1430 (aref calendar-day-name-array (- 29 h-day)))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1431 (aref calendar-day-name-array
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1432 (mod (- 30 h-day) 7)))))
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1433 (if (and (= h-day 29) (/= h-month 6))
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1434 (format "Erev Rosh Hodesh %s"
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1435 (aref h-month-names
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1436 (if (= h-month
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1437 (hebrew-calendar-last-month-of-year
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1438 h-year))
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 662
diff changeset
1439 0 h-month))))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1440
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1441 (defun diary-parasha ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1442 "Parasha diary entry--entry applies if date is a Saturday."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1443 (let ((d (calendar-absolute-from-gregorian date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1444 (if (= (% d 7) 6);; Saturday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1445 (let*
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1446 ((h-year (extract-calendar-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1447 (calendar-hebrew-from-absolute d)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1448 (rosh-hashannah
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1449 (calendar-absolute-from-hebrew (list 7 1 h-year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1450 (passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1451 (calendar-absolute-from-hebrew (list 1 15 h-year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1452 (rosh-hashannah-day
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1453 (aref calendar-day-name-array (% rosh-hashannah 7)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1454 (passover-day
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1455 (aref calendar-day-name-array (% passover 7)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1456 (long-h (hebrew-calendar-long-heshvan-p h-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1457 (short-k (hebrew-calendar-short-kislev-p h-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1458 (type (cond ((and long-h (not short-k)) "complete")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1459 ((and (not long-h) short-k) "incomplete")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1460 (t "regular")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1461 (year-format
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1462 (symbol-value
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1463 (intern (format "hebrew-calendar-year-%s-%s-%s";; keviah
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1464 rosh-hashannah-day type passover-day))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1465 (first-saturday;; of Hebrew year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1466 (calendar-dayname-on-or-before 6 (+ 6 rosh-hashannah)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1467 (saturday;; which Saturday of the Hebrew year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1468 (/ (- d first-saturday) 7))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1469 (parasha (aref year-format saturday)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1470 (if parasha
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1471 (format
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1472 "Parashat %s"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1473 (if (listp parasha);; Israel differs from diaspora
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1474 (if (car parasha)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1475 (format "%s (diaspora), %s (Israel)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1476 (hebrew-calendar-parasha-name (car parasha))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1477 (hebrew-calendar-parasha-name (cdr parasha)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1478 (format "%s (Israel)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1479 (hebrew-calendar-parasha-name (cdr parasha))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1480 (hebrew-calendar-parasha-name parasha))))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1481
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1482 (defun add-to-diary-list (date string)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1483 "Add the entry (DATE STRING) to the diary-entries-list.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1484 Do nothing if DATE or STRING is nil."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1485 (and date string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1486 (setq diary-entries-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1487 (append diary-entries-list (list (list date string))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1488
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1489 (defconst hebrew-calendar-parashiot-names
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1490 ["Bereshith" "Noah" "Lech L'cha" "Vayera" "Hayei Sarah" "Toledoth"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1491 "Vayetze" "Vayishlah" "Vayeshev" "Mikketz" "Vayiggash" "Vayhi"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1492 "Shemoth" "Vaera" "Bo" "Beshallah" "Yithro" "Mishpatim"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1493 "Terumah" "Tetzavveh" "Ki Tissa" "Vayakhel" "Pekudei" "Vayikra"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1494 "Tzav" "Shemini" "Tazria" "Metzora" "Aharei Moth" "Kedoshim"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1495 "Emor" "Behar" "Behukkotai" "Bemidbar" "Naso" "Behaalot'cha"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1496 "Shelah L'cha" "Korah" "Hukkath" "Balak" "Pinhas" "Mattoth"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1497 "Masei" "Devarim" "Vaethanan" "Ekev" "Reeh" "Shofetim"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1498 "Ki Tetze" "Ki Tavo" "Nitzavim" "Vayelech" "Haazinu"]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1499 "The names of the parashiot in the Torah.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1500
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1501 ;; The seven ordinary year types (keviot)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1502
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1503 (defconst hebrew-calendar-year-Saturday-incomplete-Sunday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1504 [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]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1505 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1506 43 44 45 46 47 48 49 50]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1507 "The structure of the parashiot in a Hebrew year that starts on Saturday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1508 is `incomplete' (Heshvan and Kislev each have 29 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1509 start on Sunday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1510
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1511 (defconst hebrew-calendar-year-Saturday-complete-Tuesday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1512 [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]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1513 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1514 43 44 45 46 47 48 49 [50 51]]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1515 "The structure of the parashiot in a Hebrew year that starts on Saturday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1516 is `complete' (Heshvan and Kislev each have 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1517 start on Tuesday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1518
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1519 (defconst hebrew-calendar-year-Monday-incomplete-Tuesday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1520 [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]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1521 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1522 43 44 45 46 47 48 49 [50 51]]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1523 "The structure of the parashiot in a Hebrew year that starts on Monday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1524 is `incomplete' (Heshvan and Kislev each have 29 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1525 start on Tuesday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1526
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1527 (defconst hebrew-calendar-year-Monday-complete-Thursday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1528 [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]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1529 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34.35) (35.36)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1530 (36.37) (37.38) ([38 39].39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1531 "The structure of the parashiot in a Hebrew year that starts on Monday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1532 is `complete' (Heshvan and Kislev each have 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1533 start on Thursday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1534
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1535 (defconst hebrew-calendar-year-Tuesday-regular-Thursday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1536 [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]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1537 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34.35) (35.36)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1538 (36.37) (37.38) ([38 39].39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1539 "The structure of the parashiot in a Hebrew year that starts on Tuesday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1540 is `regular' (Heshvan has 29 days and Kislev has 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1541 start on Thursday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1543 (defconst hebrew-calendar-year-Thursday-regular-Saturday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1544 [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]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1545 23 24 nil (nil . 25) (25.[26 27]) ([26 27].[28 29]) ([28 29].30) (30.31)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1546 ([31 32].32) 33 34 35 36 37 38 39 40 [41 42]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1547 43 44 45 46 47 48 49 50]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1548 "The structure of the parashiot in a Hebrew year that starts on Thursday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1549 is `regular' (Heshvan has 29 days and Kislev has 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1550 start on Saturday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1551
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1552 (defconst hebrew-calendar-year-Thursday-complete-Sunday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1553 [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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1554 23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1555 43 44 45 46 47 48 49 50]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1556 "The structure of the parashiot in a Hebrew year that starts on Thursday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1557 is `complete' (Heshvan and Kislev each have 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1558 start on Sunday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1559
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1560 ;; The seven leap year types (keviot)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1561
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1562 (defconst hebrew-calendar-year-Saturday-incomplete-Tuesday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1563 [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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1564 23 24 25 26 27 nil 28 29 30 31 32 33 34 35 36 37 38 39 40 [41 42]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1565 43 44 45 46 47 48 49 [50 51]]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1566 "The structure of the parashiot in a Hebrew year that starts on Saturday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1567 is `incomplete' (Heshvan and Kislev each have 29 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1568 start on Tuesday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1569
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1570 (defconst hebrew-calendar-year-Saturday-complete-Thursday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1571 [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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1572 23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34.35) (35.36) (36.37)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1573 (37.38) ([38 39].39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1574 "The structure of the parashiot in a Hebrew year that starts on Saturday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1575 is `complete' (Heshvan and Kislev each have 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1576 start on Thursday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1577
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1578 (defconst hebrew-calendar-year-Monday-incomplete-Thursday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1579 [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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1580 23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34.35) (35.36) (36.37)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1581 (37.38) ([38 39].39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1582 "The structure of the parashiot in a Hebrew year that starts on Monday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1583 is `incomplete' (Heshvan and Kislev each have 29 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1584 start on Thursday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1585
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1586 (defconst hebrew-calendar-year-Monday-complete-Saturday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1587 [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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1588 23 24 25 26 27 nil (nil . 28) (28.29) (29.30) (30.31) (31.32) (32.33)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1589 (33.34) (34.35) (35.36) (36.37) (37.38) (38.39) (39.40) (40.41) ([41 42].42)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1590 43 44 45 46 47 48 49 50]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1591 "The structure of the parashiot in a Hebrew year that starts on Monday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1592 is `complete' (Heshvan and Kislev each have 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1593 start on Saturday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1594
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1595 (defconst hebrew-calendar-year-Tuesday-regular-Saturday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1596 [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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1597 23 24 25 26 27 nil (nil . 28) (28.29) (29.30) (30.31) (31.32) (32.33)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1598 (33.34) (34.35) (35.36) (36.37) (37.38) (38.39) (39.40) (40.41) ([41 42].42)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1599 43 44 45 46 47 48 49 50]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1600 "The structure of the parashiot in a Hebrew year that starts on Tuesday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1601 is `regular' (Heshvan has 29 days and Kislev has 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1602 start on Saturday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1603
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1604 (defconst hebrew-calendar-year-Thursday-incomplete-Sunday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1605 [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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1606 23 24 25 26 27 28 nil 29 30 31 32 33 34 35 36 37 38 39 40 41 42
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1607 43 44 45 46 47 48 49 50]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1608 "The structure of the parashiot in a Hebrew year that starts on Thursday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1609 is `incomplete' (Heshvan and Kislev both have 29 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1610 start on Sunday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1611
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1612 (defconst hebrew-calendar-year-Thursday-complete-Tuesday
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1613 [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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1614 23 24 25 26 27 28 nil 29 30 31 32 33 34 35 36 37 38 39 40 41 42
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1615 43 44 45 46 47 48 49 [50 51]]
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1616 "The structure of the parashiot in a Hebrew year that starts on Thursday,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1617 is `complete' (Heshvan and Kislev both have 30 days), and has Passover
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1618 start on Tuesday.")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1619
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1620 (defun hebrew-calendar-parasha-name (p)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1621 "Name(s) corresponding to parasha P."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1622 (if (arrayp p);; combined parasha
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1623 (format "%s/%s"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1624 (aref hebrew-calendar-parashiot-names (aref p 0))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1625 (aref hebrew-calendar-parashiot-names (aref p 1)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1626 (aref hebrew-calendar-parashiot-names p)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1627
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1628 (defun list-islamic-diary-entries ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1629 "Add any Islamic date entries from the diary-file to diary-entries-list.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1630 Islamic date diary entries must be prefaced by an islamic-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1631 \(normally an `I'\). The same diary-date-forms govern the style of the Islamic
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1632 calendar entries, except that the Islamic month names must be spelled in full.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1633 The Islamic months are numbered from 1 to 12 with Muharram being 1 and 12 being
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1634 Dhu al-Hijjah. If an Islamic date diary entry begins with a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1635 diary-nonmarking-symbol the entry will appear in the diary listing, but will
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1636 not be marked in the calendar. This function is provided for use with the
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1637 nongregorian-diary-listing-hook."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1638 (if (< 0 number)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1639 (let ((buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1640 (diary-modified (buffer-modified-p))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1641 (gdate original-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1642 (mark (regexp-quote diary-nonmarking-symbol)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1643 (calendar-for-loop i from 1 to number do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1644 (let* ((d diary-date-forms)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1645 (idate (calendar-islamic-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1646 (calendar-absolute-from-gregorian gdate)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1647 (month (extract-calendar-month idate))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1648 (day (extract-calendar-day idate))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1649 (year (extract-calendar-year idate)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1650 (while d
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1651 (let*
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1652 ((date-form (if (equal (car (car d)) 'backup)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1653 (cdr (car d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1654 (car d)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1655 (backup (equal (car (car d)) 'backup))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1656 (dayname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1657 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1658 (calendar-day-name gdate) "\\|"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1659 (substring (calendar-day-name gdate) 0 3) ".?"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1660 (calendar-month-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1661 calendar-islamic-month-name-array)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1662 (monthname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1663 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1664 "\\*\\|"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1665 (calendar-month-name month)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1666 (month (concat "\\*\\|0*" (int-to-string month)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1667 (day (concat "\\*\\|0*" (int-to-string day)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1668 (year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1669 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1670 "\\*\\|0*" (int-to-string year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1671 (if abbreviated-calendar-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1672 (concat "\\|" (int-to-string (% year 100)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1673 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1674 (regexp
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1675 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1676 "\\(\\`\\|\^M\\|\n\\)" mark "?"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1677 (regexp-quote islamic-diary-entry-symbol)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1678 "\\("
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1679 (mapconcat 'eval date-form "\\)\\(")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1680 "\\)"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1681 (case-fold-search t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1682 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1683 (while (re-search-forward regexp nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1684 (if backup (re-search-backward "\\<" nil t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1685 (if (and (or (char-equal (preceding-char) ?\^M)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1686 (char-equal (preceding-char) ?\n))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1687 (not (looking-at " \\|\^I")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1688 ;; Diary entry that consists only of date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1689 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1690 ;; Found a nonempty diary entry--make it visible and
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1691 ;; add it to the list.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1692 (let ((entry-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1693 (date-start))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1694 (re-search-backward "\^M\\|\n\\|\\`")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1695 (setq date-start (point))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1696 (re-search-forward "\^M\\|\n" nil t 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1697 (while (looking-at " \\|\^I")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1698 (re-search-forward "\^M\\|\n" nil t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1699 (backward-char 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1700 (subst-char-in-region date-start (point) ?\^M ?\n t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1701 (add-to-diary-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1702 gdate (buffer-substring entry-start (point)))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1703 (setq d (cdr d))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1704 (setq gdate
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1705 (calendar-gregorian-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1706 (1+ (calendar-absolute-from-gregorian gdate)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1707 (set-buffer-modified-p diary-modified))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1708 (goto-char (point-min))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1709
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1710 (defun mark-islamic-diary-entries ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1711 "Mark days in the calendar window that have Islamic date diary entries.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1712 Each entry in diary-file (or included files) visible in the calendar window
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1713 is marked. Islamic date entries are prefaced by a islamic-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1714 \(normally an `I'\). The same diary-date-forms govern the style of the Islamic
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1715 calendar entries, except that the Islamic month names must be spelled in full.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1716 The Islamic months are numbered from 1 to 12 with Muharram being 1 and 12 being
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1717 Dhu al-Hijjah. Islamic date diary entries that begin with a
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1718 diary-nonmarking-symbol will not be marked in the calendar. This function is
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1719 provided for use as part of the nongregorian-diary-marking-hook."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1720 (let ((d diary-date-forms))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1721 (while d
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1722 (let*
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1723 ((date-form (if (equal (car (car d)) 'backup)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1724 (cdr (car d))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1725 (car d)));; ignore 'backup directive
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1726 (dayname (diary-name-pattern calendar-day-name-array))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1727 (monthname
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1728 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1729 (diary-name-pattern calendar-islamic-month-name-array t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1730 "\\|\\*"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1731 (month "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1732 (day "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1733 (year "[0-9]+\\|\\*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1734 (l (length date-form))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1735 (d-name-pos (- l (length (memq 'dayname date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1736 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1737 (m-name-pos (- l (length (memq 'monthname date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1738 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1739 (d-pos (- l (length (memq 'day date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1740 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1741 (m-pos (- l (length (memq 'month date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1742 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1743 (y-pos (- l (length (memq 'year date-form))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1744 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1745 (regexp
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1746 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1747 "\\(\\`\\|\^M\\|\n\\)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1748 (regexp-quote islamic-diary-entry-symbol)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1749 "\\("
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1750 (mapconcat 'eval date-form "\\)\\(")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1751 "\\)"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1752 (case-fold-search t))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1753 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1754 (while (re-search-forward regexp nil t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1755 (let* ((dd-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1756 (if d-name-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1757 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1758 (match-beginning d-name-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1759 (match-end d-name-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1760 (mm-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1761 (if m-name-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1762 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1763 (match-beginning m-name-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1764 (match-end m-name-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1765 (mm (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1766 (if m-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1767 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1768 (match-beginning m-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1769 (match-end m-pos))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1770 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1771 (dd (string-to-int
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1772 (if d-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1773 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1774 (match-beginning d-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1775 (match-end d-pos))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1776 "")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1777 (y-str (if y-pos
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1778 (buffer-substring
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1779 (match-beginning y-pos)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1780 (match-end y-pos))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1781 (yy (if (not y-str)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1782 0
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1783 (if (and (= (length y-str) 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1784 abbreviated-calendar-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1785 (let* ((current-y
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1786 (extract-calendar-year
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1787 (calendar-islamic-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1788 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1789 (calendar-current-date)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1790 (y (+ (string-to-int y-str)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1791 (* 100 (/ current-y 100)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1792 (if (> (- y current-y) 50)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1793 (- y 100)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1794 (if (> (- current-y y) 50)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1795 (+ y 100)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1796 y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1797 (string-to-int y-str)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1798 (if dd-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1799 (mark-calendar-days-named
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1800 (cdr (assoc (capitalize (substring dd-name 0 3))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1801 (calendar-make-alist
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1802 calendar-day-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1803 0
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1804 '(lambda (x) (substring x 0 3))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1805 (if mm-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1806 (if (string-equal mm-name "*")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1807 (setq mm 0)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1808 (setq mm
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1809 (cdr (assoc
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1810 (capitalize mm-name)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1811 (calendar-make-alist
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1812 calendar-islamic-month-name-array))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1813 (mark-islamic-calendar-date-pattern mm dd yy)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1814 (setq d (cdr d)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1815
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1816 (defun mark-islamic-calendar-date-pattern (month day year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1817 "Mark all dates in the calendar window that conform to the Islamic date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1818 MONTH/DAY/YEAR. A value of 0 in any position is a wild-card."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1819 (save-excursion
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1820 (set-buffer calendar-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1821 (if (and (/= 0 month) (/= 0 day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1822 (if (/= 0 year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1823 ;; Fully specified Islamic date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1824 (let ((date (calendar-gregorian-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1825 (calendar-absolute-from-islamic
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1826 (list month day year)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1827 (if (calendar-date-is-visible-p date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1828 (mark-visible-calendar-date date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1829 ;; Month and day in any year--this taken from the holiday stuff.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1830 (let* ((islamic-date (calendar-islamic-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1831 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1832 (list displayed-month 15 displayed-year))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1833 (m (extract-calendar-month islamic-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1834 (y (extract-calendar-year islamic-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1835 (date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1836 (if (< m 1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1837 nil;; Islamic calendar doesn't apply.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1838 (increment-calendar-month m y (- 10 month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1839 (if (> m 7);; Islamic date might be visible
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1840 (let ((date (calendar-gregorian-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1841 (calendar-absolute-from-islamic
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1842 (list month day y)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1843 (if (calendar-date-is-visible-p date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1844 (mark-visible-calendar-date date)))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1845 ;; Not one of the simple cases--check all visible dates for match.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1846 ;; Actually, the following code takes care of ALL of the cases, but
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1847 ;; it's much too slow to be used for the simple (common) cases.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1848 (let ((m displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1849 (y displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1850 (first-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1851 (last-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1852 (increment-calendar-month m y -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1853 (setq first-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1854 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1855 (list m 1 y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1856 (increment-calendar-month m y 2)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1857 (setq last-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1858 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1859 (list m (calendar-last-day-of-month m y) y)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1860 (calendar-for-loop date from first-date to last-date do
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1861 (let* ((i-date (calendar-islamic-from-absolute date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1862 (i-month (extract-calendar-month i-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1863 (i-day (extract-calendar-day i-date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1864 (i-year (extract-calendar-year i-date)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1865 (and (or (zerop month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1866 (= month i-month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1867 (or (zerop day)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1868 (= day i-day))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1869 (or (zerop year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1870 (= year i-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1871 (mark-visible-calendar-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1872 (calendar-gregorian-from-absolute date)))))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1873
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1874 (defun make-diary-entry (string &optional nonmarking file)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1875 "Insert a diary entry STRING which may be NONMARKING in FILE.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1876 If omitted, NONMARKING defaults to nil and FILE defaults to diary-file."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1877 (find-file-other-window
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1878 (substitute-in-file-name (if file file diary-file)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1879 (goto-char (point-max))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1880 (insert
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1881 (if (bolp) "" "\n")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1882 (if nonmarking diary-nonmarking-symbol "")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1883 string " "))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1884
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1885 (defun insert-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1886 "Insert a diary entry for the date indicated by point.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1887 Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1888 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1889 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1890 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1891 '(day " " monthname " " year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1892 '(monthname " " day ", " year))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1893 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1894 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1895 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1896 (error "Cursor is not on a date!"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1897 t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1898 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1899
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1900 (defun insert-weekly-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1901 "Insert a weekly diary entry for the day of the week indicated by point.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1902 Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1903 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1904 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1905 (calendar-day-name
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1906 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1907 (error "Cursor is not on a date!")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1908 arg))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1909
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1910 (defun insert-monthly-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1911 "Insert a monthly diary entry for the day of the month indicated by point.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1912 Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1913 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1914 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1915 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1916 '(day " * ")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1917 '("* " day))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1918 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1919 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1920 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1921 (error "Cursor is not on a date!"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1922 t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1923 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1924
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1925 (defun insert-yearly-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1926 "Insert an annual diary entry for the day of the year indicated by point.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1927 Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1928 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1929 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1930 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1931 '(day " " monthname)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1932 '(monthname " " day))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1933 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1934 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1935 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1936 (error "Cursor is not on a date!"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1937 t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1938 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1939
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1940 (defun insert-anniversary-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1941 "Insert an anniversary diary entry for the date given by point.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1942 Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1943 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1944 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1945 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1946 '(day " " month " " year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1947 '(month " " day " " year))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1948 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1949 (format "%s(diary-anniversary %s)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1950 sexp-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1951 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1952 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1953 (error "Cursor is not on a date!"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1954 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1955
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1956 (defun insert-block-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1957 "Insert a block diary entry for the days between the point and marked date.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1958 Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1959 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1960 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1961 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1962 '(day " " month " " year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1963 '(month " " day " " year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1964 (cursor (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1965 (error "Cursor is not on a date!")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1966 (mark (or (car calendar-mark-ring)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1967 (error "No mark set in this buffer")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1968 (start)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1969 (end))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1970 (if (< (calendar-absolute-from-gregorian mark)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1971 (calendar-absolute-from-gregorian cursor))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1972 (setq start mark
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1973 end cursor)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1974 (setq start cursor
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1975 end mark))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1976 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1977 (format "%s(diary-block %s %s)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1978 sexp-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1979 (calendar-date-string start)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1980 (calendar-date-string end))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1981 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1982
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1983 (defun insert-cyclic-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1984 "Insert a cyclic diary entry starting at the date given by point.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1985 Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1986 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1987 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1988 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1989 '(day " " month " " year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1990 '(month " " day " " year))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1991 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1992 (format "%s(diary-cyclic %d %s)"
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1993 sexp-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1994 (calendar-read "Repeat every how many days: "
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1995 '(lambda (x) (> x 0)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1996 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1997 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1998 (error "Cursor is not on a date!"))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1999 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2000
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2001 (defun insert-hebrew-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2002 "Insert a diary entry for the Hebrew date corresponding to the date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2003 indicated by point. Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2004 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2005 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2006 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2007 '(day " " monthname " " year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2008 '(monthname " " day ", " year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2009 (calendar-month-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2010 calendar-hebrew-month-name-array-leap-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2011 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2012 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2013 hebrew-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2014 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2015 (calendar-hebrew-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2016 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2017 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2018 (error "Cursor is not on a date!"))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2019 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2020
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2021 (defun insert-monthly-hebrew-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2022 "Insert a monthly diary entry for the day of the Hebrew month corresponding
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2023 to the date indicated by point. Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2024 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2025 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2026 (if european-calendar-style '(day " * ") '("* " day )))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2027 (calendar-month-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2028 calendar-hebrew-month-name-array-leap-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2029 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2030 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2031 hebrew-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2032 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2033 (calendar-hebrew-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2034 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2035 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2036 (error "Cursor is not on a date!"))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2037 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2038
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2039 (defun insert-yearly-hebrew-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2040 "Insert an annual diary entry for the day of the Hebrew year corresponding
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2041 to the date indicated by point. Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2042 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2043 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2044 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2045 '(day " " monthname)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2046 '(monthname " " day)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2047 (calendar-month-name-array
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2048 calendar-hebrew-month-name-array-leap-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2049 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2050 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2051 hebrew-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2052 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2053 (calendar-hebrew-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2054 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2055 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2056 (error "Cursor is not on a date!"))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2057 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2058
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2059 (defun insert-islamic-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2060 "Insert a diary entry for the Islamic date corresponding to the date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2061 indicated by point. Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2062 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2063 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2064 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2065 '(day " " monthname " " year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2066 '(monthname " " day ", " year)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2067 (calendar-month-name-array calendar-islamic-month-name-array))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2068 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2069 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2070 islamic-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2071 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2072 (calendar-islamic-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2073 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2074 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2075 (error "Cursor is not on a date!"))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2076 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2077
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2078 (defun insert-monthly-islamic-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2079 "Insert a monthly diary entry for the day of the Islamic month corresponding
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2080 to the date indicated by point. Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2081 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2082 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2083 (if european-calendar-style '(day " * ") '("* " day )))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2084 (calendar-month-name-array calendar-islamic-month-name-array))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2085 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2086 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2087 islamic-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2088 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2089 (calendar-islamic-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2090 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2091 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2092 (error "Cursor is not on a date!"))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2093 arg)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2094
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2095 (defun insert-yearly-islamic-diary-entry (arg)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2096 "Insert an annual diary entry for the day of the Islamic year corresponding
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2097 to the date indicated by point. Prefix arg will make the entry nonmarking."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2098 (interactive "P")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2099 (let* ((calendar-date-display-form
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2100 (if european-calendar-style
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2101 '(day " " monthname)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2102 '(monthname " " day)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2103 (calendar-month-name-array calendar-islamic-month-name-array))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2104 (make-diary-entry
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2105 (concat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2106 islamic-diary-entry-symbol
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2107 (calendar-date-string
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2108 (calendar-islamic-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2109 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2110 (or (calendar-cursor-to-date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2111 (error "Cursor is not on a date!"))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2112 arg)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
2113
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
2114 (provide 'diary)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
2115
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2116 ;;; diary.el ends here