summaryrefslogtreecommitdiff
path: root/lisp/calendar/holidays.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2012-05-05 13:58:14 -0700
committerGlenn Morris <rgm@gnu.org>2012-05-05 13:58:14 -0700
commita43f98b3959cf9435de7ea5a5bb44e3fbd061085 (patch)
treebb8f58c45b6df94d88084b10748abd18881db404 /lisp/calendar/holidays.el
parentfef9d1494c136356309722cbb00e7ad367233797 (diff)
downloademacs-a43f98b3959cf9435de7ea5a5bb44e3fbd061085.tar.gz
emacs-a43f98b3959cf9435de7ea5a5bb44e3fbd061085.tar.bz2
emacs-a43f98b3959cf9435de7ea5a5bb44e3fbd061085.zip
Move function from cal-tex to holidays
* calendar/holidays.el (holiday-in-range): Move here from cal-tex-list-holidays. * calendar/cal-tex.el (cal-tex-list-holidays): Make it an obsolete alias for holiday-in-range. Update all callers.
Diffstat (limited to 'lisp/calendar/holidays.el')
-rw-r--r--lisp/calendar/holidays.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/lisp/calendar/holidays.el b/lisp/calendar/holidays.el
index 9edd353b889..0bb3c231840 100644
--- a/lisp/calendar/holidays.el
+++ b/lisp/calendar/holidays.el
@@ -645,6 +645,33 @@ strings describing those holidays that apply on DATE, or nil if none do."
(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))
;;;###cal-autoload