comparison lisp/calendar/holidays.el @ 93438:03d6bc06ded0

(holiday-fixed): Comment. (holiday-filter-visible-calendar): Return result from dolist.
author Glenn Morris <rgm@gnu.org>
date Mon, 31 Mar 2008 01:35:11 +0000
parents 5f88d76e42f0
children 101c1d082feb
comparison
equal deleted inserted replaced
93437:c45c0ebc9722 93438:03d6bc06ded0
273 273
274 (defun holiday-fixed (month day string) 274 (defun holiday-fixed (month day string)
275 "Holiday on MONTH, DAY (Gregorian) called STRING. 275 "Holiday on MONTH, DAY (Gregorian) called STRING.
276 If MONTH, DAY is visible, the value returned is the list (((MONTH DAY year) 276 If MONTH, DAY is visible, the value returned is the list (((MONTH DAY year)
277 STRING)). Returns nil if it is not visible in the current calendar window." 277 STRING)). Returns nil if it is not visible in the current calendar window."
278 ;; This determines whether a given month is visible in the calendar.
279 ;; cf calendar-date-is-visible-p (which also checks the year part).
280 ;; The day is irrelevant since only full months are displayed.
281 ;; Since the calendar displays three months at a time, month N
282 ;; is visible if displayed-month = N-1, N, N+1.
283 ;; In particular, November is visible if d-m = 10, 11, 12.
284 ;; This is useful, because we can do a one-sided test:
285 ;; November is visible if d-m > 9. (Similarly, February is visible if
286 ;; d-m < 4.)
287 ;; To determine if December is visible, we can shift the calendar
288 ;; back a month and ask if November is visible; to determine if
289 ;; October is visible, we can shift it forward a month and ask if
290 ;; November is visible; etc.
278 (let ((m displayed-month) 291 (let ((m displayed-month)
279 (y displayed-year)) 292 (y displayed-year))
280 (increment-calendar-month m y (- 11 month)) 293 (increment-calendar-month m y (- 11 month))
281 (if (> m 9) 294 (if (> m 9) ; is november visible?
282 (list (list (list month day y) string))))) 295 (list (list (list month day y) string)))))
283 296
284 (defun holiday-float (month dayname n string &optional day) 297 (defun holiday-float (month dayname n string &optional day)
285 "Holiday on MONTH, DAYNAME (Nth occurrence) called STRING. 298 "Holiday on MONTH, DAYNAME (Nth occurrence) called STRING.
286 If the Nth DAYNAME in MONTH is visible, the value returned is the list 299 If the Nth DAYNAME in MONTH is visible, the value returned is the list
334 (list (list (calendar-nth-named-day n dayname month y d) 347 (list (list (calendar-nth-named-day n dayname month y d)
335 string)))))) 348 string))))))
336 349
337 (defun holiday-filter-visible-calendar (l) 350 (defun holiday-filter-visible-calendar (l)
338 "Return a list of all visible holidays of those on L." 351 "Return a list of all visible holidays of those on L."
339 (let ((visible ())) 352 (let (visible)
340 (dolist (p l) 353 (dolist (p l visible)
341 (and (car p) 354 (and (car p)
342 (calendar-date-is-visible-p (car p)) 355 (calendar-date-is-visible-p (car p))
343 (push p visible))) 356 (push p visible)))))
344 visible))
345 357
346 (define-obsolete-function-alias 358 (define-obsolete-function-alias
347 'filter-visible-calendar-holidays 'holiday-filter-visible-calendar "23.1") 359 'filter-visible-calendar-holidays 'holiday-filter-visible-calendar "23.1")
348 360
349 (defun holiday-sexp (sexp string) 361 (defun holiday-sexp (sexp string)