Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

counsel.el: Fix and improve counsel-colors-* #1436

Closed
wants to merge 1 commit into from

Conversation

basil-conto
Copy link
Collaborator

@basil-conto basil-conto commented Feb 7, 2018

Changelog

(counsel-colors--best-contrast-color)
(counsel-colors--update-highlight): Replace with shr-color-visible.
(counsel-colors--name-to-hex): Fix docstring.
(counsel-colors--formatter): New defun generalising ivy--format-function-generic for counsel-colors-emacs and counsel-colors-web and fixing foreground/background contrast of current candidate.
(counsel-colors-emacs, counsel-colors-web): Simplify logic. Fix docstring. Reduce display width. Do not hard-code ivy-count-format. Use counsel-colors--formatter with text properties.
(counsel-colors--web-colors-alist): Remove.
(counsel-colors--web-alist): Replacement for counsel-colors--web-colors-alist based on shr-color-html-colors-alist.
(counsel-colors-action-insert-hex, counsel-colors-action-kill-hex): Use text properties.
(counsel-colors-action-insert-name)
(counsel-colors-action-kill-name): Redundant; remove.

Justification and demonstration

Graphical terminal

Before

graphical-before

After

graphical-after

Text terminal

Before

tty-before

After

tty-after

Discussion

I haven't tested this, but in theory this should fix #921.

A further benefit of the refactor is that M-p within a counsel-colors-* session gives the colour name, rather than the unwieldy formatted name + hex + sample string.

Pinging @joedicastro for comment.

(counsel-colors--best-contrast-color)
(counsel-colors--update-highlight): Replace with shr-color-visible.
(counsel-colors--name-to-hex): Fix docstring.
(counsel-colors--formatter): New defun generalizing
ivy--format-function-generic for counsel-colors-emacs and
counsel-colors-web and fixing foreground/background contrast of
current candidate.
(counsel-colors-emacs, counsel-colors-web): Simplify logic.  Fix
docstring.  Do not hard-code ivy-count-format.  Reduce display
width.  Use counsel-colors--formatter with text properties.
(counsel-colors--web-colors-alist): Remove.
(counsel-colors--web-alist): Replacement for
counsel-colors--web-colors-alist based on
shr-color-html-colors-alist.
(counsel-colors-action-insert-hex, counsel-colors-action-kill-hex):
Use text properties.
(counsel-colors-action-insert-name)
(counsel-colors-action-kill-name): Redundant; remove.

Fixes abo-abo#921 and closes abo-abo#1436.
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Feb 7, 2018

Looks good, thanks.

@basil-conto basil-conto deleted the blc/colour branch Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants