Mercurial > emacs
annotate lisp/calendar/cal-bahai.el @ 91521:e96ff7166c81
(w32font_open_internal): Use xmalloc, xrealloc, xfree.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Mon, 04 Feb 2008 15:41:52 +0000 |
parents | 107ccd98fa12 |
children | 8b2b620788b7 |
rev | line source |
---|---|
82833 | 1 ;;; cal-bahai.el --- calendar functions for the Bahá'í calendar. -*- coding: utf-8 -*- |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
2 |
79703 | 3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
68721 | 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 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
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 |
65141
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
58 (defvar date) |
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
59 (defvar displayed-month) |
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
60 (defvar displayed-year) |
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
61 (defvar number) |
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
62 (defvar original-date) |
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
63 |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
64 (require 'cal-julian) |
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-month-name-array |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
67 ["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
|
68 "Asmá" "`Izzat" "Mashiyyat" "`Ilm" "Qudrat" "Qawl" "Masá'il" |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
69 "Sharaf" "Sultán" "Mulk" "`Alá"]) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
70 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
71 (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
|
72 "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
|
73 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
74 (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
|
75 "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
|
76 (calendar-leap-year-p (+ year 1844))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
77 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
78 (defconst calendar-bahai-leap-base |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
79 (+ (/ 1844 4) (- (/ 1844 100)) (/ 1844 400))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
80 |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
81 (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
|
82 "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
|
83 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
|
84 Gregorian date Sunday, December 31, 1 BC." |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
85 (let* ((month (extract-calendar-month date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
86 (day (extract-calendar-day date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
87 (year (extract-calendar-year date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
88 (prior-years (+ (1- year) 1844)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
89 (leap-days (- (+ (/ prior-years 4) ; Leap days in prior years. |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
90 (- (/ prior-years 100)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
91 (/ prior-years 400)) |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
92 calendar-bahai-leap-base))) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
93 (+ (1- calendar-bahai-epoch) ; Days before epoch |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
94 (* 365 (1- year)) ; Days in prior years. |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
95 leap-days |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
96 (calendar-sum m 1 (< m month) 19) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
97 (if (= month 19) 4 0) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
98 day))) ; Days so far this month. |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
99 |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
100 (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
|
101 "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
|
102 (if (< date calendar-bahai-epoch) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
103 (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
|
104 (let* ((greg (calendar-gregorian-from-absolute date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
105 (year (+ (- (extract-calendar-year greg) 1844) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
106 (if (or (> (extract-calendar-month greg) 3) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
107 (and (= (extract-calendar-month greg) 3) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
108 (>= (extract-calendar-day greg) 21))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
109 1 0))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
110 (month ;; Search forward from Baha. |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
111 (1+ (calendar-sum m 1 |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
112 (> date |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
113 (calendar-absolute-from-bahai |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
114 (list m 19 year))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
115 1))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
116 (day ;; Calculate the day by subtraction. |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
117 (- date |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
118 (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
|
119 (list month day year)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
120 |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
121 (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
|
122 "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
|
123 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
|
124 (let* ((bahai-date (calendar-bahai-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
125 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
126 (or date (calendar-current-date))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
127 (y (extract-calendar-year bahai-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
128 (m (extract-calendar-month bahai-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
129 (d (extract-calendar-day bahai-date))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
130 (let ((monthname |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
131 (if (and (= m 19) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
132 (<= d 0)) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
133 "Ayyám-i-Há" |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
134 (aref calendar-bahai-month-name-array (1- m)))) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
135 (day (int-to-string |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
136 (if (<= d 0) |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
137 (if (calendar-bahai-leap-year-p y) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
138 (+ d 5) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
139 (+ d 4)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
140 d))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
141 (dayname nil) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
142 (month (int-to-string m)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
143 (year (int-to-string y))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
144 (mapconcat 'eval calendar-date-display-form "")))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
145 |
84581
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
146 (defun calendar-bahai-print-date () |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
147 "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
|
148 (interactive) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
149 (message "Bahá'í date: %s" |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
150 (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
|
151 |
84581
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
152 (defun calendar-bahai-goto-date (date &optional noecho) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
153 "Move cursor to Bahá'í date DATE. |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
154 Echo Bahá'í date unless NOECHO is t." |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
155 (interactive (calendar-bahai-prompt-for-date)) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
156 (calendar-goto-date (calendar-gregorian-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
157 (calendar-absolute-from-bahai date))) |
84581
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
158 (or noecho (calendar-bahai-print-date))) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
159 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
160 (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
|
161 "Ask for a Bahá'í date." |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
162 (let* ((today (calendar-current-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
163 (year (calendar-read |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
164 "Bahá'í calendar year (not 0): " |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
165 '(lambda (x) (/= x 0)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
166 (int-to-string |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
167 (extract-calendar-year |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
168 (calendar-bahai-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
169 (calendar-absolute-from-gregorian today)))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
170 (completion-ignore-case t) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
171 (month (cdr (assoc |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
172 (completing-read |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
173 "Bahá'í calendar month name: " |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
174 (mapcar 'list |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
175 (append calendar-bahai-month-name-array nil)) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
176 nil t) |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
177 (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
|
178 1)))) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
179 (day (calendar-read "Bahá'í calendar day (1-19): " |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
180 '(lambda (x) (and (< 0 x) (<= x 19)))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
181 (list (list month day year)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
182 |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
183 (defun diary-bahai-date () |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
184 "Bahá'í calendar equivalent of date diary entry." |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
185 (format "Bahá'í date: %s" (calendar-bahai-date-string date))) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
186 |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
187 (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
|
188 "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
|
189 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
|
190 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
|
191 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
|
192 (let* ((bahai-date (calendar-bahai-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
193 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
194 (list displayed-month 15 displayed-year)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
195 (m (extract-calendar-month bahai-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
196 (y (extract-calendar-year bahai-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
197 (date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
198 (if (< m 1) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
199 nil ;; Bahá'í calendar doesn't apply. |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
200 (increment-calendar-month m y (- 10 month)) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
201 (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
|
202 (let ((date (calendar-gregorian-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
203 (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
|
204 (if (calendar-date-is-visible-p date) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
205 (list (list date string)))))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
206 |
86488
41a473ff321a
(add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents:
84590
diff
changeset
|
207 ;; 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
|
208 (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
|
209 (date string specifier &optional marker globcolor literal)) |
41a473ff321a
(add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents:
84590
diff
changeset
|
210 |
84581
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
211 (defun diary-bahai-list-entries () |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
212 "Add any Bahá'í date entries from the diary file to `diary-entries-list'. |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
213 Bahá'í date diary entries must be prefaced by an |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
214 `bahai-diary-entry-symbol' (normally a `B'). The same diary date |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
215 forms govern the style of the Bahá'í calendar entries, except that the |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
216 Bahá'í month names must be given numerically. The Bahá'í months are |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
217 numbered from 1 to 19 with Bahá being 1 and 19 being `Alá. If a |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
218 Bahá'í date diary entry begins with a `diary-nonmarking-symbol', the |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
219 entry will appear in the diary listing, but will not be marked in the |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
220 calendar. This function is provided for use with the |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
221 `nongregorian-diary-listing-hook'." |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
222 (if (< 0 number) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
223 (let ((buffer-read-only nil) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
224 (diary-modified (buffer-modified-p)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
225 (gdate original-date) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
226 (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
|
227 (dotimes (idummy number) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
228 (let* ((d diary-date-forms) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
229 (bdate (calendar-bahai-from-absolute |
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)) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
233 (year (extract-calendar-year bdate))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
234 (while d |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
235 (let* |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
236 ((date-form (if (equal (car (car d)) 'backup) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
237 (cdr (car d)) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
238 (car d))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
239 (backup (equal (car (car d)) 'backup)) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
240 (dayname |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
241 (concat |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
242 (calendar-day-name gdate) "\\|" |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
243 (substring (calendar-day-name gdate) 0 3) ".?")) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
244 (calendar-month-name-array |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
245 calendar-bahai-month-name-array) |
82082
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
246 (monthname |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
247 (concat |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
248 "\\*\\|" |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
249 (calendar-month-name month))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
250 (month (concat "\\*\\|0*" (int-to-string month))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
251 (day (concat "\\*\\|0*" (int-to-string day))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
252 (year |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
253 (concat |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
254 "\\*\\|0*" (int-to-string year) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
255 (if abbreviated-calendar-year |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
256 (concat "\\|" (int-to-string (% year 100))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
257 ""))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
258 (regexp |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
259 (concat |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
260 "\\(\\`\\|\^M\\|\n\\)" mark "?" |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
261 (regexp-quote bahai-diary-entry-symbol) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
262 "\\(" |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
263 (mapconcat 'eval date-form "\\)\\(") |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
264 "\\)")) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
265 (case-fold-search t)) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
266 (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
|
267 (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
|
268 (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
|
269 (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
|
270 (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
|
271 (not (looking-at " \\|\^I"))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
272 ;; Diary entry that consists only of date. |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
273 (backward-char 1) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
274 ;; Found a nonempty diary entry--make it visible and |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
275 ;; add it to the list. |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
276 (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
|
277 (date-start)) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
278 (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
|
279 (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
|
280 (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
|
281 (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
|
282 (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
|
283 (backward-char 1) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
284 (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
|
285 (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
|
286 gdate |
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 entry-start (point)) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
288 (buffer-substring-no-properties |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
289 (1+ date-start) (1- entry-start))))))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
290 (setq d (cdr d)))) |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
291 (setq gdate |
62a75b41aa25
(list-bahai-diary-entries): Use dotimes rather than calendar-for-loop.
Glenn Morris <rgm@gnu.org>
parents:
78143
diff
changeset
|
292 (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
|
293 (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
|
294 (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
|
295 (goto-char (point-min)))) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
296 |
86488
41a473ff321a
(add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents:
84590
diff
changeset
|
297 (declare-function diary-name-pattern "diary-lib" |
41a473ff321a
(add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents:
84590
diff
changeset
|
298 (string-array &optional abbrev-array paren)) |
41a473ff321a
(add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents:
84590
diff
changeset
|
299 |
41a473ff321a
(add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents:
84590
diff
changeset
|
300 (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
|
301 (dayname &optional color)) |
41a473ff321a
(add-to-diary-list, diary-name-pattern)
Glenn Morris <rgm@gnu.org>
parents:
84590
diff
changeset
|
302 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
303 (defun diary-bahai-mark-entries () |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
304 "Mark days in the calendar window that have Bahá'í date diary entries. |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
305 Each entry in diary-file (or included files) visible in the calendar |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
306 window is marked. Bahá'í date entries are prefaced by a |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
307 bahai-diary-entry-symbol \(normally a B`I'). The same |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
308 diary-date-forms govern the style of the Bahá'í calendar entries, |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
309 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
|
310 Bahá'í months are numbered from 1 to 12 with Bahá being 1 and 12 being |
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
311 `Alá. Bahá'í date diary entries that begin with a |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
312 diary-nonmarking-symbol will not be marked in the calendar. This |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
313 function is provided for use as part of the |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
314 nongregorian-diary-marking-hook." |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
315 (let ((d diary-date-forms)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
316 (while d |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
317 (let* |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
318 ((date-form (if (equal (car (car d)) 'backup) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
319 (cdr (car d)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
320 (car d)));; ignore 'backup directive |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
321 (dayname (diary-name-pattern calendar-day-name-array)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
322 (monthname |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
323 (concat |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
324 (diary-name-pattern calendar-bahai-month-name-array t) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
325 "\\|\\*")) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
326 (month "[0-9]+\\|\\*") |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
327 (day "[0-9]+\\|\\*") |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
328 (year "[0-9]+\\|\\*") |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
329 (l (length date-form)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
330 (d-name-pos (- l (length (memq 'dayname date-form)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
331 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
332 (m-name-pos (- l (length (memq 'monthname date-form)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
333 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
334 (d-pos (- l (length (memq 'day date-form)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
335 (d-pos (if (/= l d-pos) (+ 2 d-pos))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
336 (m-pos (- l (length (memq 'month date-form)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
337 (m-pos (if (/= l m-pos) (+ 2 m-pos))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
338 (y-pos (- l (length (memq 'year date-form)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
339 (y-pos (if (/= l y-pos) (+ 2 y-pos))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
340 (regexp |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
341 (concat |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
342 "\\(\\`\\|\^M\\|\n\\)" |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
343 (regexp-quote bahai-diary-entry-symbol) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
344 "\\(" |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
345 (mapconcat 'eval date-form "\\)\\(") |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
346 "\\)")) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
347 (case-fold-search t)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
348 (goto-char (point-min)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
349 (while (re-search-forward regexp nil t) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
350 (let* ((dd-name |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
351 (if d-name-pos |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
352 (buffer-substring |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
353 (match-beginning d-name-pos) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
354 (match-end d-name-pos)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
355 (mm-name |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
356 (if m-name-pos |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
357 (buffer-substring |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
358 (match-beginning m-name-pos) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
359 (match-end m-name-pos)))) |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
62123
diff
changeset
|
360 (mm (string-to-number |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
361 (if m-pos |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
362 (buffer-substring |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
363 (match-beginning m-pos) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
364 (match-end m-pos)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
365 ""))) |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
62123
diff
changeset
|
366 (dd (string-to-number |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
367 (if d-pos |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
368 (buffer-substring |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
369 (match-beginning d-pos) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
370 (match-end d-pos)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
371 ""))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
372 (y-str (if y-pos |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
373 (buffer-substring |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
374 (match-beginning y-pos) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
375 (match-end y-pos)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
376 (yy (if (not y-str) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
377 0 |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
378 (if (and (= (length y-str) 2) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
379 abbreviated-calendar-year) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
380 (let* ((current-y |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
381 (extract-calendar-year |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
382 (calendar-bahai-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
383 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
384 (calendar-current-date))))) |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
62123
diff
changeset
|
385 (y (+ (string-to-number y-str) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
386 (* 100 (/ current-y 100))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
387 (if (> (- y current-y) 50) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
388 (- y 100) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
389 (if (> (- current-y y) 50) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
390 (+ y 100) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
391 y))) |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
62123
diff
changeset
|
392 (string-to-number y-str))))) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
393 (if dd-name |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
394 (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
|
395 (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
|
396 (calendar-make-alist |
8c992d4395d2
(mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents:
55461
diff
changeset
|
397 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
|
398 0 |
8c992d4395d2
(mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents:
55461
diff
changeset
|
399 '(lambda (x) (substring x 0 3))) |
8c992d4395d2
(mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents:
55461
diff
changeset
|
400 t))) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
401 (if mm-name |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
402 (if (string-equal mm-name "*") |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
403 (setq mm 0) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
404 (setq mm |
62123
8c992d4395d2
(mark-bahai-diary-entries): Replace `assoc-ignore-case' by `assoc-string'.
Juanma Barranquero <lekktu@gmail.com>
parents:
55461
diff
changeset
|
405 (cdr (assoc-string |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
406 mm-name |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
407 (calendar-make-alist |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
408 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
|
409 t))))) |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
410 (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
|
411 (setq d (cdr d))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
412 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
413 (defun calendar-bahai-mark-date-pattern (month day year) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
414 "Mark dates in calendar window that conform to Bahá'í date MONTH/DAY/YEAR. |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
415 A value of 0 in any position is a wildcard." |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
416 (save-excursion |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
417 (set-buffer calendar-buffer) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
418 (if (and (/= 0 month) (/= 0 day)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
419 (if (/= 0 year) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
420 ;; Fully specified Bahá'í date. |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
421 (let ((date (calendar-gregorian-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
422 (calendar-absolute-from-bahai |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
423 (list month day year))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
424 (if (calendar-date-is-visible-p date) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
425 (mark-visible-calendar-date date))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
426 ;; Month and day in any year--this taken from the holiday stuff. |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
427 (let* ((bahai-date (calendar-bahai-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
428 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
429 (list displayed-month 15 displayed-year)))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
430 (m (extract-calendar-month bahai-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
431 (y (extract-calendar-year bahai-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
432 (date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
433 (if (< m 1) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
434 nil;; Bahá'í calendar doesn't apply. |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
435 (increment-calendar-month m y (- 10 month)) |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
436 (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
|
437 (let ((date (calendar-gregorian-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
438 (calendar-absolute-from-bahai |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
439 (list month day y))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
440 (if (calendar-date-is-visible-p date) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
441 (mark-visible-calendar-date date))))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
442 ;; Not one of the simple cases--check all visible dates for match. |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
443 ;; Actually, the following code takes care of ALL of the cases, but |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
444 ;; it's much too slow to be used for the simple (common) cases. |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
445 (let ((m displayed-month) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
446 (y displayed-year) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
447 (first-date) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
448 (last-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
449 (increment-calendar-month m y -1) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
450 (setq first-date |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
451 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
452 (list m 1 y))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
453 (increment-calendar-month m y 2) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
454 (setq last-date |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
455 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
456 (list m (calendar-last-day-of-month m y) y))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
457 (calendar-for-loop date from first-date to last-date do |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
458 (let* ((b-date (calendar-bahai-from-absolute date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
459 (i-month (extract-calendar-month b-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
460 (i-day (extract-calendar-day b-date)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
461 (i-year (extract-calendar-year b-date))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
462 (and (or (zerop month) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
463 (= month i-month)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
464 (or (zerop day) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
465 (= day i-day)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
466 (or (zerop year) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
467 (= year i-year)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
468 (mark-visible-calendar-date |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
469 (calendar-gregorian-from-absolute date))))))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
470 |
84581
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
471 (defun diary-bahai-insert-entry (arg) |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
472 "Insert a diary entry. |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
473 For the Bahá'í date corresponding to the date indicated by point. |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
474 Prefix arg will make the entry nonmarking." |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
475 (interactive "P") |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
476 (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
|
477 (make-diary-entry |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
478 (concat |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
479 bahai-diary-entry-symbol |
65141
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
480 (calendar-date-string |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
481 (calendar-bahai-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
482 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
483 (calendar-cursor-to-date t))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
484 nil t)) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
485 arg))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
486 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
487 (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
|
488 "Insert a monthly diary entry. |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
489 For the day of the Bahá'í month corresponding to the date indicated by point. |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
490 Prefix arg will make the entry nonmarking." |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
491 (interactive "P") |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
492 (let* ((calendar-date-display-form |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
493 (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
|
494 (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
|
495 (make-diary-entry |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
496 (concat |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
497 bahai-diary-entry-symbol |
65141
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
498 (calendar-date-string |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
499 (calendar-bahai-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
500 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
501 (calendar-cursor-to-date t))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
502 arg))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
503 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
504 (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
|
505 "Insert an annual diary entry. |
82787
03ac28e9a566
2007-08-23 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
82177
diff
changeset
|
506 For the day of the Bahá'í year corresponding to the date indicated by point. |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
507 Prefix arg will make the entry nonmarking." |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
508 (interactive "P") |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
509 (let* ((calendar-date-display-form |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
510 (if european-calendar-style |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
511 '(day " " monthname) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
512 '(monthname " " day))) |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
513 (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
|
514 (make-diary-entry |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
515 (concat |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
516 bahai-diary-entry-symbol |
65141
fad69800a5b0
(date, displayed-month, displayed-year, number, original-date):
Juanma Barranquero <lekktu@gmail.com>
parents:
64085
diff
changeset
|
517 (calendar-date-string |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
518 (calendar-bahai-from-absolute |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
519 (calendar-absolute-from-gregorian |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
520 (calendar-cursor-to-date t))))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
521 arg))) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
522 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
523 ;; Backward compatibility. |
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
524 (define-obsolete-function-alias |
84581
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
525 '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
|
526 (define-obsolete-function-alias |
84581
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
527 '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
|
528 (define-obsolete-function-alias |
84581
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
529 '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
|
530 (define-obsolete-function-alias |
84590
1cfbc4c30509
Fix typos in aliases in previous change.
Glenn Morris <rgm@gnu.org>
parents:
84581
diff
changeset
|
531 '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
|
532 (define-obsolete-function-alias |
84590
1cfbc4c30509
Fix typos in aliases in previous change.
Glenn Morris <rgm@gnu.org>
parents:
84581
diff
changeset
|
533 '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
|
534 (define-obsolete-function-alias |
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
535 '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
|
536 (define-obsolete-function-alias |
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
537 '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
|
538 (define-obsolete-function-alias |
96df62307dfc
(mark-bahai-diary-entries): Fix up typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82833
diff
changeset
|
539 '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
|
540 |
55431
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
541 (provide 'cal-bahai) |
b278cb498cc8
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
542 |
82177
f673ee49d36e
(calendar-bahai-month-name-array, calendar-bahai-epoch)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
543 ;; 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
|
544 ;;; cal-bahai.el ends here |