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

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

[elpa] master 16486d5 394/399: ivy.el (ivy--shorter-matches-first): Add


From: Oleh Krehel
Subject: [elpa] master 16486d5 394/399: ivy.el (ivy--shorter-matches-first): Add and use for ivy-completion-in-region
Date: Sat, 20 Jul 2019 14:58:06 -0400 (EDT)

branch: master
commit 16486d5b78222b0a78c8a71699b257f51c03d6cc
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy--shorter-matches-first): Add and use for 
ivy-completion-in-region
---
 ivy.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ivy.el b/ivy.el
index 1c2da08..d224484 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3240,8 +3240,18 @@ CANDIDATES are assumed to be static."
                    res))))
     (setq ivy--all-candidates res)))
 
+(defun ivy--shorter-matches-first (_name cands)
+  "Sort CANDS according to their length."
+  (if (< (length cands) ivy-sort-max-size)
+      (cl-sort
+       (copy-sequence cands)
+       (lambda (s1 s2)
+         (< (length s1) (length s2))))
+    cands))
+
 (defcustom ivy-sort-matches-functions-alist
   '((t . nil)
+    (ivy-completion-in-region . ivy--shorter-matches-first)
     (ivy-switch-buffer . ivy-sort-function-buffer))
   "An alist of functions for sorting matching candidates.
 



reply via email to

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