]> git.eshelyaron.com Git - emacs.git/commitdiff
Add try to close completions more often like zsh.
authorJimmy Aguilar Mena <spacibba@aol.com>
Fri, 20 Nov 2020 15:00:33 +0000 (16:00 +0100)
committerJimmy Aguilar Mena <spacibba@aol.com>
Fri, 20 Nov 2020 18:03:23 +0000 (19:03 +0100)
*
lisp/completions-highlight.el (completions-highlight-maybe-close-completions)
: New function to perform more actions on pre-command-hook.

lisp/completions-highlight.el

index 435631414b68ca8b6e7082a4910bc1af774ce882..ca5cf8f0372366852ba746412060f4b14421fb90 100644 (file)
@@ -221,6 +221,15 @@ should be assigned to completion-in-minibuffer-scroll-window."
          ;; can scroll.
          (with-selected-window window (scroll-up)))))))
 
+(defun completions-highlight-maybe-close-completions ()
+  "Close *Completions* buffer when the command is not in the map."
+  (completions-highlight--clear-suffix)
+  (unless (lookup-key completions-highlight-minibuffer-map
+                      (this-single-command-keys))
+    (remove-hook 'pre-command-hook
+                 #'completions-highlight-maybe-close-completions t)
+    (minibuffer-hide-completions)))
+
 (defun completions-highlight-setup ()
   "Function to call when enabling the `completion-highlight-mode' mode.
 It is called when showing the *Completions* buffer."
@@ -242,7 +251,8 @@ It is called when showing the *Completions* buffer."
           (next-completion 1)
           (completions-highlight-select-near)))))
 
-  (add-hook 'pre-command-hook #'completions-highlight--clear-suffix nil t)
+  (add-hook 'pre-command-hook
+            #'completions-highlight-maybe-close-completions nil t)
 
   ;; Add completions-highlight-minibuffer-map bindings to minibuffer
   (use-local-map (make-composed-keymap