[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 900ae0d 096/173: Add support for company-face
From: |
Dmitry Gutov |
Subject: |
[elpa] master 900ae0d 096/173: Add support for company-face |
Date: |
Thu, 23 Jun 2016 00:28:41 +0000 (UTC) |
branch: master
commit 900ae0d7a2270ea1d2ea00567e80a619333fd4e5
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Add support for company-face
#437.
---
company.el | 16 ++++++++++++++++
test/frontends-tests.el | 25 +++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/company.el b/company.el
index 498920a..18cd2e3 100644
--- a/company.el
+++ b/company.el
@@ -2405,6 +2405,7 @@ If SHOW-VERSION is non-nil, show the version in the echo
area."
'(face company-tooltip-common-selection
mouse-face company-tooltip-selection)
line)))
+ (company--apply-company-face line)
line))
(defun company--search-chunks ()
@@ -2417,6 +2418,21 @@ If SHOW-VERSION is non-nil, show the version in the echo
area."
(push (cons (car md) (cadr md)) res))))
res))
+(defun company--apply-company-face (str)
+ (let ((start (if (get-text-property 0 'company-face str)
+ 0
+ (next-single-property-change 0 'company-face str)))
+ end value)
+ (while start
+ (setq end (or (next-single-property-change start 'company-face str)
+ (length str)))
+ (setq value (get-text-property start 'company-face str))
+ (font-lock-prepend-text-property start end 'face value str)
+ (font-lock-prepend-text-property start end 'mouse-face value str)
+ (setq start (next-single-property-change end 'company-face str)))
+ (when end
+ (remove-text-properties 0 end '(company-face) str))))
+
(defun company--clean-string (str)
(replace-regexp-in-string
"\\([^[:graph:] ]\\)\\|\\(\ufeff\\)\\|[[:multibyte:]]"
diff --git a/test/frontends-tests.el b/test/frontends-tests.el
index 7348cbd..b35fe76 100644
--- a/test/frontends-tests.el
+++ b/test/frontends-tests.el
@@ -265,6 +265,31 @@
#(" bar "
0 5 (face company-tooltip mouse-face company-tooltip-mouse))))))
+(ert-deftest company-fill-propertize-uses-company-face ()
+ (let ((company-backend #'ignore)
+ (company-prefix "")
+ (str1 "str1")
+ (str2 "str2"))
+ (put-text-property 0 3 'company-face 'boo str1)
+ (put-text-property 1 4 'company-face 'boo str2)
+ (let ((res (company-fill-propertize str1 nil 10 nil nil nil)))
+ ;; `equal-including-properties' uses `eq' for properties.
+ (equal-including-properties
+ (substring res 3 10)
+ #(" " 0 6 (face company-tooltip mouse-face company-tooltip-mouse)))
+ (should (equal (get-text-property 0 'face res)
+ '(boo company-tooltip)))
+ (should (equal (get-text-property 2 'mouse-face res)
+ '(boo company-tooltip-mouse))))
+ (let ((res (company-fill-propertize str2 nil 4 nil nil nil)))
+ (equal-including-properties
+ (substring res 0 1)
+ #("s" 0 1 (face company-tooltip mouse-face company-tooltip-mouse)))
+ (should (equal (get-text-property 1 'face res)
+ '(boo company-tooltip)))
+ (should (equal (get-text-property 3 'mouse-face res)
+ '(boo company-tooltip-mouse))))))
+
(ert-deftest company-column-with-composition ()
:tags '(interactive)
(with-temp-buffer
- [elpa] master 69228c7 168/173: Tag company-dabbrev-ignore-buffers with package-version, (continued)
- [elpa] master 69228c7 168/173: Tag company-dabbrev-ignore-buffers with package-version, Dmitry Gutov, 2016/06/22
- [elpa] master be2f586 100/173: Add workaround for bug#18067, Dmitry Gutov, 2016/06/22
- [elpa] master df14727 110/173: Fix bbdb completion for multi-recipient messages, Dmitry Gutov, 2016/06/22
- [elpa] master 18a77b9 121/173: Improve the example in the Commentary, Dmitry Gutov, 2016/06/22
- [elpa] master c97828c 142/173: Clarify where callback must be called from, Dmitry Gutov, 2016/06/22
- [elpa] master 4cd4c3a 123/173: Turn :company-prefix-length property into a value, Dmitry Gutov, 2016/06/22
- [elpa] master 18b0414 103/173: Declare python-shell-get-process, Dmitry Gutov, 2016/06/22
- [elpa] master 23c6f85 109/173: Merge pull request #450 from fbergroth/capf-prefix-function, Dmitry Gutov, 2016/06/22
- [elpa] master 5bfbb05 098/173: Add the pre-render backend command, Dmitry Gutov, 2016/06/22
- [elpa] master 3ec9d5d 145/173: Add Julia keywords, Dmitry Gutov, 2016/06/22
- [elpa] master 900ae0d 096/173: Add support for company-face,
Dmitry Gutov <=
- [elpa] master 1221739 122/173: Improve the description of cons prefix, Dmitry Gutov, 2016/06/22
- [elpa] master ac7f816 134/173: Merge pull request #466 from tarsius/patch-1, Dmitry Gutov, 2016/06/22
- [elpa] master 9e844d1 124/173: Merge pull request #459 from fbergroth/prefix-length-var, Dmitry Gutov, 2016/06/22
- [elpa] master 31780fb 114/173: Revert "company-cancel: Call frontends' 'hide before 'post-completion", Dmitry Gutov, 2016/06/22
- [elpa] master a7e4408 152/173: Merge pull request #491 from akirakyle/patch-1, Dmitry Gutov, 2016/06/22
- [elpa] master 2dd1f6a 112/173: company-cancel: Call frontends' 'hide before 'post-completion, Dmitry Gutov, 2016/06/22
- [elpa] master dc4927b 158/173: Allow company-dabbrev-ignore-buffers to be a function, Dmitry Gutov, 2016/06/22
- [elpa] master 3f1afc6 171/173: Revert "Remove the [return] binding (#530)", Dmitry Gutov, 2016/06/22
- [elpa] master 9fb6072 116/173: Reimplement -electric-do using a pre-command-hook, Dmitry Gutov, 2016/06/22
- [elpa] master c845c43 097/173: Revert "Add support for company-face", Dmitry Gutov, 2016/06/22