annotate lisp/=diary-lib.el @ 6848:df94ce8c363c

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