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

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

[elpa] master 99ce60b 125/173: Add company-search-flex-regexp


From: Dmitry Gutov
Subject: [elpa] master 99ce60b 125/173: Add company-search-flex-regexp
Date: Thu, 23 Jun 2016 00:28:44 +0000 (UTC)

branch: master
commit 99ce60bc4f8e669163f02b5169399ca481461545
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Add company-search-flex-regexp
    
    #460
---
 company.el |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/company.el b/company.el
index 0735630..2381e9d 100644
--- a/company.el
+++ b/company.el
@@ -1641,7 +1641,9 @@ each one wraps a part of the input string."
           (const :tag "Exact match" regexp-quote)
           (const :tag "Words separated with spaces" 
company-search-words-regexp)
           (const :tag "Words separated with spaces, in any order"
-                 company-search-words-in-any-order-regexp)))
+                 company-search-words-in-any-order-regexp)
+          (const :tag "All characters in given order, with anything in between"
+                 company-search-flex-regexp)))
 
 (defvar-local company-search-string "")
 
@@ -1671,6 +1673,15 @@ each one wraps a part of the input string."
                permutations
                "\\|")))
 
+(defun company-search-flex-regexp (input)
+  (if (zerop (length input))
+      ""
+    (concat (regexp-quote (string (aref input 0)))
+            (mapconcat (lambda (c)
+                         (concat "[^" (string c) "]*"
+                                 (regexp-quote (string c))))
+                       (substring input 1) ""))))
+
 (defun company--permutations (lst)
   (if (not lst)
       '(nil)



reply via email to

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