]> code.delx.au - gnu-emacs/blobdiff - lisp/calendar/holidays.el
Update copyright year to 2015
[gnu-emacs] / lisp / calendar / holidays.el
index b75ae52cf1df3c0d114b31d2f9c1def3a929809a..8085c1cf119131337c054358d7aa5931016c0e0a 100644 (file)
@@ -1,11 +1,12 @@
 ;;; holidays.el --- holiday functions for the calendar package
 
-;; Copyright (C) 1989, 1990, 1992, 1993, 1994, 1997, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
+;; Copyright (C) 1989-1990, 1992-1994, 1997, 2001-2015 Free Software
+;; Foundation, Inc.
 
 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
 ;; Maintainer: Glenn Morris <rgm@gnu.org>
 ;; Keywords: holidays, calendar
+;; Package: calendar
 
 ;; This file is part of GNU Emacs.
 
@@ -67,9 +68,6 @@ See the documentation for `calendar-holidays' for details."
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-general-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'general-holidays
-  'holiday-general-holidays "23.1")
 
 ;;;###autoload
 (defcustom holiday-oriental-holidays
@@ -92,9 +90,6 @@ See the documentation for `calendar-holidays' for details."
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-oriental-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'oriental-holidays
-  'holiday-oriental-holidays "23.1")
 
 ;;;###autoload
 (defcustom holiday-local-holidays nil
@@ -104,8 +99,6 @@ See the documentation for `calendar-holidays' for details."
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-local-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'local-holidays 'holiday-local-holidays "23.1")
 
 ;;;###autoload
 (defcustom holiday-other-holidays nil
@@ -115,107 +108,6 @@ See the documentation for `calendar-holidays' for details."
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-other-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'other-holidays 'holiday-other-holidays "23.1")
-
-;;;###autoload
-(defvar hebrew-holidays-1
-  (mapcar 'purecopy
-  '((holiday-hebrew-rosh-hashanah)
-    (if calendar-hebrew-all-holidays-flag
-        (holiday-julian
-         11
-         (let ((m displayed-month)
-               (y displayed-year)
-               year)
-           (calendar-increment-month m y -1)
-           (setq year (calendar-extract-year
-                       (calendar-julian-from-absolute
-                        (calendar-absolute-from-gregorian (list m 1 y)))))
-           (if (zerop (% (1+ year) 4))
-               22
-             21)) "\"Tal Umatar\" (evening)"))))
-  "Component of the old default value of `holiday-hebrew-holidays'.")
-;;;###autoload
-(put 'hebrew-holidays-1 'risky-local-variable t)
-(make-obsolete-variable 'hebrew-holidays-1 'hebrew-holidays "23.1")
-
-;;;###autoload
-(defvar hebrew-holidays-2
-  (mapcar 'purecopy
-  '((holiday-hebrew-hanukkah) ; respects calendar-hebrew-all-holidays-flag
-    (if calendar-hebrew-all-holidays-flag
-      (holiday-hebrew
-       10
-       (let ((h-year (calendar-extract-year
-                      (calendar-hebrew-from-absolute
-                       (calendar-absolute-from-gregorian
-                        (list displayed-month 28 displayed-year))))))
-         (if (= 6 (% (calendar-hebrew-to-absolute (list 10 10 h-year))
-                     7))
-             11 10))
-       "Tzom Teveth"))
-    (if calendar-hebrew-all-holidays-flag
-        (holiday-hebrew 11 15 "Tu B'Shevat"))))
-  "Component of the old default value of `holiday-hebrew-holidays'.")
-;;;###autoload
-(put 'hebrew-holidays-2 'risky-local-variable t)
-(make-obsolete-variable 'hebrew-holidays-2 'hebrew-holidays "23.1")
-
-;;;###autoload
-(defvar hebrew-holidays-3
-  (mapcar 'purecopy
-  '((if calendar-hebrew-all-holidays-flag
-        (holiday-hebrew
-         11
-         (let* ((m displayed-month)
-                (y displayed-year)
-                (h-year (progn
-                          (calendar-increment-month m y 1)
-                          (calendar-extract-year
-                           (calendar-hebrew-from-absolute
-                            (calendar-absolute-from-gregorian
-                             (list m (calendar-last-day-of-month m y) y))))))
-                (s-s
-                 (calendar-hebrew-from-absolute
-                  (if (= 6
-                         (% (calendar-hebrew-to-absolute
-                             (list 7 1 h-year))
-                            7))
-                      (calendar-dayname-on-or-before
-                       6 (calendar-hebrew-to-absolute
-                          (list 11 17 h-year)))
-                    (calendar-dayname-on-or-before
-                     6 (calendar-hebrew-to-absolute
-                        (list 11 16 h-year))))))
-                (day (calendar-extract-day s-s)))
-           day)
-         "Shabbat Shirah"))))
-  "Component of the old default value of `holiday-hebrew-holidays'.")
-;;;###autoload
-(put 'hebrew-holidays-3 'risky-local-variable t)
-(make-obsolete-variable 'hebrew-holidays-3 'hebrew-holidays "23.1")
-
-;;;###autoload
-(defvar hebrew-holidays-4
-  (mapcar 'purecopy
-  '((holiday-hebrew-passover)
-    (and calendar-hebrew-all-holidays-flag
-         (let* ((m displayed-month)
-                (y displayed-year)
-                (year (progn
-                        (calendar-increment-month m y -1)
-                        (calendar-extract-year
-                         (calendar-julian-from-absolute
-                          (calendar-absolute-from-gregorian (list m 1 y)))))))
-           (= 21 (% year 28)))
-         (holiday-julian 3 26 "Kiddush HaHamah"))
-    (if calendar-hebrew-all-holidays-flag
-        (holiday-hebrew-tisha-b-av))))
-    "Component of the old default value of `holiday-hebrew-holidays'.")
-;;;###autoload
-(put 'hebrew-holidays-4 'risky-local-variable t)
-(make-obsolete-variable 'hebrew-holidays-4 'hebrew-holidays "23.1")
 
 ;;;###autoload
 (defcustom holiday-hebrew-holidays
@@ -234,9 +126,6 @@ See the documentation for `calendar-holidays' for details."
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-hebrew-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'hebrew-holidays
-  'holiday-hebrew-holidays "23.1")
 
 ;;;###autoload
 (defcustom holiday-christian-holidays
@@ -246,7 +135,7 @@ See the documentation for `calendar-holidays' for details."
     (if calendar-christian-all-holidays-flag
         (append
          (holiday-fixed 1 6 "Epiphany")
-         (holiday-julian 12 25 "Eastern Orthodox Christmas")
+         (holiday-julian 12 25 "Christmas (Julian calendar)")
          (holiday-greek-orthodox-easter)
          (holiday-fixed 8 15 "Assumption")
          (holiday-advent 0 "Advent")))))
@@ -256,9 +145,6 @@ See the documentation for `calendar-holidays' for details."
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-christian-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'christian-holidays
-  'holiday-christian-holidays "23.1")
 
 ;;;###autoload
 (defcustom holiday-islamic-holidays
@@ -280,32 +166,27 @@ See the documentation for `calendar-holidays' for details."
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-islamic-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'islamic-holidays
-  'holiday-islamic-holidays "23.1")
 
 ;;;###autoload
 (defcustom holiday-bahai-holidays
   (mapcar 'purecopy
   '((holiday-bahai-new-year)
     (holiday-bahai-ridvan)      ; respects calendar-bahai-all-holidays-flag
-    (holiday-fixed  5 23 "Declaration of the Bab")
-    (holiday-fixed  5 29 "Ascension of Baha'u'llah")
-    (holiday-fixed  7  9 "Martyrdom of the Bab")
-    (holiday-fixed 10 20 "Birth of the Bab")
-    (holiday-fixed 11 12 "Birth of Baha'u'llah")
+    (holiday-fixed  5 23 "Declaration of the Báb")
+    (holiday-fixed  5 29 "Ascension of Bahá'u'lláh")
+    (holiday-fixed  7  9 "Martyrdom of the Báb")
+    (holiday-fixed 10 20 "Birth of the Báb")
+    (holiday-fixed 11 12 "Birth of Bahá'u'lláh")
     (if calendar-bahai-all-holidays-flag
         (append
          (holiday-fixed 11 26 "Day of the Covenant")
-         (holiday-fixed 11 28 "Ascension of `Abdu'l-Baha")))))
-  "Baha'i holidays.
+         (holiday-fixed 11 28 "Ascension of `Abdu'l-Bahá")))))
+  "Bahá'í holidays.
 See the documentation for `calendar-holidays' for details."
   :type 'sexp
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-bahai-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'bahai-holidays 'holiday-bahai-holidays "23.1")
 
 ;;;###autoload
 (defcustom holiday-solar-holidays
@@ -327,8 +208,6 @@ See the documentation for `calendar-holidays' for details."
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-solar-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'solar-holidays 'holiday-solar-holidays "23.1")
 
 ;; This one should not be autoloaded, else .emacs changes of
 ;; holiday-general-holidays etc have no effect.
@@ -342,12 +221,12 @@ See the documentation for `calendar-holidays' for details."
   "List of notable days for the command \\[holidays].
 
 Additional holidays are easy to add to the list, just put them in the
-list `holiday-other-holidays' in your .emacs file.  Similarly, by setting
+list `holiday-other-holidays' in your init file.  Similarly, by setting
 any of `holiday-general-holidays', `holiday-local-holidays',
 `holiday-christian-holidays', `holiday-hebrew-holidays',
 `holiday-islamic-holidays', `holiday-bahai-holidays',
 `holiday-oriental-holidays', or `holiday-solar-holidays' to nil in your
-.emacs file, you can eliminate unwanted categories of holidays.
+init file, you can eliminate unwanted categories of holidays.
 
 The aforementioned variables control the holiday choices offered
 by the function `holiday-list' when it is called interactively.
@@ -375,7 +254,7 @@ Several basic functions are provided for this purpose:
                                K>0, and MONTH's last day otherwise.
     (holiday-hebrew MONTH DAY STRING)  a fixed date on the Hebrew calendar
     (holiday-islamic MONTH DAY STRING) a fixed date on the Islamic calendar
-    (holiday-bahai MONTH DAY STRING)   a fixed date on the Baha'i calendar
+    (holiday-bahai MONTH DAY STRING)   a fixed date on the Bahá'í calendar
     (holiday-julian MONTH DAY STRING)  a fixed date on the Julian calendar
     (holiday-sexp SEXP STRING) SEXP is a Gregorian-date-valued expression
                                in the variable `year'; if it evaluates to
@@ -403,11 +282,11 @@ To add the Islamic feast celebrating Mohammed's birthday, use
      (holiday-islamic 3 12 \"Mohammed's Birthday\")
 
 since the Islamic months are numbered from 1 starting with Muharram.
-To add an entry for the Baha'i festival of Ridvan, use
+To add an entry for the Bahá'í festival of Ridvan, use
 
      (holiday-bahai 2 13 \"Festival of Ridvan\")
 
-since the Baha'i months are numbered from 1 starting with Baha.
+since the Bahá'í months are numbered from 1 starting with Bahá.
 To add Thomas Jefferson's birthday, April 2, 1743 (Julian), use
 
      (holiday-julian 4 2 \"Jefferson's Birthday\")
@@ -457,17 +336,20 @@ with descriptive strings such as
 (defun calendar-holiday-list ()
   "Form the list of holidays that occur on dates in the calendar window.
 The holidays are those in the list `calendar-holidays'."
-  (let (res h)
+  (let (res h err)
     (sort
      (dolist (p calendar-holidays res)
        (if (setq h (if calendar-debug-sexp
-                       (let ((stack-trace-on-error t))
+                       (let ((debug-on-error t))
                          (eval p))
-                     (condition-case nil
+                     (condition-case err
                          (eval p)
-                       (error (beep)
-                              (message "Bad holiday list item: %s" p)
-                              (sleep-for 2)))))
+                       (error
+                        (display-warning
+                         :error
+                         (format "Bad holiday list item: %s\nError: %s\n"
+                                 p err))
+                        nil))))
            (setq res (append h res))))
      'calendar-date-compare)))
 
@@ -512,14 +394,11 @@ use instead of point."
         (message "Looking up holidays...done"))
       holiday-list)))
 
-(define-obsolete-function-alias
-  'list-calendar-holidays 'calendar-list-holidays "23.1")
-
 ;;;###autoload
 (defun holidays (&optional arg)
   "Display the holidays for last month, this month, and next month.
 If called with an optional prefix argument ARG, prompts for month and year.
-This function is suitable for execution in a .emacs file."
+This function is suitable for execution in a init file."
   (interactive "P")
   (save-excursion
     (let* ((completion-ignore-case t)
@@ -581,7 +460,7 @@ The optional LABEL is used to label the buffer created."
             (if holiday-islamic-holidays
                 (cons "Islamic" holiday-islamic-holidays))
             (if holiday-bahai-holidays
-                (cons "Baha'i" holiday-bahai-holidays))
+                (cons "Bahá'í" holiday-bahai-holidays))
             (if holiday-oriental-holidays
                 (cons "Oriental" holiday-oriental-holidays))
             (if holiday-solar-holidays
@@ -631,8 +510,9 @@ The optional LABEL is used to label the buffer created."
 ;;;###diary-autoload
 (defun calendar-check-holidays (date)
   "Check the list of holidays for any that occur on DATE.
-The value returned is a list of strings of relevant holiday descriptions.
-The holidays are those in the list `calendar-holidays'."
+DATE is a list (month day year).  This function considers the
+holidays from the list `calendar-holidays', and returns a list of
+strings describing those holidays that apply on DATE, or nil if none do."
   (let ((displayed-month (calendar-extract-month date))
         (displayed-year (calendar-extract-year date))
         holiday-list)
@@ -640,8 +520,32 @@ The holidays are those in the list `calendar-holidays'."
       (if (calendar-date-equal date (car h))
           (setq holiday-list (append holiday-list (cdr h)))))))
 
-(define-obsolete-function-alias
-  'check-calendar-holidays 'calendar-check-holidays "23.1")
+
+;; Formerly cal-tex-list-holidays.
+(defun holiday-in-range (d1 d2)
+  "Generate a list of all holidays in range from absolute date D1 to D2."
+  (let* ((start (calendar-gregorian-from-absolute d1))
+         (displayed-month (calendar-extract-month start))
+         (displayed-year (calendar-extract-year start))
+         (end (calendar-gregorian-from-absolute d2))
+         (end-month (calendar-extract-month end))
+         (end-year (calendar-extract-year end))
+         (number-of-intervals
+          (1+ (/ (calendar-interval displayed-month displayed-year
+                                    end-month end-year)
+                 3)))
+         holidays in-range a)
+    (calendar-increment-month displayed-month displayed-year 1)
+    (dotimes (_idummy number-of-intervals)
+      (setq holidays (append holidays (calendar-holiday-list)))
+      (calendar-increment-month displayed-month displayed-year 3))
+    (dolist (hol holidays)
+      (and (car hol)
+           (setq a (calendar-absolute-from-gregorian (car hol)))
+           (and (<= d1 a) (<= a d2))
+           (setq in-range (append (list hol) in-range))))
+    in-range))
+
 
 (declare-function x-popup-menu "menu.c" (position menu))
 
@@ -692,9 +596,6 @@ use instead of point."
       (calendar-mark-visible-date (car holiday) calendar-holiday-marker))
     (message "Marking holidays...done")))
 
-(define-obsolete-function-alias
-  'mark-calendar-holidays 'calendar-mark-holidays "23.1")
-
 ;; Below are the functions that calculate the dates of holidays; these
 ;; are eval'ed in the function calendar-holiday-list.  If you
 ;; write other such functions, be sure to imitate the style used below.
@@ -721,7 +622,7 @@ STRING)).  Returns nil if it is not visible in the current calendar window."
   (let ((m displayed-month)
         (y displayed-year))
     (calendar-increment-month m y (- 11 month))
-    (if (> m 9)                         ; is november visible?
+    (if (> m 9)                         ; Is November visible?
         (list (list (list month day y) string)))))
 
 (defun holiday-float (month dayname n string &optional day)
@@ -781,9 +682,6 @@ HLIST is a list of elements of the form (DATE) TEXT."
                       (and (car p) (calendar-date-is-visible-p (car p)) p))
                     hlist)))
 
-(define-obsolete-function-alias
-  'filter-visible-calendar-holidays 'holiday-filter-visible-calendar "23.1")
-
 (defun holiday-sexp (sexp string)
   "Sexp holiday for dates in the calendar window.
 SEXP is an expression in variable `year' that is evaluated to
@@ -918,5 +816,8 @@ is non-nil)."
 
 (provide 'holidays)
 
-;; arch-tag: 48eb3117-75a7-4dbe-8fd9-873c3cbb0d37
+;; Local Variables:
+;; coding: utf-8
+;; End:
+
 ;;; holidays.el ends here