emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/completions-highlight-modifications 25f23b1 25/25: Add try to cl


From: Jimmy Aguilar Mena
Subject: feature/completions-highlight-modifications 25f23b1 25/25: Add try to close completions more often like zsh.
Date: Fri, 20 Nov 2020 13:28:36 -0500 (EST)

branch: feature/completions-highlight-modifications
commit 25f23b1910ca9d05712d62a85d993efe52b5eac5
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>

    Add try to close completions more often like zsh.
    
    *
    lisp/completions-highlight.el 
(completions-highlight-maybe-close-completions)
    : New function to perform more actions on pre-command-hook.
---
 lisp/completions-highlight.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/completions-highlight.el b/lisp/completions-highlight.el
index 4356314..ca5cf8f 100644
--- a/lisp/completions-highlight.el
+++ b/lisp/completions-highlight.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]