From 99ce60bc4f8e669163f02b5169399ca481461545 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Fri, 22 Jan 2016 21:28:51 +0300 Subject: [PATCH] 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 07356306a..2381e9d53 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) -- 2.39.2