From: Jimmy Aguilar Mena Date: Fri, 20 Nov 2020 15:00:33 +0000 (+0100) Subject: Add try to close completions more often like zsh. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=25f23b1910ca9d05712d62a85d993efe52b5eac5;p=emacs.git 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. --- diff --git a/lisp/completions-highlight.el b/lisp/completions-highlight.el index 435631414b6..ca5cf8f0372 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