(when (window-live-p (get-buffer-window))
(set-window-point (get-buffer-window) (point))))))
+(defun calendar-event-buffer (event)
+ "Return the Calendar buffer where EVENT happened.
+If EVENT's start falls within a window, use that window's buffer.
+Otherwise, use the selected window of EVENT's frame."
+ (let ((window-or-frame (posn-window (event-start event))))
+ (if (windowp window-or-frame)
+ (window-buffer window-or-frame)
+ (window-buffer (frame-selected-window window-or-frame)))))
+
(defvar calendar-mode-map
(let ((map (make-keymap)))
(suppress-keymap map)
If EVENT is non-nil, it's an event indicating the buffer position to
use instead of point."
(with-current-buffer
- (if event (window-buffer (posn-window (event-start event)))
+ (if event (calendar-event-buffer event)
(current-buffer))
(save-excursion
(and event (setq event (event-start event))
+ ;; (posn-point event) can be `menu-bar' if this command is
+ ;; invoked from the menu bar.
+ (integerp (posn-point event))
(goto-char (posn-point event)))
(let* ((segment (calendar-column-to-segment))
(month (% (+ displayed-month (1- segment)) 12)))
EVENT is an event like `last-nonmenu-event'."
(interactive (let ((event (list last-nonmenu-event)))
(append (calendar-read-date 'noday) event)))
- (save-selected-window
- (and event
- (setq event (event-start event))
- (select-window (posn-window event)))
+ (with-current-buffer (or (and (not event) (current-buffer))
+ (calendar-event-buffer event))
(unless (and (= month displayed-month)
(= year displayed-year))
(let ((old-date (calendar-cursor-to-date))
(interactive (list last-nonmenu-event))
;; If called from a menu, with the calendar window not selected.
(with-current-buffer
- (if event (window-buffer (posn-window (event-start event)))
+ (if event (calendar-event-buffer event)
(current-buffer))
(message "Looking up holidays...")
(let ((holiday-list (calendar-holiday-list))
(interactive (list last-nonmenu-event))
;; If called from a menu, with the calendar window not selected.
(with-current-buffer
- (if event (window-buffer (posn-window (event-start event)))
+ (if event (calendar-event-buffer event)
(current-buffer))
(setq calendar-mark-holidays-flag t)
(message "Marking holidays...")
(interactive (list last-nonmenu-event))
;; If called from a menu, with the calendar window not selected.
(with-current-buffer
- (if event (window-buffer (posn-window (event-start event)))
+ (if event (calendar-event-buffer event)
(current-buffer))
(message "Computing phases of the moon...")
(let ((m1 displayed-month)
map doc-view-mode-map :vert-only t
:enable '(< (doc-view-current-page)
(doc-view-last-page-number))
- :help "Move to the next page.")
+ :help "Move to the last page.")
map)
"Like the default `tool-bar-map', but with additions for DocView.")