aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-04-11 02:38:51 +0000
committerRichard M. Stallman1997-04-11 02:38:51 +0000
commit056a21c458b19e289f3858d5c23bee3ce82fdf23 (patch)
treea4c20540aa4d01e72503ce6677dd255b4650a94a
parent5cb9391022bac2eb99a075f4f4fd0dd506c9b721 (diff)
downloademacs-056a21c458b19e289f3858d5c23bee3ce82fdf23.tar.gz
emacs-056a21c458b19e289f3858d5c23bee3ce82fdf23.zip
(list-holidays): New function.
-rw-r--r--lisp/calendar/holidays.el80
1 files changed, 80 insertions, 0 deletions
diff --git a/lisp/calendar/holidays.el b/lisp/calendar/holidays.el
index cb5b3a1d8cb..0bd15724670 100644
--- a/lisp/calendar/holidays.el
+++ b/lisp/calendar/holidays.el
@@ -101,6 +101,86 @@ This function is suitable for execution in a .emacs file."
101 (displayed-year (extract-calendar-year date))) 101 (displayed-year (extract-calendar-year date)))
102 (list-calendar-holidays)))) 102 (list-calendar-holidays))))
103 103
104(defun list-holidays (y1 y2 &optional l label)
105 "Display holidays for years Y1 to Y2 (inclusive).
106
107The optional list of holidays L defaults to `calendar-holidays'. See the
108documentation for that variable for a description of holiday lists.
109
110The optional LABEL is used to label the buffer created."
111 (interactive
112 (let* ((start-year (calendar-read
113 "Starting year of holidays (>0): "
114 '(lambda (x) (> x 0))
115 (int-to-string (extract-calendar-year
116 (calendar-current-date)))))
117 (end-year (calendar-read
118 (format "Ending year (inclusive) of holidays (>=%s): "
119 start-year)
120 '(lambda (x) (>= x start-year))
121 (int-to-string start-year)))
122 (completion-ignore-case t)
123 (lists
124 (list
125 (cons "All" calendar-holidays)
126 (if (fboundp 'atan)
127 (cons "Equinoxes/Solstices"
128 (list (list 'solar-equinoxes-solstices))))
129 (if general-holidays (cons "General" general-holidays))
130 (if local-holidays (cons "Local" local-holidays))
131 (if other-holidays (cons "Other" other-holidays))
132 (if christian-holidays (cons "Christian" christian-holidays))
133 (if hebrew-holidays (cons "Hebrew" hebrew-holidays))
134 (if islamic-holidays (cons "Islamic" islamic-holidays))
135 (if oriental-holidays (cons "Oriental" oriental-holidays))
136 (if solar-holidays (cons "Solar" solar-holidays))
137 (cons "Ask" nil)))
138 (choice (capitalize
139 (completing-read "List (TAB for choices): " lists nil t)))
140 (which (if (string-equal choice "Ask")
141 (eval (read-variable "Enter list name: "))
142 (cdr (assoc choice lists))))
143 (name (if (string-equal choice "Equinoxes/Solstices")
144 choice
145 (if (string-equal choice "Ask")
146 "Holidays"
147 (format "%s Holidays" choice)))))
148 (list start-year end-year which name)))
149 (message "Computing holidays...")
150 (let* ((holiday-buffer "*Holidays*")
151 (calendar-holidays (if l l calendar-holidays))
152 (title (if label label "Holidays"))
153 (holiday-list nil)
154 (s (calendar-absolute-from-gregorian (list 2 1 y1)))
155 (e (calendar-absolute-from-gregorian (list 11 1 y2)))
156 (d s)
157 (never t)
158 (displayed-month 2)
159 (displayed-year y1))
160 (while (or never (<= d e))
161 (setq holiday-list (append holiday-list (calendar-holiday-list)))
162 (setq never nil)
163 (increment-calendar-month displayed-month displayed-year 3)
164 (setq d (calendar-absolute-from-gregorian
165 (list displayed-month 1 displayed-year))))
166 (set-buffer (get-buffer-create holiday-buffer))
167 (setq buffer-read-only nil)
168 (calendar-set-mode-line
169 (if (= y1 y2)
170 (format "%s for %s" label y1)
171 (format "%s for %s-%s" label y1 y2)))
172 (erase-buffer)
173 (goto-char (point-min))
174 (insert
175 (mapconcat
176 '(lambda (x) (concat (calendar-date-string (car x)) ": " (car (cdr x))))
177 holiday-list "\n"))
178 (goto-char (point-min))
179 (set-buffer-modified-p nil)
180 (setq buffer-read-only t)
181 (display-buffer holiday-buffer)
182 (message "Computing holidays...done")))
183
104(defun check-calendar-holidays (date) 184(defun check-calendar-holidays (date)
105 "Check the list of holidays for any that occur on DATE. 185 "Check the list of holidays for any that occur on DATE.
106The value returned is a list of strings of relevant holiday descriptions. 186The value returned is a list of strings of relevant holiday descriptions.