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

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

[elpa] master 8cc284e 162/173: Merge pull request #531 from juergenhoetz


From: Dmitry Gutov
Subject: [elpa] master 8cc284e 162/173: Merge pull request #531 from juergenhoetzel/master
Date: Thu, 23 Jun 2016 00:28:47 +0000 (UTC)

branch: master
commit 8cc284ee4eea8f8a1d870f91585f7a1827b40129
Merge: 2d9bf1e b8f8777
Author: Dmitry Gutov <address@hidden>
Commit: GitHub <address@hidden>

    Merge pull request #531 from juergenhoetzel/master
    
    New transformer: company-sort-prefer-same-case-prefix
---
 company.el |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/company.el b/company.el
index 443e638..28ed56b 100644
--- a/company.el
+++ b/company.el
@@ -465,6 +465,8 @@ without duplicates."
           (const :tag "Sort by occurrence" (company-sort-by-occurrence))
           (const :tag "Sort by backend importance"
                  (company-sort-by-backend-importance))
+          (const :tag "Prefer case sensitive prefix"
+                 (company-sort-prefer-same-case-prefix))
           (repeat :tag "User defined" (function))))
 
 (defcustom company-completion-started-hook nil
@@ -1331,6 +1333,16 @@ from the rest of the backends in the group, if any, will 
be left at the end."
                  (let ((b1 (get-text-property 0 'company-backend c1)))
                    (or (not b1) (not (memq b1 low-priority)))))))))))
 
+(defun company-sort-prefer-same-case-prefix (candidates)
+  "Prefer CANDIDATES with the same case sensitive prefix.
+If a backend returns case insensitive matches, candidates with the an exact
+prefix match will be prioritized even if this changes the lexical order."
+  (cl-loop for candidate in candidates
+           if (string-prefix-p company-prefix candidate)
+           collect candidate into same-case
+           else collect candidate into other-case
+           finally return (append same-case other-case)))
+
 (defun company-idle-begin (buf win tick pos)
   (and (eq buf (current-buffer))
        (eq win (selected-window))



reply via email to

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