diff options
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/calendar/holidays.el | 22 |
2 files changed, 22 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8fe99b3d0a0..a163467b809 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-03-31 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * calendar/holidays.el (holiday-filter-visible-calendar): Return result | ||
| 4 | from dolist. | ||
| 5 | |||
| 1 | 2008-03-30 Juanma Barranquero <lekktu@gmail.com> | 6 | 2008-03-30 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 7 | ||
| 3 | * hi-lock.el (hi-lock-mode): Fix typos in docstring. | 8 | * hi-lock.el (hi-lock-mode): Fix typos in docstring. |
diff --git a/lisp/calendar/holidays.el b/lisp/calendar/holidays.el index 28cde37e400..7c50af09f0e 100644 --- a/lisp/calendar/holidays.el +++ b/lisp/calendar/holidays.el | |||
| @@ -275,10 +275,23 @@ The holidays are those in the list `calendar-holidays'." | |||
| 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) |
| @@ -336,12 +349,11 @@ Returns nil if it is not visible in the current calendar window." | |||
| 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") |