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

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

[elpa] externals/company 59bbbbc 5/6: company-text-icons-margin: Better


From: ELPA Syncer
Subject: [elpa] externals/company 59bbbbc 5/6: company-text-icons-margin: Better handling of unspecified colors
Date: Wed, 5 May 2021 15:57:09 -0400 (EDT)

branch: externals/company
commit 59bbbbc83f257286e4872743c190d8239a0c8495
Author: Mohsin Kaleem <mohkale@kisara.moe>
Commit: Mohsin Kaleem <mohkale@kisara.moe>

    company-text-icons-margin: Better handling of unspecified colors
    
    For some reason `face-attribute` returns unspecified on a missing
    property instead of nil.
---
 company.el | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/company.el b/company.el
index e4ebe85..6a7c57c 100644
--- a/company.el
+++ b/company.el
@@ -1556,17 +1556,25 @@ See `company-text-icons-mapping'."
 (declare-function color-rgb-to-hex "color")
 (declare-function color-gradient "color")
 
+(cl-defsubst company-text-icons--extract-property (face property)
+  "Try to extract PROPERTY from FACE.
+If FACE isn't a valid face return FACE as is. If FACE doesn't have
+PROPERTY return nil."
+  (if (facep face)
+      (let ((value (face-attribute face property)))
+        (unless (eq value 'unspecified)
+          value))
+    face))
+
 (defun company-text-icons--face (fg bg selected)
-  (let ((fg-color (if (facep fg) (face-attribute fg :foreground) fg)))
+  (let ((fg-color (company-text-icons--extract-property fg :foreground)))
     `(,@company-text-face-extra-attributes
       ,@(and fg-color
              (list :foreground fg-color))
       ,@(let* ((bg-is-cons (consp bg))
                (bg (if bg-is-cons (if selected (cdr bg) (car bg)) bg))
-               (bg-color (if (facep bg) (face-attribute bg :background) bg))
-               (bg-color (unless (eq bg-color 'unspecified)
-                           bg-color))
-               (tooltip-bg-color (face-attribute
+               (bg-color (company-text-icons--extract-property bg :background))
+               (tooltip-bg-color (company-text-icons--extract-property
                                   (if selected
                                       'company-tooltip-selection
                                     'company-tooltip)



reply via email to

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