]> git.eshelyaron.com Git - emacs.git/commitdiff
New command minibuffer-choose-completion
authorJimmy Aguilar Mena <spacibba@aol.com>
Thu, 19 Nov 2020 06:22:05 +0000 (07:22 +0100)
committerJimmy Aguilar Mena <spacibba@aol.com>
Fri, 20 Nov 2020 18:03:23 +0000 (19:03 +0100)
This command uses *Completions* candidates only when highlighted.

lisp/completions-highlight.el

index 9ce83e6518968a4e564683284cd51cd5d1418bdd..e19a4d8aeb58fe787b0c12c0a82331249291b608 100644 (file)
@@ -153,6 +153,15 @@ is executed in another window, but cursor stays in minibuffer."
   (interactive "p")
   (with-minibuffer-scroll-window (previous-line n)))
 
+;; Maybe this may be done with an advise?
+(defun minibuffer-choose-completion ()
+  "Execute `choose-completion' in *Completions*."
+  (interactive)
+  (if (and (completions-highlight-completions-visible-p)
+           (overlay-buffer completions-highlight-overlay))
+      (with-minibuffer-scroll-window (choose-completion))
+    (minibuffer-complete-and-exit)))
+
 ;; General commands
 (defun completions-highlight--set-suffix (choice)
   "Set CHOICE suffix to current completion.
@@ -192,6 +201,8 @@ suffix."
     (define-key map [left] #'minibuffer-previous-completion)
     (define-key map [down] #'minibuffer-next-line-completion)
     (define-key map [up] #'minibuffer-previous-line-completion)
+    (define-key map [remap minibuffer-complete-and-exit]
+      #'minibuffer-choose-completion)
     map)
   "Keymap used in minibuffer while *Completions* is active.")