annotate lisp/=diary-lib.el @ 4053:c142db721726

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