branch: externals/company
commit 8bc23cac27c4fc0f5c4133cc49b33204962ee1fd
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
New search regexp function: company-search-flex-words-in-any-order-regexp
---
company.el | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/company.el b/company.el
index ee07a64550..62596a0c2b 100644
--- a/company.el
+++ b/company.el
@@ -2766,7 +2766,9 @@ each one wraps a part of the input string."
(const :tag "Words separated with spaces, in any order"
company-search-words-in-any-order-regexp)
(const :tag "All characters in given order, with anything in between"
- company-search-flex-regexp)))
+ company-search-flex-regexp)
+ (const :tag "Space separated words in any order, all chars inside a
word with anything in between"
+ company-search-flex-words-in-any-order-regexp)))
(defvar-local company-search-string "")
@@ -2806,6 +2808,16 @@ each one wraps a part of the input string."
(regexp-quote (string c)))))
(substring input 1) ""))))
+(defun company-search-flex-words-in-any-order-regexp (input)
+ (let* ((words (mapcar (lambda (word) (format "\\(?:%s\\)"
+ (company-search-flex-regexp word)))
+ (split-string input " +" t)))
+ (permutations (company--permutations words)))
+ (mapconcat (lambda (words)
+ (mapconcat #'identity words ".*"))
+ permutations
+ "\\|")))
+
(defun company--permutations (lst)
(if (not lst)
'(nil)