mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 12:21:25 -08:00
With visible-completions, only bind RET when completion is selected
Previously, if minibuffer-visible-completions was non-nil, we bound RET whenever the *Completions* buffer was visible. This meant that RET in completion-in-region would not enter a newline, which is a somewhat annoying behavior change from minibuffer-visible-completions=nil. Now, we only bind RET when a completion is selected. This means RET will newline in completion-in-region. So that completion help continues to suggest the correct keys, we also add minibuffer-visible-completions--always-bind. When let-bound to a non-nil value, it makes the minibuffer-visible-completions binds always active. We let-bind it around substitute-command-keys. * lisp/minibuffer.el (minibuffer-visible-completions--always-bind) (minibuffer-visible-completions--filter): Add. (minibuffer-visible-completions-bind): Use minibuffer-visible-completions--filter. (bug#68801) * lisp/simple.el (minibuffer-visible-completions--always-bind) (completion-setup-function): Let-bind minibuffer-visible-completions--always-bind so the completion help is correct.
This commit is contained in:
parent
09ab669351
commit
9dcb28d601
2 changed files with 29 additions and 14 deletions
|
|
@ -3163,18 +3163,30 @@ and `RET' accepts the input typed into the minibuffer."
|
|||
:type 'boolean
|
||||
:version "30.1")
|
||||
|
||||
(defvar minibuffer-visible-completions--always-bind nil
|
||||
"If non-nil, force the `minibuffer-visible-completions' bindings on.")
|
||||
|
||||
(defun minibuffer-visible-completions--filter (cmd)
|
||||
"Return CMD if `minibuffer-visible-completions' bindings should be active."
|
||||
(if minibuffer-visible-completions--always-bind
|
||||
cmd
|
||||
(when-let ((window (get-buffer-window "*Completions*" 0)))
|
||||
(when (and (eq (buffer-local-value 'completion-reference-buffer
|
||||
(window-buffer window))
|
||||
(window-buffer (active-minibuffer-window)))
|
||||
(if (eq cmd #'minibuffer-choose-completion-or-exit)
|
||||
(with-current-buffer (window-buffer window)
|
||||
(get-text-property (point) 'completion--string))
|
||||
t))
|
||||
cmd))))
|
||||
|
||||
(defun minibuffer-visible-completions-bind (binding)
|
||||
"Use BINDING when completions are visible.
|
||||
Return an item that is enabled only when a window
|
||||
displaying the *Completions* buffer exists."
|
||||
`(menu-item
|
||||
"" ,binding
|
||||
:filter ,(lambda (cmd)
|
||||
(when-let ((window (get-buffer-window "*Completions*" 0)))
|
||||
(when (eq (buffer-local-value 'completion-reference-buffer
|
||||
(window-buffer window))
|
||||
(window-buffer (active-minibuffer-window)))
|
||||
cmd)))))
|
||||
:filter ,#'minibuffer-visible-completions--filter))
|
||||
|
||||
(defvar-keymap minibuffer-visible-completions-map
|
||||
:doc "Local keymap for minibuffer input with visible completions."
|
||||
|
|
|
|||
|
|
@ -10298,6 +10298,8 @@ Called from `temp-buffer-show-hook'."
|
|||
:version "22.1"
|
||||
:group 'completion)
|
||||
|
||||
(defvar minibuffer-visible-completions--always-bind)
|
||||
|
||||
;; This function goes in completion-setup-hook, so that it is called
|
||||
;; after the text of the completion list buffer is written.
|
||||
(defun completion-setup-function ()
|
||||
|
|
@ -10338,15 +10340,16 @@ Called from `temp-buffer-show-hook'."
|
|||
(if minibuffer-visible-completions
|
||||
(let ((helps
|
||||
(with-current-buffer (window-buffer (active-minibuffer-window))
|
||||
(list
|
||||
(substitute-command-keys
|
||||
(if (display-mouse-p)
|
||||
"Click or type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n"
|
||||
"Type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n"))
|
||||
(substitute-command-keys
|
||||
"Type \\[minibuffer-next-completion], \\[minibuffer-previous-completion], \
|
||||
(let ((minibuffer-visible-completions--always-bind t))
|
||||
(list
|
||||
(substitute-command-keys
|
||||
(if (display-mouse-p)
|
||||
"Click or type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n"
|
||||
"Type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n"))
|
||||
(substitute-command-keys
|
||||
"Type \\[minibuffer-next-completion], \\[minibuffer-previous-completion], \
|
||||
\\[minibuffer-next-line-completion], \\[minibuffer-previous-line-completion] \
|
||||
to move point between completions.\n\n")))))
|
||||
to move point between completions.\n\n"))))))
|
||||
(dolist (help helps)
|
||||
(insert help)))
|
||||
(insert (substitute-command-keys
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue