diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 36b8d80841..e92bb0f885 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2681,7 +2766,10 @@ minibuffer-local-completion-map "?" #'minibuffer-completion-help "" #'switch-to-completions "M-v" #'switch-to-completions - "M-g M-c" #'switch-to-completions) + "M-g M-c" #'switch-to-completions + "M-" #'minibuffer-completion-previous + "M-" #'minibuffer-completion-next + "M-RET" #'minibuffer-completion-choose) (defvar-keymap minibuffer-local-must-match-map :doc "Local keymap for minibuffer input with completion, for exact match." @@ -4271,6 +4359,39 @@ minibuffer-scroll-other-window-down (with-minibuffer-selected-window (scroll-other-window-down arg))) +(defmacro with-minibuffer-scroll-window (&rest body) + "Execute the forms in BODY from the minibuffer in its scrolling window. +When used in a minibuffer window, select the window where scrolling command +should scroll, and execute the forms." + (declare (indent 0) (debug t)) + `(let ((window (or (get-buffer-window "*Completions*" 0) ; remove? + ;; Make sure we have a completions window. + (progn (minibuffer-completion-help) + (get-buffer-window "*Completions*" 0))))) + (when window + (with-selected-window window + ,@body)))) + +(defun minibuffer-completion-previous (&optional arg) + "Run `previous-completion' from the minibuffer in its scrolling window." + (interactive "P") + (with-minibuffer-scroll-window + (previous-completion (or arg 1)) + (choose-completion nil t t))) + +(defun minibuffer-completion-next (&optional arg) + "Run `next-completion' from the minibuffer in its scrolling window." + (interactive "P") + (with-minibuffer-scroll-window + (next-completion (or arg 1)) + (choose-completion nil t t))) + +(defun minibuffer-completion-choose (&optional arg) + "Run `choose-completion' from the minibuffer in its scrolling window." + (interactive "P") + (with-minibuffer-scroll-window + (choose-completion nil arg))) + (defcustom minibuffer-default-prompt-format " (default %s)" "Format string used to output \"default\" values. When prompting for input, there will often be a default value,