emacs-diffs
[Top][All Lists]
Advanced

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

master 1b687e1: Optimize lisp/icomplete.el when default completion avail


From: João Távora
Subject: master 1b687e1: Optimize lisp/icomplete.el when default completion available
Date: Sun, 27 Oct 2019 09:23:36 -0400 (EDT)

branch: master
commit 1b687e171e542165a260a9416d103a0af201e0c7
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Optimize lisp/icomplete.el when default completion available
    
    Often, when using icomplete with icomplete-show-matches-on-no-input
    and commands like C-h f, icomplete-exhibit will take a long time (like
    several seconds) to show all the completions.
    
    However, if there is a non-nil default value, like when the C-h f is
    performed exactly on a function name, the minibuffer prompt will
    reflect that immediately.  If the user immediately presses RE
    (icomplete-force-complete-and-exit) we take that to mean "use the
    default" and avoid the long wait.
    
    As an extra performance tweak, this commit also removes an unneeded
    call to icomplete-exhibit in icomplete-minibuffer-setup.
    
    * lisp/icomplete.el (icomplete-force-complete-and-exit): Short-circuit
    possibility of non-nil minibuffer-default.
    (icomplete-minibuffer-setup): No need to explicitly icomplete-exhibit
    here since icomplete-post-command-hook will call it unconditionally.
---
 lisp/icomplete.el | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 51f2611..5cd11b1 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -156,7 +156,7 @@ icompletion is occurring."
 Use the first of the matches if there are any displayed, and use
 the default otherwise."
   (interactive)
-  (if (or icomplete-show-matches-on-no-input
+  (if (or (and (not minibuffer-default) icomplete-show-matches-on-no-input)
           (> (icomplete--field-end) (icomplete--field-beg)))
       (minibuffer-force-complete-and-exit)
     (minibuffer-complete-and-exit)))
@@ -269,9 +269,7 @@ Usually run by inclusion in `minibuffer-setup-hook'."
                                         (current-local-map)))
     (add-hook 'pre-command-hook  #'icomplete-pre-command-hook  nil t)
     (add-hook 'post-command-hook #'icomplete-post-command-hook nil t)
-    (run-hooks 'icomplete-minibuffer-setup-hook)
-    (when icomplete-show-matches-on-no-input
-      (icomplete-exhibit))))
+    (run-hooks 'icomplete-minibuffer-setup-hook)))
 
 (defvar icomplete--in-region-buffer nil)
 



reply via email to

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