[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d8ca520 13/23: Improve search visualization
From: |
Dmitry Gutov |
Subject: |
[elpa] master d8ca520 13/23: Improve search visualization |
Date: |
Fri, 11 Nov 2016 22:21:42 +0000 (UTC) |
branch: master
commit d8ca520e99f40db1a0d2727d9b46c1db26b81f12
Author: Andrea Orru <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Improve search visualization
Fixes #567.
---
NEWS.md | 1 +
company.el | 34 ++++++++++++++++++++--------------
test/frontends-tests.el | 12 ++++++------
3 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index ea04f48..ecb48f8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
## Next
+* Better visualization of search matches. New face
`company-tooltip-search-selection`.
* New variable `company-files-exclusions`.
* `company-next-page` and `company-previous-page` adhere to
`company-selection-wrap-around` docstring more closely and only wrap around
diff --git a/company.el b/company.el
index d297bd3..d46e96a 100644
--- a/company.el
+++ b/company.el
@@ -118,9 +118,13 @@ attention to case differences."
"Face used for the selection in the tooltip.")
(defface company-tooltip-search
- '((default :inherit company-tooltip-selection))
+ '((default :inherit highlight))
"Face used for the search string in the tooltip.")
+(defface company-tooltip-search-selection
+ '((default :inherit highlight))
+ "Face used for the search string inside the selection in the tooltip.")
+
(defface company-tooltip-mouse
'((default :inherit highlight))
"Face used for the tooltip item under the mouse.")
@@ -2475,22 +2479,24 @@ If SHOW-VERSION is non-nil, show the version in the
echo area."
'company-tooltip-common-selection
'company-tooltip-common)
line)
- (when selected
- (if (let ((re (funcall company-search-regexp-function
+ (when (let ((re (funcall company-search-regexp-function
company-search-string)))
(and (not (string= re ""))
(string-match re value (length company-prefix))))
- (pcase-dolist (`(,mbeg . ,mend) (company--search-chunks))
- (let ((beg (+ margin mbeg))
- (end (+ margin mend))
- (width (- width (length right))))
- (when (< beg width)
- (font-lock-prepend-text-property beg (min end width)
- 'face 'company-tooltip-search
- line))))
- (font-lock-append-text-property 0 width 'face
- 'company-tooltip-selection
- line)))
+ (pcase-dolist (`(,mbeg . ,mend) (company--search-chunks))
+ (let ((beg (+ margin mbeg))
+ (end (+ margin mend))
+ (width (- width (length right))))
+ (when (< beg width)
+ (font-lock-prepend-text-property beg (min end width) 'face
+ (if selected
+
'company-tooltip-search-selection
+ 'company-tooltip-search)
+ line)))))
+ (when selected
+ (font-lock-append-text-property 0 width 'face
+ 'company-tooltip-selection
+ line))
(font-lock-append-text-property 0 width 'face
'company-tooltip
line)
diff --git a/test/frontends-tests.el b/test/frontends-tests.el
index 7b8ee61..9592bed 100644
--- a/test/frontends-tests.el
+++ b/test/frontends-tests.el
@@ -256,18 +256,18 @@
(should (ert-equal-including-properties
(company-fill-propertize "barfoo" nil 6 t nil nil)
#("barfoo"
- 0 3 (face (company-tooltip) mouse-face (company-tooltip-mouse))
- 3 6 (face (company-tooltip-search company-tooltip) mouse-face
(company-tooltip-mouse)))))
+ 0 3 (face (company-tooltip-selection company-tooltip)
mouse-face (company-tooltip-mouse))
+ 3 6 (face (company-tooltip-search-selection
company-tooltip-selection company-tooltip) mouse-face
(company-tooltip-mouse)))))
(should (ert-equal-including-properties
(company-fill-propertize "barfoo" nil 5 t "" " ")
#("barfo "
- 0 3 (face (company-tooltip) mouse-face (company-tooltip-mouse))
- 3 5 (face (company-tooltip-search company-tooltip) mouse-face
(company-tooltip-mouse))
- 5 6 (face (company-tooltip) mouse-face
(company-tooltip-mouse)))))
+ 0 3 (face (company-tooltip-selection company-tooltip)
mouse-face (company-tooltip-mouse))
+ 3 5 (face (company-tooltip-search-selection
company-tooltip-selection company-tooltip) mouse-face (company-tooltip-mouse))
+ 5 6 (face (company-tooltip-selection company-tooltip)
mouse-face (company-tooltip-mouse)))))
(should (ert-equal-including-properties
(company-fill-propertize "barfoo" nil 3 t " " " ")
#(" bar "
- 0 5 (face (company-tooltip) mouse-face
(company-tooltip-mouse)))))))
+ 0 5 (face (company-tooltip-selection company-tooltip)
mouse-face (company-tooltip-mouse)))))))
(ert-deftest company-fill-propertize-overrides-face-property ()
(let ((company-backend #'ignore)
- [elpa] master ac2606a 18/23: Add JSX modes to javascript aliases, (continued)
- [elpa] master ac2606a 18/23: Add JSX modes to javascript aliases, Dmitry Gutov, 2016/11/11
- [elpa] master fc39277 15/23: Add keywords for rust-mode to company-keywords., Dmitry Gutov, 2016/11/11
- [elpa] master f78f9c1 21/23: Initialize grouped backends on the fly as well, Dmitry Gutov, 2016/11/11
- [elpa] master e6689ea 12/23: company-files--directory-files: Swallow file-error, Dmitry Gutov, 2016/11/11
- [elpa] master 9476aef 09/23: company-files--directory-files: Don't ignore errors, Dmitry Gutov, 2016/11/11
- [elpa] master c353c71 14/23: global goes through all the tag files listed in GTAGSLIBPATH, Dmitry Gutov, 2016/11/11
- [elpa] master f2327bc 19/23: Merge pull request #575 from Wilfred/patch-1, Dmitry Gutov, 2016/11/11
- [elpa] master e077caf 22/23: Release 0.9.1, Dmitry Gutov, 2016/11/11
- [elpa] master ba87881 16/23: Merge pull request #572 from Wilfred/rust_keywords, Dmitry Gutov, 2016/11/11
- [elpa] master 6025006 08/23: Add company-files-exclusions, Dmitry Gutov, 2016/11/11
- [elpa] master d8ca520 13/23: Improve search visualization,
Dmitry Gutov <=
- [elpa] master 1028f38 20/23: company-indent-or-complete-common: Blacklist some indentation functions, Dmitry Gutov, 2016/11/11
- [elpa] master 85bd83e 23/23: Merge commit 'e077caf1957f1846fae29aa84a021234c43be96f', Dmitry Gutov, 2016/11/11
- [elpa] master 917936c 17/23: Fix keyword ordering, Dmitry Gutov, 2016/11/11