[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b0940fb 29/66: Close #798: look for :company-match functio
From: |
Dmitry Gutov |
Subject: |
[elpa] master b0940fb 29/66: Close #798: look for :company-match function in the capf's metadata |
Date: |
Mon, 5 Nov 2018 18:19:17 -0500 (EST) |
branch: master
commit b0940fbd7308a52e659b8ac76bf6feee9d633c6e
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Close #798: look for :company-match function in the capf's metadata
* company-capf.el (company-capf): In `match', look for the `:company-match'
function in the capf's metadata.
---
company-capf.el | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/company-capf.el b/company-capf.el
index 5613333..52716a3 100644
--- a/company-capf.el
+++ b/company-capf.el
@@ -112,23 +112,27 @@
(nth 3 res) (plist-get (nthcdr 4 res) :predicate))))
(cdr (assq 'display-sort-function meta))))))
(`match
- (let* ((match-start nil) (pos -1)
- (prop-value nil) (faces nil)
- (has-face-p nil) chunks
- (limit (length arg)))
- (while (< pos limit)
- (setq pos
- (if (< pos 0) 0 (next-property-change pos arg limit)))
- (setq prop-value (or (get-text-property pos 'face arg)
- (get-text-property pos 'font-lock-face arg))
- faces (if (listp prop-value) prop-value (list prop-value))
- has-face-p (memq 'completions-common-part faces))
- (cond ((and (not match-start) has-face-p)
- (setq match-start pos))
- ((and match-start (not has-face-p))
- (push (cons match-start pos) chunks)
- (setq match-start nil))))
- (if chunks (nreverse chunks) (cons 0 (length arg)))))
+ ;; ask the for the `:company-match' function. If that doesn't help,
+ ;; fallback to sniffing for face changes to get a suitable value
+ (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-match)))
+ (if f (funcall f arg)
+ (let* ((match-start nil) (pos -1)
+ (prop-value nil) (faces nil)
+ (has-face-p nil) chunks
+ (limit (length arg)))
+ (while (< pos limit)
+ (setq pos
+ (if (< pos 0) 0 (next-property-change pos arg limit)))
+ (setq prop-value (or (get-text-property pos 'face arg)
+ (get-text-property pos 'font-lock-face arg))
+ faces (if (listp prop-value) prop-value (list prop-value))
+ has-face-p (memq 'completions-common-part faces))
+ (cond ((and (not match-start) has-face-p)
+ (setq match-start pos))
+ ((and match-start (not has-face-p))
+ (push (cons match-start pos) chunks)
+ (setq match-start nil))))
+ (if chunks (nreverse chunks) (cons 0 (length arg)))))))
(`duplicates t)
(`no-cache t) ;Not much can be done here, as long as we handle
;non-prefix matches.
- [elpa] master 0afe18d 09/66: Allow CMake completion in strings when inside ${...}, (continued)
- [elpa] master 0afe18d 09/66: Allow CMake completion in strings when inside ${...}, Dmitry Gutov, 2018/11/05
- [elpa] master 67650de 17/66: Merge pull request #769 from tigersoldier/master, Dmitry Gutov, 2018/11/05
- [elpa] master 23e6c82 07/66: Add NEWS entry, Dmitry Gutov, 2018/11/05
- [elpa] master 5c2425b 06/66: Work around python-shell-completion-at-point's behavior, Dmitry Gutov, 2018/11/05
- [elpa] master a64d52c 05/66: Deprecate company-nxml too, Dmitry Gutov, 2018/11/05
- [elpa] master 5698be9 10/66: Simplify company-cmake-prefix-dollar-brace-p, Dmitry Gutov, 2018/11/05
- [elpa] master 5118b59 14/66: company-tng: Supress post-completion (#731), Dmitry Gutov, 2018/11/05
- [elpa] master a78f7d8 15/66: Merge pull request #764 from nikital/tng-supress-post-completion, Dmitry Gutov, 2018/11/05
- [elpa] master 5a856d7 13/66: backend: Remove pre-completion command, Dmitry Gutov, 2018/11/05
- [elpa] master 5b11709 31/66: Emacs 24 doesn't have working elisp capf, so don't test it, Dmitry Gutov, 2018/11/05
- [elpa] master b0940fb 29/66: Close #798: look for :company-match function in the capf's metadata,
Dmitry Gutov <=
- [elpa] master f404a12 30/66: Add some tests for the previous commits, Dmitry Gutov, 2018/11/05
- [elpa] master 0325a40 11/66: Remove an unnecessary test, Dmitry Gutov, 2018/11/05
- [elpa] master ed1085f 19/66: Merge pull request #771 from Wilfred/interactive-example, Dmitry Gutov, 2018/11/05
- [elpa] master 7d6ab3c 22/66: company-keywords: Support thrift-mode, Dmitry Gutov, 2018/11/05
- [elpa] master 270976b 25/66: Update Javascript and Python keywords, Dmitry Gutov, 2018/11/05
- [elpa] master 287a5fb 18/66: Make example backend interactive, Dmitry Gutov, 2018/11/05
- [elpa] master 46680da 21/66: company-css: Improve performance, Dmitry Gutov, 2018/11/05
- [elpa] master d26ec71 23/66: Merge pull request #785 from ylectric/company-keywords/thrift-mode, Dmitry Gutov, 2018/11/05
- [elpa] master 392dadd 28/66: Per #798, #762: Fix company-capf's highlighting of non-prefix matches, Dmitry Gutov, 2018/11/05
- [elpa] master f1aef4d 45/66: add reference url for go-mode's keywords, Dmitry Gutov, 2018/11/05