Commit 898cdc67 authored by Juri Linkov's avatar Juri Linkov

Run scroll/recenter commands from minibuffer in original window (bug#38076)

* lisp/minibuffer.el (with-minibuffer-selected-window): New macro.
(minibuffer-recenter-top-bottom, minibuffer-scroll-up-command)
(minibuffer-scroll-down-command, minibuffer-scroll-other-window):
(minibuffer-scroll-other-window-down): New commands.
(minibuffer-local-map): Remap recenter/scroll symbols to their
minibuffer wrappers: recenter-top-bottom to minibuffer-recenter-top-bottom.

* src/window.c (Fother_window_for_scrolling): Use 'lambda' value for
MINIBUF arg of Fnext_window, so minibuffer-scroll-other-window and
minibuffer-scroll-other-window-down doesn't try to scroll the
minibuffer window.
parent 06cb8350
Pipeline #3989 failed with stage
in 63 minutes and 25 seconds
......@@ -710,6 +710,9 @@ list the contents of such directories when completing file names.
** Minibuffer
*** Scrolling and recentering commands in the minibuffer are invoked
on the original window (that was selected before activating the minibuffer).
+++
*** A new user option, 'minibuffer-beginning-of-buffer-movement', has
been introduced to allow controlling how the 'M-<' command works in
......
......@@ -2236,6 +2236,13 @@ The completion method is determined by `completion-at-point-functions'."
(let ((map minibuffer-local-map))
(define-key map "\C-g" 'abort-recursive-edit)
(define-key map "\M-<" 'minibuffer-beginning-of-buffer)
(define-key map [remap recenter-top-bottom] 'minibuffer-recenter-top-bottom)
(define-key map [remap scroll-up-command] 'minibuffer-scroll-up-command)
(define-key map [remap scroll-down-command] 'minibuffer-scroll-down-command)
(define-key map [remap scroll-other-window] 'minibuffer-scroll-other-window)
(define-key map [remap scroll-other-window-down] 'minibuffer-scroll-other-window-down)
(define-key map "\r" 'exit-minibuffer)
(define-key map "\n" 'exit-minibuffer))
......@@ -3671,6 +3678,46 @@ Otherwise move to the start of the buffer."
(when (and arg (not (consp arg)))
(forward-line 1)))
(defmacro with-minibuffer-selected-window (&rest body)
"Execute the forms in BODY from the minibuffer in its original window.
When used in a minibuffer window, select the window selected just before
the minibuffer was activated, and execute the forms."
(declare (indent 0) (debug t))
`(let ((window (minibuffer-selected-window)))
(when window
(with-selected-window window
,@body))))
(defun minibuffer-recenter-top-bottom (&optional arg)
"Run `recenter-top-bottom' from the minibuffer in its original window."
(interactive "P")
(with-minibuffer-selected-window
(recenter-top-bottom arg)))
(defun minibuffer-scroll-up-command (&optional arg)
"Run `scroll-up-command' from the minibuffer in its original window."
(interactive "^P")
(with-minibuffer-selected-window
(scroll-up-command arg)))
(defun minibuffer-scroll-down-command (&optional arg)
"Run `scroll-down-command' from the minibuffer in its original window."
(interactive "^P")
(with-minibuffer-selected-window
(scroll-down-command arg)))
(defun minibuffer-scroll-other-window (&optional arg)
"Run `scroll-other-window' from the minibuffer in its original window."
(interactive "P")
(with-minibuffer-selected-window
(scroll-other-window arg)))
(defun minibuffer-scroll-other-window-down (&optional arg)
"Run `scroll-other-window-down' from the minibuffer in its original window."
(interactive "^P")
(with-minibuffer-selected-window
(scroll-other-window-down arg)))
(provide 'minibuffer)
;;; minibuffer.el ends here
......@@ -6253,12 +6253,12 @@ followed by all visible frames on the current terminal. */)
{
/* Nothing specified; look for a neighboring window on the same
frame. */
window = Fnext_window (selected_window, Qnil, Qnil);
window = Fnext_window (selected_window, Qlambda, Qnil);
if (EQ (window, selected_window))
/* That didn't get us anywhere; look for a window on another
visible frame on the current terminal. */
window = Fnext_window (window, Qnil, Qvisible);
window = Fnext_window (window, Qlambda, Qvisible);
}
CHECK_LIVE_WINDOW (window);
......
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