]> code.delx.au - gnu-emacs-elpa/commitdiff
company-create-match-predicate: Just replace the predicate
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 28 Sep 2014 00:57:05 +0000 (04:57 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 28 Sep 2014 00:57:05 +0000 (04:57 +0400)
Building on the previous one is ridiculous, because the main use case is
company-search-mode, and any previous search string is a prefix of the current
one.  With company-filter-candidates, it was especially wasteful.

company.el

index a72136665788bac966c53b3c51ac1459e4ea9a9d..8cb12e30caa8a21859c409dee22dfc3c804eaeca 100644 (file)
@@ -1607,13 +1607,9 @@ from the rest of the back-ends in the group, if any, will be left at the end."
       (company-set-selection (- company-selection pos 1) t))))
 
 (defun company-create-match-predicate ()
-  (setq company-candidates-predicate
-        `(lambda (candidate)
-           ,(if company-candidates-predicate
-                `(and (string-match ,company-search-string candidate)
-                      (funcall ,company-candidates-predicate
-                               candidate))
-              `(string-match ,company-search-string candidate))))
+  (let ((ss company-search-string))
+    (setq company-candidates-predicate
+          (when ss (lambda (candidate) (string-match ss candidate)))))
   (company-update-candidates
    (company-apply-predicate company-candidates company-candidates-predicate))
   ;; Invalidate cache.