diff options
| author | Juri Linkov | 2019-11-09 23:32:46 +0200 |
|---|---|---|
| committer | Juri Linkov | 2019-11-09 23:32:46 +0200 |
| commit | 898cdc67f19ca15f4ac2b447adf350188baef604 (patch) | |
| tree | c9e859ade9bd726b725dba8fc6add71023fccde2 | |
| parent | 06cb8350c69d96c686f17fdb2d1f9260cd16a0df (diff) | |
| download | emacs-898cdc67f19ca15f4ac2b447adf350188baef604.tar.gz emacs-898cdc67f19ca15f4ac2b447adf350188baef604.zip | |
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.
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 47 | ||||
| -rw-r--r-- | src/window.c | 4 |
3 files changed, 52 insertions, 2 deletions
| @@ -710,6 +710,9 @@ list the contents of such directories when completing file names. | |||
| 710 | 710 | ||
| 711 | ** Minibuffer | 711 | ** Minibuffer |
| 712 | 712 | ||
| 713 | *** Scrolling and recentering commands in the minibuffer are invoked | ||
| 714 | on the original window (that was selected before activating the minibuffer). | ||
| 715 | |||
| 713 | +++ | 716 | +++ |
| 714 | *** A new user option, 'minibuffer-beginning-of-buffer-movement', has | 717 | *** A new user option, 'minibuffer-beginning-of-buffer-movement', has |
| 715 | been introduced to allow controlling how the 'M-<' command works in | 718 | been introduced to allow controlling how the 'M-<' command works in |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 5b993e792f0..2b1343858f6 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -2236,6 +2236,13 @@ The completion method is determined by `completion-at-point-functions'." | |||
| 2236 | (let ((map minibuffer-local-map)) | 2236 | (let ((map minibuffer-local-map)) |
| 2237 | (define-key map "\C-g" 'abort-recursive-edit) | 2237 | (define-key map "\C-g" 'abort-recursive-edit) |
| 2238 | (define-key map "\M-<" 'minibuffer-beginning-of-buffer) | 2238 | (define-key map "\M-<" 'minibuffer-beginning-of-buffer) |
| 2239 | |||
| 2240 | (define-key map [remap recenter-top-bottom] 'minibuffer-recenter-top-bottom) | ||
| 2241 | (define-key map [remap scroll-up-command] 'minibuffer-scroll-up-command) | ||
| 2242 | (define-key map [remap scroll-down-command] 'minibuffer-scroll-down-command) | ||
| 2243 | (define-key map [remap scroll-other-window] 'minibuffer-scroll-other-window) | ||
| 2244 | (define-key map [remap scroll-other-window-down] 'minibuffer-scroll-other-window-down) | ||
| 2245 | |||
| 2239 | (define-key map "\r" 'exit-minibuffer) | 2246 | (define-key map "\r" 'exit-minibuffer) |
| 2240 | (define-key map "\n" 'exit-minibuffer)) | 2247 | (define-key map "\n" 'exit-minibuffer)) |
| 2241 | 2248 | ||
| @@ -3671,6 +3678,46 @@ Otherwise move to the start of the buffer." | |||
| 3671 | (when (and arg (not (consp arg))) | 3678 | (when (and arg (not (consp arg))) |
| 3672 | (forward-line 1))) | 3679 | (forward-line 1))) |
| 3673 | 3680 | ||
| 3681 | (defmacro with-minibuffer-selected-window (&rest body) | ||
| 3682 | "Execute the forms in BODY from the minibuffer in its original window. | ||
| 3683 | When used in a minibuffer window, select the window selected just before | ||
| 3684 | the minibuffer was activated, and execute the forms." | ||
| 3685 | (declare (indent 0) (debug t)) | ||
| 3686 | `(let ((window (minibuffer-selected-window))) | ||
| 3687 | (when window | ||
| 3688 | (with-selected-window window | ||
| 3689 | ,@body)))) | ||
| 3690 | |||
| 3691 | (defun minibuffer-recenter-top-bottom (&optional arg) | ||
| 3692 | "Run `recenter-top-bottom' from the minibuffer in its original window." | ||
| 3693 | (interactive "P") | ||
| 3694 | (with-minibuffer-selected-window | ||
| 3695 | (recenter-top-bottom arg))) | ||
| 3696 | |||
| 3697 | (defun minibuffer-scroll-up-command (&optional arg) | ||
| 3698 | "Run `scroll-up-command' from the minibuffer in its original window." | ||
| 3699 | (interactive "^P") | ||
| 3700 | (with-minibuffer-selected-window | ||
| 3701 | (scroll-up-command arg))) | ||
| 3702 | |||
| 3703 | (defun minibuffer-scroll-down-command (&optional arg) | ||
| 3704 | "Run `scroll-down-command' from the minibuffer in its original window." | ||
| 3705 | (interactive "^P") | ||
| 3706 | (with-minibuffer-selected-window | ||
| 3707 | (scroll-down-command arg))) | ||
| 3708 | |||
| 3709 | (defun minibuffer-scroll-other-window (&optional arg) | ||
| 3710 | "Run `scroll-other-window' from the minibuffer in its original window." | ||
| 3711 | (interactive "P") | ||
| 3712 | (with-minibuffer-selected-window | ||
| 3713 | (scroll-other-window arg))) | ||
| 3714 | |||
| 3715 | (defun minibuffer-scroll-other-window-down (&optional arg) | ||
| 3716 | "Run `scroll-other-window-down' from the minibuffer in its original window." | ||
| 3717 | (interactive "^P") | ||
| 3718 | (with-minibuffer-selected-window | ||
| 3719 | (scroll-other-window-down arg))) | ||
| 3720 | |||
| 3674 | (provide 'minibuffer) | 3721 | (provide 'minibuffer) |
| 3675 | 3722 | ||
| 3676 | ;;; minibuffer.el ends here | 3723 | ;;; minibuffer.el ends here |
diff --git a/src/window.c b/src/window.c index e122649f59e..1984a540add 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -6253,12 +6253,12 @@ followed by all visible frames on the current terminal. */) | |||
| 6253 | { | 6253 | { |
| 6254 | /* Nothing specified; look for a neighboring window on the same | 6254 | /* Nothing specified; look for a neighboring window on the same |
| 6255 | frame. */ | 6255 | frame. */ |
| 6256 | window = Fnext_window (selected_window, Qnil, Qnil); | 6256 | window = Fnext_window (selected_window, Qlambda, Qnil); |
| 6257 | 6257 | ||
| 6258 | if (EQ (window, selected_window)) | 6258 | if (EQ (window, selected_window)) |
| 6259 | /* That didn't get us anywhere; look for a window on another | 6259 | /* That didn't get us anywhere; look for a window on another |
| 6260 | visible frame on the current terminal. */ | 6260 | visible frame on the current terminal. */ |
| 6261 | window = Fnext_window (window, Qnil, Qvisible); | 6261 | window = Fnext_window (window, Qlambda, Qvisible); |
| 6262 | } | 6262 | } |
| 6263 | 6263 | ||
| 6264 | CHECK_LIVE_WINDOW (window); | 6264 | CHECK_LIVE_WINDOW (window); |