annotate lisp/calendar/cal-bahai.el @ 92968:e2f0046a8cb4

(appt-check, appt-delete, appt-make-list): Use caar.
author Glenn Morris <rgm@gnu.org>
date Sat, 15 Mar 2008 02:59:34 +0000
parents 69683285b129
children 9bc37937216f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
92578
8b2b620788b7 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
1 ;;; cal-bahai.el --- calendar functions for the Bahá'í calendar.
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
2
79703
974a828870fe Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78216
diff changeset
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
68721
8daf7d9a0771 Add 2006 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 67465
diff changeset
4 ;; Free Software Foundation, Inc.
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
5
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
6 ;; Author: John Wiegley <johnw@gnu.org>
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
7 ;; Keywords: calendar
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
8 ;; Human-Keywords: Bahá'í calendar, Bahá'í, Baha'i, Bahai, calendar, diary
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
9
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
11
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
13 ;; 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: 78143
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
15 ;; any later version.
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
16
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
21
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62402
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62402
diff changeset
25 ;; Boston, MA 02110-1301, USA.
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
26
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
27 ;;; Commentary:
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
28
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
29 ;; This collection of functions implements the features of calendar.el
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
30 ;; and diary.el that deal with the Bahá'í calendar.
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
31
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
32 ;; The Bahá'í (http://www.bahai.org) calendar system is based on a
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
33 ;; solar cycle of 19 months with 19 days each. The four remaining
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
34 ;; "intercalary" days are called the Ayyám-i-Há (days of Há), and are
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
35 ;; placed between the 18th and 19th months. They are meant as a time
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
36 ;; of festivals preceding the 19th month, which is the month of
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
37 ;; fasting. In Gregorian leap years, there are 5 of these days (Há
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
38 ;; has the numerical value of 5 in the arabic abjad, or
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
39 ;; letter-to-number, reckoning).
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
40
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
41 ;; Each month is named after an attribute of God, as are the 19 days
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
42 ;; -- which have the same names as the months. There is also a name
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
43 ;; for each year in every 19 year cycle. These cycles are called
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
44 ;; Váhids. A cycle of 19 Váhids (361 years) is called a Kullu-Shay,
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
45 ;; which means "all things".
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
46
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
47 ;; The calendar was named the "Badí` calendar" by its author, the Báb.
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
48 ;; It uses a week of seven days, corresponding to the Gregorian week,
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
49 ;; each of which has its own name, again patterned after the
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
50 ;; attributes of God.
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
51
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
52 ;; Note: The days of Ayyám-i-Há are encoded as zero and negative
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
53 ;; offsets from the first day of the final month. So, (19 -3 157) is
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
54 ;; the first day of Ayyám-i-Há, in the year 157 BE.
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
55
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
56 ;;; Code:
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
57
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
58 (require 'cal-julian)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
59
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
60 (defconst calendar-bahai-month-name-array
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
61 ["Bahá" "Jalál" "Jamál" "`Azamat" "Núr" "Rahmat" "Kalimát" "Kamál"
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
62 "Asmá" "`Izzat" "Mashiyyat" "`Ilm" "Qudrat" "Qawl" "Masá'il"
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
63 "Sharaf" "Sultán" "Mulk" "`Alá"]
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
64 "Array of the month names in the Bahá'í calendar.")
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
65
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
66 (defconst calendar-bahai-epoch (calendar-absolute-from-gregorian '(3 21 1844))
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
67 "Absolute date of start of Bahá'í calendar = March 19, 622 A.D. (Julian).")
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
68
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
69 (defun calendar-bahai-leap-year-p (year)
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
70 "True if YEAR is a leap year on the Bahá'í calendar."
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
71 (calendar-leap-year-p (+ year 1844)))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
72
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
73 (defconst calendar-bahai-leap-base
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
74 (+ (/ 1844 4) (- (/ 1844 100)) (/ 1844 400))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
75 "Used by `calendar-absolute-from-bahai'.")
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
76
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
77 (defun calendar-absolute-from-bahai (date)
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
78 "Compute absolute date from Bahá'í date DATE.
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
79 The absolute date is the number of days elapsed since the (imaginary)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
80 Gregorian date Sunday, December 31, 1 BC."
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
81 (let* ((month (extract-calendar-month date))
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
82 (day (extract-calendar-day date))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
83 (year (extract-calendar-year date))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
84 (prior-years (+ (1- year) 1844))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
85 (leap-days (- (+ (/ prior-years 4) ; leap days in prior years
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
86 (- (/ prior-years 100))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
87 (/ prior-years 400))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
88 calendar-bahai-leap-base)))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
89 (+ (1- calendar-bahai-epoch) ; days before epoch
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
90 (* 365 (1- year)) ; days in prior years
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
91 leap-days
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
92 (calendar-sum m 1 (< m month) 19)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
93 (if (= month 19) 4 0)
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
94 day))) ; days so far this month
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
95
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
96 (defun calendar-bahai-from-absolute (date)
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
97 "Bahá'í year corresponding to the absolute DATE."
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
98 (if (< date calendar-bahai-epoch)
92652
fa071bcc1d62 Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92615
diff changeset
99 (list 0 0 0) ; pre-Bahá'í date
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
100 (let* ((greg (calendar-gregorian-from-absolute date))
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
101 (year (+ (- (extract-calendar-year greg) 1844)
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
102 (if (or (> (extract-calendar-month greg) 3)
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
103 (and (= (extract-calendar-month greg) 3)
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
104 (>= (extract-calendar-day greg) 21)))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
105 1 0)))
92652
fa071bcc1d62 Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92615
diff changeset
106 (month ; search forward from Baha
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
107 (1+ (calendar-sum m 1
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
108 (> date
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
109 (calendar-absolute-from-bahai
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
110 (list m 19 year)))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
111 1)))
92652
fa071bcc1d62 Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92615
diff changeset
112 (day ; calculate the day by subtraction
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
113 (- date
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
114 (1- (calendar-absolute-from-bahai (list month 1 year))))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
115 (list month day year))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
116
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
117 ;;;###cal-autoload
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
118 (defun calendar-bahai-date-string (&optional date)
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
119 "String of Bahá'í date of Gregorian DATE.
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
120 Defaults to today's date if DATE is not given."
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
121 (let* ((bahai-date (calendar-bahai-from-absolute
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
122 (calendar-absolute-from-gregorian
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
123 (or date (calendar-current-date)))))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
124 (y (extract-calendar-year bahai-date))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
125 (m (extract-calendar-month bahai-date))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
126 (d (extract-calendar-day bahai-date)))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
127 (let ((monthname
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
128 (if (and (= m 19)
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
129 (<= d 0))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
130 "Ayyám-i-Há"
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
131 (aref calendar-bahai-month-name-array (1- m))))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
132 (day (int-to-string
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
133 (if (<= d 0)
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
134 (if (calendar-bahai-leap-year-p y)
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
135 (+ d 5)
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
136 (+ d 4))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
137 d)))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
138 (dayname nil)
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
139 (month (int-to-string m))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
140 (year (int-to-string y)))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
141 (mapconcat 'eval calendar-date-display-form ""))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
142
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
143 ;;;###cal-autoload
84581
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
144 (defun calendar-bahai-print-date ()
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
145 "Show the Bahá'í calendar equivalent of the selected date."
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
146 (interactive)
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
147 (message "Bahá'í date: %s"
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
148 (calendar-bahai-date-string (calendar-cursor-to-date t))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
149
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
150 (defun calendar-bahai-prompt-for-date ()
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
151 "Ask for a Bahá'í date."
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
152 (let* ((today (calendar-current-date))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
153 (year (calendar-read
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
154 "Bahá'í calendar year (not 0): "
92615
3dd341aae76d (calendar-bahai-prompt-for-date, calendar-bahai-mark-date-pattern):
Glenn Morris <rgm@gnu.org>
parents: 92578
diff changeset
155 (lambda (x) (not (zerop x)))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
156 (int-to-string
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
157 (extract-calendar-year
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
158 (calendar-bahai-from-absolute
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
159 (calendar-absolute-from-gregorian today))))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
160 (completion-ignore-case t)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
161 (month (cdr (assoc
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
162 (completing-read
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
163 "Bahá'í calendar month name: "
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
164 (mapcar 'list
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
165 (append calendar-bahai-month-name-array nil))
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
166 nil t)
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
167 (calendar-make-alist calendar-bahai-month-name-array
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
168 1))))
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
169 (day (calendar-read "Bahá'í calendar day (1-19): "
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
170 (lambda (x) (and (< 0 x) (<= x 19))))))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
171 (list (list month day year))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
172
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
173 ;;;###cal-autoload
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
174 (defun calendar-bahai-goto-date (date &optional noecho)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
175 "Move cursor to Bahá'í date DATE.
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
176 Echo Bahá'í date unless NOECHO is non-nil."
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
177 (interactive (calendar-bahai-prompt-for-date))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
178 (calendar-goto-date (calendar-gregorian-from-absolute
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
179 (calendar-absolute-from-bahai date)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
180 (or noecho (calendar-bahai-print-date)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
181
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
182 (defvar displayed-month)
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
183 (defvar displayed-year)
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
184
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
185 ;;;###holiday-autoload
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
186 (defun holiday-bahai (month day string)
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
187 "Holiday on MONTH, DAY (Bahá'í) called STRING.
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
188 If MONTH, DAY (Bahá'í) is visible, the value returned is corresponding
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
189 Gregorian date in the form of the list (((month day year) STRING)). Returns
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
190 nil if it is not visible in the current calendar window."
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
191 (let* ((bahai-date (calendar-bahai-from-absolute
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
192 (calendar-absolute-from-gregorian
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
193 (list displayed-month 15 displayed-year))))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
194 (m (extract-calendar-month bahai-date))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
195 (y (extract-calendar-year bahai-date))
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
196 (date))
92911
69683285b129 (holiday-bahai, calendar-bahai-mark-date-pattern): Use unless.
Glenn Morris <rgm@gnu.org>
parents: 92909
diff changeset
197 (unless (< m 1) ; Bahá'í calendar doesn't apply
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
198 (increment-calendar-month m y (- 10 month))
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
199 (if (> m 7) ; Bahá'í date might be visible
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
200 (let ((date (calendar-gregorian-from-absolute
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
201 (calendar-absolute-from-bahai (list month day y)))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
202 (if (calendar-date-is-visible-p date)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
203 (list (list date string))))))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
204
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
205 (defvar number)
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
206 (defvar original-date)
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
207
86488
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
208 ;; d-b-l-e should be called from diary code.
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
209 (declare-function add-to-diary-list "diary-lib"
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
210 (date string specifier &optional marker globcolor literal))
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
211
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
212 ;;;###diary-autoload
84581
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
213 (defun diary-bahai-list-entries ()
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
214 "Add any Bahá'í date entries from the diary file to `diary-entries-list'.
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
215 Bahá'í date diary entries must be prefaced by `bahai-diary-entry-symbol'
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
216 \(normally a `B'). The same diary date forms govern the style of the
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
217 Bahá'í calendar entries, except that the Bahá'í month names must be given
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
218 numerically. The Bahá'í months are numbered from 1 to 19 with Bahá being
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
219 1 and 19 being `Alá. If a Bahá'í date diary entry begins with
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
220 `diary-nonmarking-symbol', the entry will appear in the diary listing, but
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
221 will not be marked in the calendar. This function is provided for use with
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
222 `nongregorian-diary-listing-hook'."
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
223 (if (< 0 number)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
224 (let ((buffer-read-only nil)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
225 (diary-modified (buffer-modified-p))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
226 (gdate original-date)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
227 (mark (regexp-quote diary-nonmarking-symbol)))
82082
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
228 (dotimes (idummy number)
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
229 (let* ((bdate (calendar-bahai-from-absolute
82082
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
230 (calendar-absolute-from-gregorian gdate)))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
231 (month (extract-calendar-month bdate))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
232 (day (extract-calendar-day bdate))
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
233 (year (extract-calendar-year bdate))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
234 backup)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
235 (dolist (date-form diary-date-forms)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
236 (if (setq backup (eq (car date-form) 'backup))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
237 (setq date-form (cdr date-form)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
238 (let* ((dayname
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
239 (concat
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
240 (calendar-day-name gdate) "\\|"
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
241 (substring (calendar-day-name gdate) 0 3) ".?"))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
242 (calendar-month-name-array
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
243 calendar-bahai-month-name-array)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
244 (monthname
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
245 (concat
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
246 "\\*\\|"
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
247 (calendar-month-name month)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
248 (month (concat "\\*\\|0*" (int-to-string month)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
249 (day (concat "\\*\\|0*" (int-to-string day)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
250 (year
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
251 (concat
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
252 "\\*\\|0*" (int-to-string year)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
253 (if abbreviated-calendar-year
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
254 (concat "\\|" (int-to-string (% year 100)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
255 "")))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
256 ;; FIXME get rid of the ^M stuff.
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
257 (regexp
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
258 (concat
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
259 "\\(\\`\\|\^M\\|\n\\)" mark "?"
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
260 (regexp-quote bahai-diary-entry-symbol)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
261 "\\("
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
262 (mapconcat 'eval date-form "\\)\\(")
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
263 "\\)"))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
264 (case-fold-search t))
82082
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
265 (goto-char (point-min))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
266 (while (re-search-forward regexp nil t)
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
267 (if backup (re-search-backward "\\<" nil t))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
268 (if (and (or (char-equal (preceding-char) ?\^M)
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
269 (char-equal (preceding-char) ?\n))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
270 (not (looking-at " \\|\^I")))
92652
fa071bcc1d62 Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92615
diff changeset
271 ;; Diary entry that consists only of date.
82082
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
272 (backward-char 1)
92652
fa071bcc1d62 Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92615
diff changeset
273 ;; Found a nonempty diary entry--make it visible and
fa071bcc1d62 Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92615
diff changeset
274 ;; add it to the list.
82082
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
275 (let ((entry-start (point))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
276 (date-start))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
277 (re-search-backward "\^M\\|\n\\|\\`")
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
278 (setq date-start (point))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
279 (re-search-forward "\^M\\|\n" nil t 2)
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
280 (while (looking-at " \\|\^I")
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
281 (re-search-forward "\^M\\|\n" nil t))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
282 (backward-char 1)
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
283 (subst-char-in-region date-start (point) ?\^M ?\n t)
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
284 (add-to-diary-list
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
285 gdate
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
286 (buffer-substring-no-properties entry-start (point))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
287 (buffer-substring-no-properties
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
288 (1+ date-start) (1- entry-start)))))))))
82082
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
289 (setq gdate
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
290 (calendar-gregorian-from-absolute
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
291 (1+ (calendar-absolute-from-gregorian gdate)))))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
292 (set-buffer-modified-p diary-modified))
62a75b41aa25 (list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents: 78143
diff changeset
293 (goto-char (point-min))))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
294
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
295 ;;;###diary-autoload
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
296 (defun calendar-bahai-mark-date-pattern (month day year)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
297 "Mark dates in calendar window that conform to Bahá'í date MONTH/DAY/YEAR.
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
298 A value of 0 in any position is a wildcard."
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
299 (save-excursion
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
300 (set-buffer calendar-buffer)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
301 (if (and (not (zerop month)) (not (zerop day)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
302 (if (not (zerop year))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
303 ;; Fully specified Bahá'í date.
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
304 (let ((date (calendar-gregorian-from-absolute
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
305 (calendar-absolute-from-bahai
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
306 (list month day year)))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
307 (if (calendar-date-is-visible-p date)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
308 (mark-visible-calendar-date date)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
309 ;; Month and day in any year--this taken from the holiday stuff.
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
310 (let* ((bahai-date (calendar-bahai-from-absolute
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
311 (calendar-absolute-from-gregorian
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
312 (list displayed-month 15 displayed-year))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
313 (m (extract-calendar-month bahai-date))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
314 (y (extract-calendar-year bahai-date))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
315 (date))
92911
69683285b129 (holiday-bahai, calendar-bahai-mark-date-pattern): Use unless.
Glenn Morris <rgm@gnu.org>
parents: 92909
diff changeset
316 (unless (< m 1) ; Bahá'í calendar doesn't apply
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
317 (increment-calendar-month m y (- 10 month))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
318 (if (> m 7) ; Bahá'í date might be visible
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
319 (let ((date (calendar-gregorian-from-absolute
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
320 (calendar-absolute-from-bahai
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
321 (list month day y)))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
322 (if (calendar-date-is-visible-p date)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
323 (mark-visible-calendar-date date)))))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
324 ;; Not one of the simple cases--check all visible dates for match.
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
325 ;; Actually, the following code takes care of ALL of the cases, but
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
326 ;; it's much too slow to be used for the simple (common) cases.
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
327 (let ((m displayed-month)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
328 (y displayed-year)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
329 (first-date)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
330 (last-date))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
331 (increment-calendar-month m y -1)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
332 (setq first-date
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
333 (calendar-absolute-from-gregorian
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
334 (list m 1 y)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
335 (increment-calendar-month m y 2)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
336 (setq last-date
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
337 (calendar-absolute-from-gregorian
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
338 (list m (calendar-last-day-of-month m y) y)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
339 (calendar-for-loop date from first-date to last-date do
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
340 (let* ((b-date (calendar-bahai-from-absolute date))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
341 (i-month (extract-calendar-month b-date))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
342 (i-day (extract-calendar-day b-date))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
343 (i-year (extract-calendar-year b-date)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
344 (and (or (zerop month)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
345 (= month i-month))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
346 (or (zerop day)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
347 (= day i-day))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
348 (or (zerop year)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
349 (= year i-year))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
350 (mark-visible-calendar-date
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
351 (calendar-gregorian-from-absolute
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
352 date)))))))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
353
86488
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
354 (declare-function diary-name-pattern "diary-lib"
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
355 (string-array &optional abbrev-array paren))
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
356
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
357 (declare-function mark-calendar-days-named "diary-lib"
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
358 (dayname &optional color))
41a473ff321a (add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents: 84590
diff changeset
359
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
360 ;;;###diary-autoload
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
361 (defun diary-bahai-mark-entries ()
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
362 "Mark days in the calendar window that have Bahá'í date diary entries.
92659
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
363 Each entry in `diary-file' (or included files) visible in the calendar
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
364 window is marked. Bahá'í date entries are prefaced by
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
365 `bahai-diary-entry-symbol' (normally a \"B\"). The same
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
366 `diary-date-forms' govern the style of the Bahá'í calendar entries,
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
367 except that the Bahá'í month names must be spelled in full. The
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
368 Bahá'í months are numbered from 1 to 12 with Bahá being 1 and 12 being
92659
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
369 `Alá. Bahá'í date diary entries that begin with `diary-nonmarking-symbol'
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
370 will not be marked in the calendar. This function is provided for use as
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
371 part of `nongregorian-diary-marking-hook'."
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
372 (let ((dayname (diary-name-pattern calendar-day-name-array))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
373 (monthname
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
374 (concat
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
375 (diary-name-pattern calendar-bahai-month-name-array t)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
376 "\\|\\*"))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
377 (month "[0-9]+\\|\\*")
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
378 (day "[0-9]+\\|\\*")
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
379 (year "[0-9]+\\|\\*")
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
380 (case-fold-search t))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
381 (dolist (date-form diary-date-forms)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
382 (if (eq (car date-form) 'backup) ; ignore 'backup directive
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
383 (setq date-form (cdr date-form)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
384 (let* ((l (length date-form))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
385 (d-name-pos (- l (length (memq 'dayname date-form))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
386 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
387 (m-name-pos (- l (length (memq 'monthname date-form))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
388 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
389 (d-pos (- l (length (memq 'day date-form))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
390 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
391 (m-pos (- l (length (memq 'month date-form))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
392 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
393 (y-pos (- l (length (memq 'year date-form))))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
394 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
395 (regexp
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
396 (concat
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
397 "\\(\\`\\|\^M\\|\n\\)"
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
398 (regexp-quote bahai-diary-entry-symbol)
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
399 "\\("
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
400 (mapconcat 'eval date-form "\\)\\(")
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
401 "\\)")))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
402 (goto-char (point-min))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
403 (while (re-search-forward regexp nil t)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
404 (let* ((dd-name
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
405 (if d-name-pos
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
406 (buffer-substring
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
407 (match-beginning d-name-pos)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
408 (match-end d-name-pos))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
409 (mm-name
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
410 (if m-name-pos
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
411 (buffer-substring
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
412 (match-beginning m-name-pos)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
413 (match-end m-name-pos))))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62123
diff changeset
414 (mm (string-to-number
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
415 (if m-pos
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
416 (buffer-substring
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
417 (match-beginning m-pos)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
418 (match-end m-pos))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
419 "")))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62123
diff changeset
420 (dd (string-to-number
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
421 (if d-pos
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
422 (buffer-substring
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
423 (match-beginning d-pos)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
424 (match-end d-pos))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
425 "")))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
426 (y-str (if y-pos
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
427 (buffer-substring
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
428 (match-beginning y-pos)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
429 (match-end y-pos))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
430 (yy (if (not y-str)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
431 0
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
432 (if (and (= (length y-str) 2)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
433 abbreviated-calendar-year)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
434 (let* ((current-y
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
435 (extract-calendar-year
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
436 (calendar-bahai-from-absolute
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
437 (calendar-absolute-from-gregorian
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
438 (calendar-current-date)))))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62123
diff changeset
439 (y (+ (string-to-number y-str)
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
440 (* 100 (/ current-y 100)))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
441 (if (> (- y current-y) 50)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
442 (- y 100)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
443 (if (> (- current-y y) 50)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
444 (+ y 100)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
445 y)))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 62123
diff changeset
446 (string-to-number y-str)))))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
447 (if dd-name
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
448 (mark-calendar-days-named
62123
8c992d4395d2 (mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 55461
diff changeset
449 (cdr (assoc-string (substring dd-name 0 3)
8c992d4395d2 (mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 55461
diff changeset
450 (calendar-make-alist
8c992d4395d2 (mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 55461
diff changeset
451 calendar-day-name-array
8c992d4395d2 (mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 55461
diff changeset
452 0
92578
8b2b620788b7 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
453 (lambda (x) (substring x 0 3)))
62123
8c992d4395d2 (mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 55461
diff changeset
454 t)))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
455 (if mm-name
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
456 (if (string-equal mm-name "*")
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
457 (setq mm 0)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
458 (setq mm
62123
8c992d4395d2 (mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 55461
diff changeset
459 (cdr (assoc-string
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
460 mm-name
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
461 (calendar-make-alist
92849
d72b782e6c81 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92826
diff changeset
462 calendar-bahai-month-name-array)
62123
8c992d4395d2 (mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents: 55461
diff changeset
463 t)))))
92909
e6b06f524f2b (calendar-bahai-month-name-array, calendar-bahai-leap-base): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents: 92849
diff changeset
464 (calendar-bahai-mark-date-pattern mm dd yy))))))))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
465
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
466 ;;;###cal-autoload
84581
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
467 (defun diary-bahai-insert-entry (arg)
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
468 "Insert a diary entry.
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
469 For the Bahá'í date corresponding to the date indicated by point.
92659
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
470 Prefix argument ARG makes the entry nonmarking."
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
471 (interactive "P")
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
472 (let* ((calendar-month-name-array calendar-bahai-month-name-array))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
473 (make-diary-entry
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
474 (concat
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
475 bahai-diary-entry-symbol
65141
fad69800a5b0 (date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents: 64085
diff changeset
476 (calendar-date-string
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
477 (calendar-bahai-from-absolute
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
478 (calendar-absolute-from-gregorian
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
479 (calendar-cursor-to-date t)))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
480 nil t))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
481 arg)))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
482
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
483 ;;;###cal-autoload
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
484 (defun diary-bahai-insert-monthly-entry (arg)
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
485 "Insert a monthly diary entry.
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
486 For the day of the Bahá'í month corresponding to the date indicated by point.
92659
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
487 Prefix argument ARG makes the entry nonmarking."
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
488 (interactive "P")
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
489 (let* ((calendar-date-display-form
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
490 (if european-calendar-style '(day " * ") '("* " day )))
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
491 (calendar-month-name-array calendar-bahai-month-name-array))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
492 (make-diary-entry
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
493 (concat
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
494 bahai-diary-entry-symbol
65141
fad69800a5b0 (date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents: 64085
diff changeset
495 (calendar-date-string
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
496 (calendar-bahai-from-absolute
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
497 (calendar-absolute-from-gregorian
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
498 (calendar-cursor-to-date t)))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
499 arg)))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
500
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
501 ;;;###cal-autoload
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
502 (defun diary-bahai-insert-yearly-entry (arg)
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
503 "Insert an annual diary entry.
82787
03ac28e9a566 2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 82177
diff changeset
504 For the day of the Bahá'í year corresponding to the date indicated by point.
92659
678337768a80 (diary-bahai-mark-entries)
Glenn Morris <rgm@gnu.org>
parents: 92652
diff changeset
505 Prefix argument ARG will make the entry nonmarking."
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
506 (interactive "P")
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
507 (let* ((calendar-date-display-form
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
508 (if european-calendar-style
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
509 '(day " " monthname)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
510 '(monthname " " day)))
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
511 (calendar-month-name-array calendar-bahai-month-name-array))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
512 (make-diary-entry
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
513 (concat
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
514 bahai-diary-entry-symbol
65141
fad69800a5b0 (date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents: 64085
diff changeset
515 (calendar-date-string
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
516 (calendar-bahai-from-absolute
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
517 (calendar-absolute-from-gregorian
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
518 (calendar-cursor-to-date t)))))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
519 arg)))
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
520
92826
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
521 (defvar date)
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
522
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
523 ;; To be called from list-sexp-diary-entries, where DATE is bound.
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
524 ;;;###diary-autoload
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
525 (defun diary-bahai-date ()
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
526 "Bahá'í calendar equivalent of date diary entry."
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
527 (format "Bahá'í date: %s" (calendar-bahai-date-string date)))
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
528
416592e7d882 Move variable declarations where they are needed.
Glenn Morris <rgm@gnu.org>
parents: 92659
diff changeset
529
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
530 ;; Backward compatibility.
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
531 (define-obsolete-function-alias
84581
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
532 'list-bahai-diary-entries 'diary-bahai-list-entries "23.1")
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
533 (define-obsolete-function-alias
84581
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
534 'mark-bahai-diary-entries 'diary-bahai-mark-entries "23.1")
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
535 (define-obsolete-function-alias
84581
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
536 'insert-bahai-diary-entry 'diary-bahai-insert-entry "23.1")
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
537 (define-obsolete-function-alias
84590
1cfbc4c30509 Fix typos in aliases in previous change.
Glenn Morris <rgm@gnu.org>
parents: 84581
diff changeset
538 'insert-monthly-bahai-diary-entry 'diary-bahai-insert-monthly-entry "23.1")
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
539 (define-obsolete-function-alias
84590
1cfbc4c30509 Fix typos in aliases in previous change.
Glenn Morris <rgm@gnu.org>
parents: 84581
diff changeset
540 'insert-yearly-bahai-diary-entry 'diary-bahai-insert-yearly-entry "23.1")
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
541 (define-obsolete-function-alias
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
542 'mark-bahai-calendar-date-pattern 'calendar-bahai-mark-date-pattern "23.1")
84581
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
543 (define-obsolete-function-alias
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
544 'calendar-goto-bahai-date 'calendar-bahai-goto-date "23.1")
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
545 (define-obsolete-function-alias
96df62307dfc (mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82833
diff changeset
546 'calendar-print-bahai-date 'calendar-bahai-print-date "23.1")
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
547
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
548 (provide 'cal-bahai)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
549
92578
8b2b620788b7 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
550 ;; Local Variables:
8b2b620788b7 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
551 ;; coding: utf-8
8b2b620788b7 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
552 ;; End:
8b2b620788b7 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
553
82177
f673ee49d36e (calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
554 ;; arch-tag: c1cb1d67-862a-4264-a01c-41cb4df01f14
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff changeset
555 ;;; cal-bahai.el ends here