Mercurial > emacs
annotate lisp/calendar/cal-islam.el @ 93258:16142d1d9f33
(redisplay_internal): Reset selected_frame earlier.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 26 Mar 2008 18:11:47 +0000 |
parents | 9aca848375df |
children | 691804e8889b |
rev | line source |
---|---|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38402
diff
changeset
|
1 ;;; cal-islam.el --- calendar functions for the Islamic calendar |
13053 | 2 |
92610
6f4bd17c2adc
(mark-islamic-calendar-date-pattern): Use zerop.
Glenn Morris <rgm@gnu.org>
parents:
92585
diff
changeset
|
3 ;; Copyright (C) 1995, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
6f4bd17c2adc
(mark-islamic-calendar-date-pattern): Use zerop.
Glenn Morris <rgm@gnu.org>
parents:
92585
diff
changeset
|
4 ;; 2008 Free Software Foundation, Inc. |
13053 | 5 |
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | |
67465
a55ee709ec8d
Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents:
65144
diff
changeset
|
7 ;; Maintainer: Glenn Morris <rgm@gnu.org> |
13053 | 8 ;; Keywords: calendar |
9 ;; Human-Keywords: Islamic calendar, calendar, diary | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
78216
93e11478c954
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77279
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
13053 | 16 ;; any later version. |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
14169 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
13053 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; This collection of functions implements the features of calendar.el and | |
31 ;; diary.el that deal with the Islamic calendar. | |
32 | |
20462
d179de7ad92e
Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents:
20268
diff
changeset
|
33 ;; Technical details of all the calendrical calculations can be found in |
61148
7f7db25577d9
Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents:
54075
diff
changeset
|
34 ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold |
7f7db25577d9
Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents:
54075
diff
changeset
|
35 ;; and Nachum Dershowitz, Cambridge University Press (2001). |
20462
d179de7ad92e
Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents:
20268
diff
changeset
|
36 |
13053 | 37 ;;; Code: |
38 | |
93223
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
39 (require 'calendar) |
13053 | 40 |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
41 (defconst calendar-islamic-month-name-array |
13053 | 42 ["Muharram" "Safar" "Rabi I" "Rabi II" "Jumada I" "Jumada II" |
52119
226327fe046f
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
43 "Rajab" "Sha'ban" "Ramadan" "Shawwal" "Dhu al-Qada" "Dhu al-Hijjah"] |
226327fe046f
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
44 "Array of strings giving the names of the Islamic months.") |
13053 | 45 |
93223
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
46 (eval-and-compile |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
47 (autoload 'calendar-absolute-from-julian "cal-julian")) |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
48 |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
49 (defconst calendar-islamic-epoch |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
50 (eval-when-compile (calendar-absolute-from-julian '(7 16 622))) |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
51 "Absolute date of start of Islamic calendar = July 16, 622 AD (Julian).") |
13053 | 52 |
53 (defun islamic-calendar-leap-year-p (year) | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
54 "Return t if YEAR is a leap year on the Islamic calendar." |
13053 | 55 (memq (% year 30) |
56 (list 2 5 7 10 13 16 18 21 24 26 29))) | |
57 | |
58 (defun islamic-calendar-last-day-of-month (month year) | |
59 "The last day in MONTH during YEAR on the Islamic calendar." | |
60 (cond | |
61 ((memq month (list 1 3 5 7 9 11)) 30) | |
62 ((memq month (list 2 4 6 8 10)) 29) | |
63 (t (if (islamic-calendar-leap-year-p year) 30 29)))) | |
64 | |
65 (defun islamic-calendar-day-number (date) | |
66 "Return the day number within the year of the Islamic date DATE." | |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
67 (let ((month (extract-calendar-month date))) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
68 (+ (* 30 (/ month 2)) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
69 (* 29 (/ (1- month) 2)) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
70 (extract-calendar-day date)))) |
13053 | 71 |
72 (defun calendar-absolute-from-islamic (date) | |
73 "Absolute date of Islamic DATE. | |
74 The absolute date is the number of days elapsed since the (imaginary) | |
75 Gregorian date Sunday, December 31, 1 BC." | |
76 (let* ((month (extract-calendar-month date)) | |
77 (day (extract-calendar-day date)) | |
78 (year (extract-calendar-year date)) | |
79 (y (% year 30)) | |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
80 (leap-years-in-cycle (cond ((< y 3) 0) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
81 ((< y 6) 1) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
82 ((< y 8) 2) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
83 ((< y 11) 3) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
84 ((< y 14) 4) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
85 ((< y 17) 5) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
86 ((< y 19) 6) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
87 ((< y 22) 7) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
88 ((< y 25) 8) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
89 ((< y 27) 9) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
90 (t 10)))) |
92644 | 91 (+ (islamic-calendar-day-number date) ; days so far this year |
92 (* (1- year) 354) ; days in all non-leap years | |
93 (* 11 (/ year 30)) ; leap days in complete cycles | |
94 leap-years-in-cycle ; leap days this cycle | |
95 (1- calendar-islamic-epoch)))) ; days before start of calendar | |
13053 | 96 |
97 (defun calendar-islamic-from-absolute (date) | |
98 "Compute the Islamic date (month day year) corresponding to absolute DATE. | |
99 The absolute date is the number of days elapsed since the (imaginary) | |
100 Gregorian date Sunday, December 31, 1 BC." | |
101 (if (< date calendar-islamic-epoch) | |
92644 | 102 (list 0 0 0) ; pre-Islamic date |
13053 | 103 (let* ((approx (/ (- date calendar-islamic-epoch) |
92644 | 104 355)) ; approximation from below |
105 (year ; search forward from the approximation | |
13053 | 106 (+ approx |
107 (calendar-sum y approx | |
108 (>= date (calendar-absolute-from-islamic | |
109 (list 1 1 (1+ y)))) | |
110 1))) | |
92644 | 111 (month ; search forward from Muharram |
13053 | 112 (1+ (calendar-sum m 1 |
113 (> date | |
114 (calendar-absolute-from-islamic | |
115 (list m | |
116 (islamic-calendar-last-day-of-month | |
117 m year) | |
118 year))) | |
119 1))) | |
92644 | 120 (day ; calculate the day by subtraction |
13053 | 121 (- date |
122 (1- (calendar-absolute-from-islamic (list month 1 year)))))) | |
123 (list month day year)))) | |
124 | |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
125 ;;;###cal-autoload |
13053 | 126 (defun calendar-islamic-date-string (&optional date) |
127 "String of Islamic date before sunset of Gregorian DATE. | |
128 Returns the empty string if DATE is pre-Islamic. | |
129 Defaults to today's date if DATE is not given. | |
130 Driven by the variable `calendar-date-display-form'." | |
131 (let ((calendar-month-name-array calendar-islamic-month-name-array) | |
132 (islamic-date (calendar-islamic-from-absolute | |
133 (calendar-absolute-from-gregorian | |
134 (or date (calendar-current-date)))))) | |
135 (if (< (extract-calendar-year islamic-date) 1) | |
136 "" | |
137 (calendar-date-string islamic-date nil t)))) | |
138 | |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
139 ;;;###cal-autoload |
13053 | 140 (defun calendar-print-islamic-date () |
141 "Show the Islamic calendar equivalent of the date under the cursor." | |
142 (interactive) | |
143 (let ((i (calendar-islamic-date-string (calendar-cursor-to-date t)))) | |
144 (if (string-equal i "") | |
145 (message "Date is pre-Islamic") | |
146 (message "Islamic date (until sunset): %s" i)))) | |
147 | |
93184
63a7509590a7
(calendar-islamic-read-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92991
diff
changeset
|
148 (defun calendar-islamic-read-date () |
63a7509590a7
(calendar-islamic-read-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92991
diff
changeset
|
149 "Interactively read the arguments for an Islamic date command. |
63a7509590a7
(calendar-islamic-read-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92991
diff
changeset
|
150 Reads a year, month, and day." |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
151 (let* ((today (calendar-current-date)) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
152 (year (calendar-read |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
153 "Islamic calendar year (>0): " |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
154 (lambda (x) (> x 0)) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
155 (int-to-string |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
156 (extract-calendar-year |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
157 (calendar-islamic-from-absolute |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
158 (calendar-absolute-from-gregorian today)))))) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
159 (month-array calendar-islamic-month-name-array) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
160 (completion-ignore-case t) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
161 (month (cdr (assoc-string |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
162 (completing-read |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
163 "Islamic calendar month name: " |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
164 (mapcar 'list (append month-array nil)) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
165 nil t) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
166 (calendar-make-alist month-array 1) t))) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
167 (last (islamic-calendar-last-day-of-month month year)) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
168 (day (calendar-read |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
169 (format "Islamic calendar day (1-%d): " last) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
170 (lambda (x) (and (< 0 x) (<= x last)))))) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
171 (list (list month day year)))) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
172 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
173 ;;;###cal-autoload |
13053 | 174 (defun calendar-goto-islamic-date (date &optional noecho) |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
175 "Move cursor to Islamic DATE; echo Islamic date unless NOECHO is non-nil." |
93184
63a7509590a7
(calendar-islamic-read-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92991
diff
changeset
|
176 (interactive (calendar-islamic-read-date)) |
13053 | 177 (calendar-goto-date (calendar-gregorian-from-absolute |
178 (calendar-absolute-from-islamic date))) | |
179 (or noecho (calendar-print-islamic-date))) | |
180 | |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
181 (defvar displayed-month) ; from generate-calendar |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
182 (defvar displayed-year) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
183 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
184 ;;;###holiday-autoload |
13053 | 185 (defun holiday-islamic (month day string) |
186 "Holiday on MONTH, DAY (Islamic) called STRING. | |
187 If MONTH, DAY (Islamic) is visible, the value returned is corresponding | |
188 Gregorian date in the form of the list (((month day year) STRING)). Returns | |
189 nil if it is not visible in the current calendar window." | |
190 (let* ((islamic-date (calendar-islamic-from-absolute | |
191 (calendar-absolute-from-gregorian | |
192 (list displayed-month 15 displayed-year)))) | |
193 (m (extract-calendar-month islamic-date)) | |
194 (y (extract-calendar-year islamic-date)) | |
195 (date)) | |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
196 (unless (< m 1) ; Islamic calendar doesn't apply |
13053 | 197 (increment-calendar-month m y (- 10 month)) |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
198 (if (> m 7) ; Islamic date might be visible |
13053 | 199 (let ((date (calendar-gregorian-from-absolute |
200 (calendar-absolute-from-islamic (list month day y))))) | |
201 (if (calendar-date-is-visible-p date) | |
202 (list (list date string)))))))) | |
203 | |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
204 (autoload 'diary-list-entries-1 "diary-lib") |
92677
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
205 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
206 ;;;###diary-autoload |
13053 | 207 (defun list-islamic-diary-entries () |
208 "Add any Islamic date entries from the diary file to `diary-entries-list'. | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
209 Islamic date diary entries must be prefaced by `islamic-diary-entry-symbol' |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
210 \(normally an `I'). The same `diary-date-forms' govern the style |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
211 of the Islamic calendar entries, except that the Islamic month |
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
212 names must be spelled in full. The Islamic months are numbered |
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
213 from 1 to 12 with Muharram being 1 and 12 being Dhu al-Hijjah. |
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
214 If an Islamic date diary entry begins with `diary-nonmarking-symbol', |
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
215 the entry will appear in the diary listing, but will not be |
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
216 marked in the calendar. This function is provided for use with |
13053 | 217 `nongregorian-diary-listing-hook'." |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
218 (diary-list-entries-1 calendar-islamic-month-name-array |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
219 islamic-diary-entry-symbol |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
220 'calendar-islamic-from-absolute)) |
13053 | 221 |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
222 (autoload 'calendar-mark-1 "diary-lib") |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
223 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
224 ;;;###diary-autoload |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
225 (defun mark-islamic-calendar-date-pattern (month day year &optional color) |
13053 | 226 "Mark dates in calendar window that conform to Islamic date MONTH/DAY/YEAR. |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
227 A value of 0 in any position is a wildcard. Optional argument COLOR is |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
228 passed to `mark-visible-calendar-date' as MARK." |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
229 (calendar-mark-1 month day year 'calendar-islamic-from-absolute |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
230 'calendar-absolute-from-islamic color)) |
13053 | 231 |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
232 (autoload 'diary-mark-entries-1 "diary-lib") |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
233 |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
234 ;;;###diary-autoload |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
235 (defun mark-islamic-diary-entries () |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
236 "Mark days in the calendar window that have Islamic date diary entries. |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
237 Marks each entry in `diary-file' (or included files) visible in the calendar |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
238 window. See `list-islamic-diary-entries' for more information." |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
239 (diary-mark-entries-1 calendar-islamic-month-name-array |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
240 islamic-diary-entry-symbol |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
241 'calendar-islamic-from-absolute |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
242 'mark-islamic-calendar-date-pattern)) |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
243 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
244 ;;;###cal-autoload |
13053 | 245 (defun insert-islamic-diary-entry (arg) |
246 "Insert a diary entry. | |
247 For the Islamic date corresponding to the date indicated by point. | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
248 Prefix argument ARG makes the entry nonmarking." |
13053 | 249 (interactive "P") |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
250 (let ((calendar-month-name-array calendar-islamic-month-name-array)) |
13053 | 251 (make-diary-entry |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
252 (concat islamic-diary-entry-symbol |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
253 (calendar-date-string |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
254 (calendar-islamic-from-absolute |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
255 (calendar-absolute-from-gregorian (calendar-cursor-to-date t))) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
256 nil t)) |
13053 | 257 arg))) |
258 | |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
259 ;;;###cal-autoload |
13053 | 260 (defun insert-monthly-islamic-diary-entry (arg) |
261 "Insert a monthly diary entry. | |
262 For the day of the Islamic month corresponding to the date indicated by point. | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
263 Prefix argument ARG makes the entry nonmarking." |
13053 | 264 (interactive "P") |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
265 (let ((calendar-date-display-form (if european-calendar-style |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
266 '(day " * ") |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
267 '("* " day ))) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
268 (calendar-month-name-array calendar-islamic-month-name-array)) |
13053 | 269 (make-diary-entry |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
270 (concat islamic-diary-entry-symbol |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
271 (calendar-date-string |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
272 (calendar-islamic-from-absolute |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
273 (calendar-absolute-from-gregorian (calendar-cursor-to-date t))))) |
13053 | 274 arg))) |
275 | |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
276 ;;;###cal-autoload |
13053 | 277 (defun insert-yearly-islamic-diary-entry (arg) |
278 "Insert an annual diary entry. | |
279 For the day of the Islamic year corresponding to the date indicated by point. | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
280 Prefix argument ARG makes the entry nonmarking." |
13053 | 281 (interactive "P") |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
282 (let ((calendar-date-display-form (if european-calendar-style |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
283 '(day " " monthname) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
284 '(monthname " " day))) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
285 (calendar-month-name-array calendar-islamic-month-name-array)) |
13053 | 286 (make-diary-entry |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
287 (concat islamic-diary-entry-symbol |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
288 (calendar-date-string |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
289 (calendar-islamic-from-absolute |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
290 (calendar-absolute-from-gregorian (calendar-cursor-to-date t))))) |
13053 | 291 arg))) |
292 | |
92677
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
293 (defvar date) |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
294 |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
295 ;; To be called from diary-sexp-entry, where DATE, ENTRY are bound. |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
296 ;;;###diary-autoload |
92677
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
297 (defun diary-islamic-date () |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
298 "Islamic calendar equivalent of date diary entry." |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
299 (let ((i (calendar-islamic-date-string date))) |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
300 (if (string-equal i "") |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
301 "Date is pre-Islamic" |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
302 (format "Islamic date (until sunset): %s" i)))) |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
303 |
14684
66450c507ee4
Renamed from cal-islamic.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
304 (provide 'cal-islam) |
13053 | 305 |
92585
c9eb56890fe0
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
306 ;; arch-tag: a951b6c1-6f47-48d5-bac3-1b505cd719f7 |
14684
66450c507ee4
Renamed from cal-islamic.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
307 ;;; cal-islam.el ends here |