emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 1cd501a 029/272: ivy.el (ivy-completion-in-region): Optimi


From: Oleh Krehel
Subject: [elpa] master 1cd501a 029/272: ivy.el (ivy-completion-in-region): Optimize for 1 cand
Date: Mon, 25 Apr 2016 10:13:14 +0000

branch: master
commit 1cd501ad1b76d87fa353c52620b41ece71a6db41
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-completion-in-region): Optimize for 1 cand
    
    When there's only one candidate, call the action immediately.
---
 ivy.el |   28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/ivy.el b/ivy.el
index e2c5abc..b730f78 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1401,19 +1401,21 @@ The previous string is between `ivy-completion-beg' and 
`ivy-completion-end'."
     (if (null comps)
         (message "No matches")
       (nconc comps nil)
-      (let* ((w (1+ (floor (log (length comps) 10))))
-             (ivy-count-format (and ivy-count-format
-                                    (format "%%-%dd " w))))
-        (setq ivy-completion-beg (- end (ivy-completion-common-length (car 
comps))))
-        (setq ivy-completion-end end)
-        (and
-         (ivy-read (format "(%s): " str)
-                   ;; remove 'completions-first-difference face
-                   (mapcar #'substring-no-properties comps)
-                   :predicate predicate
-                   :action #'ivy-completion-in-region-action
-                   :require-match t)
-         t)))))
+      (setq ivy-completion-beg (- end (ivy-completion-common-length (car 
comps))))
+      (setq ivy-completion-end end)
+      (if (null (cdr comps))
+          (ivy-completion-in-region-action (car comps))
+        (let* ((w (1+ (floor (log (length comps) 10))))
+               (ivy-count-format (and ivy-count-format
+                                      (format "%%-%dd " w))))
+          (and
+           (ivy-read (format "(%s): " str)
+                     ;; remove 'completions-first-difference face
+                     (mapcar #'substring-no-properties comps)
+                     :predicate predicate
+                     :action #'ivy-completion-in-region-action
+                     :require-match t)
+           t))))))
 
 ;;;###autoload
 (define-minor-mode ivy-mode



reply via email to

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