[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia f263745 201/241: marginalia-annotate-color:
From: |
Stefan Monnier |
Subject: |
[elpa] externals/marginalia f263745 201/241: marginalia-annotate-color: Use readable-foreground-color |
Date: |
Fri, 28 May 2021 20:49:27 -0400 (EDT) |
branch: externals/marginalia
commit f26374545275cdde96d67576a43f3a919b6927cd
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
marginalia-annotate-color: Use readable-foreground-color
See #64
---
marginalia.el | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index 6627d52..f78e2fc 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -260,6 +260,10 @@ determine it."
(declare-function project-current "project")
(declare-function project-roots "project")
+(declare-function color-rgb-to-hex "color")
+(declare-function color-rgb-to-hsl "color")
+(declare-function color-hsl-to-rgb "color")
+
;;;; Marginalia mode
(defvar marginalia--separator " "
@@ -486,22 +490,28 @@ keybinding since CAND includes it."
(defun marginalia-annotate-color (cand)
"Annotate face CAND with its documentation string and face example."
(when-let (rgb (color-name-to-rgb cand))
- (pcase-let ((`(,r ,g ,b) rgb)
- (`(,h ,s ,l) (apply #'color-rgb-to-hsl rgb)))
+ (pcase-let* ((`(,r ,g ,b) rgb)
+ (`(,h ,s ,l) (apply #'color-rgb-to-hsl rgb))
+ (cr (color-rgb-to-hex r 0 0))
+ (cg (color-rgb-to-hex 0 g 0))
+ (cb (color-rgb-to-hex 0 0 b))
+ (ch (apply #'color-rgb-to-hex (color-hsl-to-rgb h 1 0.5)))
+ (cs (apply #'color-rgb-to-hex (color-hsl-to-rgb h s 0.5)))
+ (cl (apply #'color-rgb-to-hex (color-hsl-to-rgb 0 0 l))))
(marginalia--fields
(" " :face `(:background ,(apply #'color-rgb-to-hex rgb)))
((format "%s%s%s %s"
- (propertize "r" 'face `(:background ,(color-rgb-to-hex r 0 0)))
- (propertize "g" 'face `(:background ,(color-rgb-to-hex 0 g 0)))
- (propertize "b" 'face `(:background ,(color-rgb-to-hex 0 0 b)))
- (color-rgb-to-hex r g b 2)))
+ (propertize "r" 'face `(:background ,cr :foreground
,(readable-foreground-color cr)))
+ (propertize "g" 'face `(:background ,cg :foreground
,(readable-foreground-color cg)))
+ (propertize "b" 'face `(:background ,cb :foreground
,(readable-foreground-color cb)))
+ (color-rgb-to-hex r g b 2)))
((format "%s%s%s %3s° %3s%% %3s%%"
- (propertize "h" 'face `(:background ,(apply #'color-rgb-to-hex
(color-hsl-to-rgb h 1 0.5))))
- (propertize "s" 'face `(:background ,(apply #'color-rgb-to-hex
(color-hsl-to-rgb h s 0.5))))
- (propertize "l" 'face `(:background ,(apply #'color-rgb-to-hex
(color-hsl-to-rgb 0 0 l))))
- (round (* 360 h))
- (round (* 100 s))
- (round (* 100 l))))))))
+ (propertize "h" 'face `(:background ,ch :foreground
,(readable-foreground-color ch)))
+ (propertize "s" 'face `(:background ,cs :foreground
,(readable-foreground-color cs)))
+ (propertize "l" 'face `(:background ,cl :foreground
,(readable-foreground-color cl)))
+ (round (* 360 h))
+ (round (* 100 s))
+ (round (* 100 l))))))))
(defun marginalia-annotate-char (cand)
"Annotate character CAND with its general character category and character
code."
- [elpa] externals/marginalia e15b8b2 174/241: readme: update marginalia keybinding, (continued)
- [elpa] externals/marginalia e15b8b2 174/241: readme: update marginalia keybinding, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 55bfd5f 176/241: do not unnecessarily use defsubst, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia dcdcd5d 179/241: consistently use \` and \' for regexps, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 51f7509 184/241: Fix #57 - protect marginalia--symbol-class equality check, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 3e061a0 185/241: marginalia-annotate-bookmark: Handle non-symbol bookmark handlers, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 58f397d 187/241: update readme, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia c93b1b3 188/241: marginalia--full-candidate: Do not switch entire window, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia e54aa0c 193/241: Revert "Revert "fix #46: affixation suffix must not be nil, it must be a string"", Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 153417a 192/241: marginalia-annotate-file: Use substitute-in-file-name, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2d19497 208/241: marginalia--full-file: Ensure that pt >= 0 if cursor is moved into the prompt, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia f263745 201/241: marginalia-annotate-color: Use readable-foreground-color,
Stefan Monnier <=
- [elpa] externals/marginalia b6994e0 203/241: Attempt to fix full candidate function for files (#65), Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia f3eaa1a 197/241: Add annotator for the embark-keybinding category, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 9559819 209/241: Add link to upstream bug, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia c476b6c 212/241: Track completion base position for marginalia--full-candidate, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 1120eff 210/241: Revert b6994e0ebca6488f379914a1506af833a1abd928 and 06ae3b4c466801962b7611c851e62bf0c749fbbf, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia dca1cb5 213/241: marginalia--base-position: Minor changes, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 1d3af0a 219/241: Merge branch 'base-position' into main, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 7fe1a03 218/241: Fix retrieving full paths under Selectrum, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia cd28764 232/241: marginalia-annotator-registry: Use more precise type, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 624028c 235/241: Silence bytecode compiler warning regarding project-roots (Fix #79), Stefan Monnier, 2021/05/28