[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company ac13eab 2/2: Merge pull request #1103 from yuga
From: |
ELPA Syncer |
Subject: |
[elpa] externals/company ac13eab 2/2: Merge pull request #1103 from yugaego/numbers-face |
Date: |
Wed, 16 Jun 2021 06:57:07 -0400 (EDT) |
branch: externals/company
commit ac13eabd79ee0a963082af835e6bc3fb4d01bb81
Merge: 7d65894 cdee34e
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: GitHub <noreply@github.com>
Merge pull request #1103 from yugaego/numbers-face
Add faces for quick-access numbers
---
NEWS.md | 3 +++
company.el | 36 +++++++++++++++++++++++++++---------
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index e247c94..35408b2 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,9 @@
## Next
+* New faces `company-tooltip-quick-access` and
+ `company-tooltip-quick-access-selection`
+ ([#303](https://github.com/company-mode/company-mode/issues/303)).
* Default colors for dark themes have been changed
([#949](https://github.com/company-mode/company-mode/issues/949)).
* Default key bindings have been changed, moving `company-select-next` and
diff --git a/company.el b/company.el
index ba8233f..dfece06 100644
--- a/company.el
+++ b/company.el
@@ -126,6 +126,16 @@
'((default :inherit company-tooltip-annotation))
"Face used for the selected completion annotation in the tooltip.")
+(defface company-tooltip-quick-access
+ '((default :inherit company-tooltip-annotation))
+ "Face used for the quick-access keys shown in the tooltip."
+ :package-version '(company . "0.9.14"))
+
+(defface company-tooltip-quick-access-selection
+ '((default :inherit company-tooltip-annotation-selection))
+ "Face used for the selected quick-access keys shown in the tooltip."
+ :package-version '(company . "0.9.14"))
+
(defface company-scrollbar-fg
'((((background light))
:background "darkred")
@@ -2993,6 +3003,14 @@ If SHOW-VERSION is non-nil, show the version in the echo
area."
(mod numbered 10)
" ")))
+(defun company--format-quick-access-key (numbered selected)
+ "Produce a quick-access key to show beside a candidate."
+ (propertize (funcall company-show-numbers-function numbered)
+ 'face
+ (if selected
+ 'company-tooltip-quick-access-selection
+ 'company-tooltip-quick-access)))
+
(defsubst company--window-height ()
(if (fboundp 'window-screen-lines)
(floor (window-screen-lines))
@@ -3180,18 +3198,18 @@ If SHOW-VERSION is non-nil, show the version in the
echo area."
(annotation (cadr item))
(left (nth 2 item))
(right (company-space-string company-tooltip-margin))
- (width width))
+ (width width)
+ (selected (equal selection i)))
(when company-show-numbers
- (let ((numbers-place
- (gv-ref (if (eq company-show-numbers 'left) left right))))
- (cl-decf width 2)
- (cl-incf numbered)
- (setf (gv-deref numbers-place)
- (concat (funcall company-show-numbers-function numbered)
- (gv-deref numbers-place)))))
+ (let ((numbers-place (gv-ref (if (eq company-show-numbers 'left)
left right))))
+ (cl-decf width 2)
+ (cl-incf numbered)
+ (setf (gv-deref numbers-place)
+ (concat (company--format-quick-access-key numbered
selected)
+ (gv-deref numbers-place)))))
(push (concat
(company-fill-propertize str annotation
- width (equal i selection)
+ width selected
left
right)
(when scrollbar-bounds
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/company ac13eab 2/2: Merge pull request #1103 from yugaego/numbers-face,
ELPA Syncer <=