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

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

[elpa] master d82dc2c 328/348: counsel.el (counsel-colors--best-contrast


From: Oleh Krehel
Subject: [elpa] master d82dc2c 328/348: counsel.el (counsel-colors--best-contrast-color): Return same color on error
Date: Sat, 8 Apr 2017 11:04:24 -0400 (EDT)

branch: master
commit d82dc2c0d33f1cd4b74876af8f920c81a3636f4b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-colors--best-contrast-color): Return same color on error
    
    In case `color-name-to-rgb' returns nil.
    
    Re #921
---
 counsel.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/counsel.el b/counsel.el
index a2d3945..7ec3a7b 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2809,13 +2809,15 @@ midpoint, then the chosen color is black, otherwise is 
white.  This
 helps to improve the contrast and readability of a text regardless of
 the background color."
   (let ((rgb (color-name-to-rgb color)))
-    (if (>
-         (+ (* (nth 0 rgb) 0.299)
-            (* (nth 1 rgb) 0.587)
-            (* (nth 2 rgb) 0.114))
-         0.5)
-        "#000000"
-      "#FFFFFF")))
+    (if rgb
+        (if (>
+             (+ (* (nth 0 rgb) 0.299)
+                (* (nth 1 rgb) 0.587)
+                (* (nth 2 rgb) 0.114))
+             0.5)
+            "#000000"
+          "#FFFFFF")
+      color)))
 
 (defun counsel-colors--update-highlight (cand)
   "Update the highlight face for the current candidate CAND.



reply via email to

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