Commit 436b840d authored by Glenn Morris's avatar Glenn Morris
Browse files

(calendar-list-holidays, calendar-mark-holidays): Add event handling,

for when called from menus with the calendar buffer not current.
parent fb2bae29
...@@ -463,35 +463,41 @@ The holidays are those in the list `calendar-holidays'." ...@@ -463,35 +463,41 @@ The holidays are those in the list `calendar-holidays'."
;; FIXME name that makes sense ;; FIXME name that makes sense
;;;###cal-autoload ;;;###cal-autoload
(defun calendar-list-holidays () (defun calendar-list-holidays (&optional event)
"Create a buffer containing the holidays for the current calendar window. "Create a buffer containing the holidays for the current calendar window.
The holidays are those in the list `calendar-notable-days'. The holidays are those in the list `calendar-notable-days'.
Returns non-nil if any holidays are found." Returns non-nil if any holidays are found.
(interactive) If EVENT is non-nil, it's an event indicating the buffer position to
(message "Looking up holidays...") use instead of point."
(let ((holiday-list (calendar-holiday-list)) (interactive (list last-nonmenu-event))
(m1 displayed-month) ;; If called from a menu, with the calendar window not selected.
(y1 displayed-year) (with-current-buffer
(m2 displayed-month) (if event (window-buffer (posn-window (event-start event)))
(y2 displayed-year)) (current-buffer))
(if (not holiday-list) (message "Looking up holidays...")
(message "Looking up holidays...none found") (let ((holiday-list (calendar-holiday-list))
(calendar-in-read-only-buffer holiday-buffer (m1 displayed-month)
(calendar-increment-month m1 y1 -1) (y1 displayed-year)
(calendar-increment-month m2 y2 1) (m2 displayed-month)
(calendar-set-mode-line (y2 displayed-year))
(if (= y1 y2) (if (not holiday-list)
(format "Notable Dates from %s to %s, %d%%-" (message "Looking up holidays...none found")
(calendar-month-name m1) (calendar-month-name m2) y2) (calendar-in-read-only-buffer holiday-buffer
(format "Notable Dates from %s, %d to %s, %d%%-" (calendar-increment-month m1 y1 -1)
(calendar-month-name m1) y1 (calendar-month-name m2) y2))) (calendar-increment-month m2 y2 1)
(insert (calendar-set-mode-line
(mapconcat (if (= y1 y2)
(lambda (x) (concat (calendar-date-string (car x)) (format "Notable Dates from %s to %s, %d%%-"
": " (cadr x))) (calendar-month-name m1) (calendar-month-name m2) y2)
holiday-list "\n"))) (format "Notable Dates from %s, %d to %s, %d%%-"
(message "Looking up holidays...done")) (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
holiday-list)) (insert
(mapconcat
(lambda (x) (concat (calendar-date-string (car x))
": " (cadr x)))
holiday-list "\n")))
(message "Looking up holidays...done"))
holiday-list)))
(define-obsolete-function-alias (define-obsolete-function-alias
'list-calendar-holidays 'calendar-list-holidays "23.1") 'list-calendar-holidays 'calendar-list-holidays "23.1")
...@@ -658,14 +664,20 @@ cursor position. EVENT specifies a buffer position to use for a date." ...@@ -658,14 +664,20 @@ cursor position. EVENT specifies a buffer position to use for a date."
;; FIXME move to calendar? ;; FIXME move to calendar?
;;;###cal-autoload ;;;###cal-autoload
(defun calendar-mark-holidays () (defun calendar-mark-holidays (&optional event)
"Mark notable days in the calendar window." "Mark notable days in the calendar window.
(interactive) If EVENT is non-nil, it's an event indicating the buffer position to
(setq calendar-mark-holidays-flag t) use instead of point."
(message "Marking holidays...") (interactive (list last-nonmenu-event))
(dolist (holiday (calendar-holiday-list)) ;; If called from a menu, with the calendar window not selected.
(calendar-mark-visible-date (car holiday) calendar-holiday-marker)) (with-current-buffer
(message "Marking holidays...done")) (if event (window-buffer (posn-window (event-start event)))
(current-buffer))
(setq calendar-mark-holidays-flag t)
(message "Marking holidays...")
(dolist (holiday (calendar-holiday-list))
(calendar-mark-visible-date (car holiday) calendar-holiday-marker))
(message "Marking holidays...done")))
(define-obsolete-function-alias (define-obsolete-function-alias
'mark-calendar-holidays 'calendar-mark-holidays "23.1") 'mark-calendar-holidays 'calendar-mark-holidays "23.1")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment