emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/company 42b8894: New option: company-text-icons-add-bac


From: ELPA Syncer
Subject: [elpa] externals/company 42b8894: New option: company-text-icons-add-background
Date: Tue, 4 May 2021 17:57:07 -0400 (EDT)

branch: externals/company
commit 42b889497e073f5c2d96d570d7c109163886ca1c
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    New option: company-text-icons-add-background
    
    #1088
---
 company.el | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/company.el b/company.el
index d8cbbab..e174c9a 100644
--- a/company.el
+++ b/company.el
@@ -1557,7 +1557,11 @@ Only affects `company-text-icons-margin'."
   "Format string for printing the text icons."
   :type 'string)
 
-(defun company-text-icons-margin (candidate _selected)
+(defcustom company-text-icons-add-background nil
+  "When non-nil, add special background to the characters."
+  :type 'boolean)
+
+(defun company-text-icons-margin (candidate selected)
   "Margin function which returns unicode icons."
   (when-let ((candidate candidate)
              (kind (company-call-backend 'kind candidate))
@@ -1569,10 +1573,27 @@ Only affects `company-text-icons-margin'."
     (propertize
      (format company-text-icons-format icon)
      'face
-     (if company-text-face-extra-attributes
-         (append company-text-face-extra-attributes
-                 (list :foreground (face-attribute face :foreground)))
-       face))))
+     `(,@company-text-face-extra-attributes
+       ,@(when company-text-icons-add-background
+           (list :background
+                 (company-text-icons--background face selected)))
+       :foreground ,(face-attribute face :foreground)))))
+
+(declare-function color-rgb-to-hex "color")
+(declare-function color-gradient "color")
+
+(defun company-text-icons--background (face selected)
+  (apply #'color-rgb-to-hex
+         (nth 0 (color-gradient
+                 (color-name-to-rgb
+                  (face-attribute
+                   (if selected
+                       'company-tooltip-selection
+                     'company-tooltip)
+                   :background))
+                 (color-name-to-rgb
+                  (face-attribute face :foreground))
+                 10))))
 
 (defcustom company-dot-icons-format "●"
   "Format string for `company-dot-icons-margin'."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]