annotate lisp/calendar/diary-lib.el @ 116:9f59509498e1 r20-1b10

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