From: Po Lu Date: Thu, 10 Aug 2023 05:25:29 +0000 (+0800) Subject: Repair several minor breakages X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=11116043ae4be761ed4f8ccf559a224b272cc534;p=emacs.git Repair several minor breakages * lisp/calendar/calendar.el (calendar-event-buffer): New function. (calendar-cursor-to-date, calendar-other-month): * lisp/calendar/holidays.el (calendar-list-holidays) (calendar-mark-holidays): * lisp/calendar/lunar.el (calendar-lunar-phases): Use that function to derive event windows, in case these commands are being called from the menu bar. * lisp/doc-view.el (doc-view-tool-bar-map): Fix typo in help text. --- diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index faa88e7f52f..02167d84b3e 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el @@ -1554,6 +1554,15 @@ first INDENT characters on the line." (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) @@ -1916,10 +1925,13 @@ parameter ERROR is non-nil, otherwise just returns nil. 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))) @@ -2002,10 +2014,8 @@ handle dates in years BC." 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)) diff --git a/lisp/calendar/holidays.el b/lisp/calendar/holidays.el index f30c5653c11..a65beca0e5b 100644 --- a/lisp/calendar/holidays.el +++ b/lisp/calendar/holidays.el @@ -359,7 +359,7 @@ use instead of point." (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)) @@ -590,7 +590,7 @@ use instead of point." (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...") diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el index 5b22043102d..a9c3597a3f9 100644 --- a/lisp/calendar/lunar.el +++ b/lisp/calendar/lunar.el @@ -226,7 +226,7 @@ use instead of point." (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) diff --git a/lisp/doc-view.el b/lisp/doc-view.el index c7edbd6e150..e25e63a97ee 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -703,7 +703,7 @@ Typically \"page-%s.png\".") 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.")