Simplify "other window" bob/eob motion commands

* lisp/window.el (beginning-of-buffer-other-window)
(end-of-buffer-other-window):
Simplify via with-selected-window. (bug#30207)
This commit is contained in:
Basil L. Contovounesios 2018-05-01 16:05:52 +01:00 committed by Noam Postavsky
parent d5cf1b3160
commit ae92f52c75

View file

@ -8939,19 +8939,12 @@ For more details, see the documentation for `scroll-other-window'."
Leave mark at previous position. Leave mark at previous position.
With arg N, put point N/10 of the way from the true beginning." With arg N, put point N/10 of the way from the true beginning."
(interactive "P") (interactive "P")
(let ((orig-window (selected-window)) (with-selected-window (other-window-for-scrolling)
(window (other-window-for-scrolling))) ;; Set point and mark in that window's buffer.
;; We use unwind-protect rather than save-window-excursion (with-no-warnings
;; because the latter would preserve the things we want to change. (beginning-of-buffer arg))
(unwind-protect ;; Set point accordingly.
(progn (recenter '(t))))
(select-window window)
;; Set point and mark in that window's buffer.
(with-no-warnings
(beginning-of-buffer arg))
;; Set point accordingly.
(recenter '(t)))
(select-window orig-window))))
(defun end-of-buffer-other-window (arg) (defun end-of-buffer-other-window (arg)
"Move point to the end of the buffer in the other window. "Move point to the end of the buffer in the other window.
@ -8959,15 +8952,10 @@ Leave mark at previous position.
With arg N, put point N/10 of the way from the true end." With arg N, put point N/10 of the way from the true end."
(interactive "P") (interactive "P")
;; See beginning-of-buffer-other-window for comments. ;; See beginning-of-buffer-other-window for comments.
(let ((orig-window (selected-window)) (with-selected-window (other-window-for-scrolling)
(window (other-window-for-scrolling))) (with-no-warnings
(unwind-protect (end-of-buffer arg))
(progn (recenter '(t))))
(select-window window)
(with-no-warnings
(end-of-buffer arg))
(recenter '(t)))
(select-window orig-window))))
(defvar mouse-autoselect-window-timer nil (defvar mouse-autoselect-window-timer nil
"Timer used by delayed window autoselection.") "Timer used by delayed window autoselection.")