diff options
author | Po Lu <luangruo@yahoo.com> | 2023-08-10 13:25:29 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2023-08-10 13:25:29 +0800 |
commit | 11116043ae4be761ed4f8ccf559a224b272cc534 (patch) | |
tree | 992061448ebfd8c82093137b41c469d6a34538ba /lisp/calendar/calendar.el | |
parent | 67f79fc8027150656bf39ba1910caa54490889b7 (diff) |
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.
Diffstat (limited to 'lisp/calendar/calendar.el')
-rw-r--r-- | lisp/calendar/calendar.el | 20 |
1 files changed, 15 insertions, 5 deletions
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)) |