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-colors-emacs stopped working #921

Closed
Dickby opened this Issue Mar 17, 2017 · 10 comments

Comments

Projects
None yet
3 participants
@Dickby
Copy link

commented Mar 17, 2017

invoking the command counsel-colors-emacs gives the error message:

counsel-colors--update-highlight: Wrong type argument: number-or-marker-p, nil

I tested this with emacs -Q
emacs version:
26.0.50

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Mar 17, 2017

Can't reproduce.
Please try to reinstall/restart and/or reproduce on a stable version of Emacs.

@Dickby

This comment has been minimized.

Copy link
Author

commented Mar 17, 2017

The error is somewhere hidden in my .emacs.d directory.
Strange that it occurs even if i start emacs with -Q and only package-initialize.
But if I start it without any .emacs.d directory the error is gone.
I close this issue.

@Dickby Dickby closed this Mar 17, 2017

@Dickby

This comment has been minimized.

Copy link
Author

commented Mar 28, 2017

Since i opened this issue, i can't find what causes the error in my config.
Even if I start emacs with -Q and only package-initialize i get this error.
only if i rename my .emacs.d reinstall ivy and counsel, It is still working.
Maby you can help me track the error?
somehow caused by the return value of counsel-colors--best-contrast-color
if i override the function with a dummy that just returns "black" counsel-colors-emacs is still working.
if I toggle-debug-on-error it gives

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  counsel-colors--best-contrast-color("0000000")
  counsel-colors--update-highlight(#("black                    #000000000000              " 0 25 (result "black") 25 40 (face (:foreground "black")) 40 50 (face (:background "black")) 50 52 (face (:foreground "black"))))
  #[0 "\302�\303H	>\204�\304\305\306�D\"\210�\307H!\207" [ivy-last cl-struct-ivy-state-tags counsel-colors--update-highlight 0 signal wrong-type-argument ivy-state 23] 5]()
  ivy--insert-minibuffer(#("\nblack                    #000000000000              \nDimGrey                  #696969696969              dim gray, dim grey, DimGray\nDarkGrey                 #a9a9a9a9a9a9              dark gray, dark grey, DarkGray\ngrey                     #bebebebebebe              gray\nLightGrey                #d3d3d3d3d3d3              light gray, light grey, LightGray\ngainsboro                #dcdcdcdcdcdc              \nWhiteSmoke               #f5f5f5f5f5f5              white smoke\nwhite                    #ffffffffffff              \nred                      #ffff00000000              " 0 1 (read-only nil) 1 26 (result "black" face ((:foreground "black") ivy-current-match) read-only nil) 26 41 (face ((:foreground "black") ivy-current-match) read-only nil) 41 51 (face ((:foreground "black") ivy-current-match) read-only nil) 51 53 (face ((:foreground "black") ivy-current-match) read-only nil) 53 54 (read-only nil) 54 79 (result "DimGrey" read-only nil) 79 94 (face (:foreground "DimGrey") read-only nil) 94 104 (face (:background "DimGrey") read-only nil) 104 133 (face (:foreground "DimGrey") read-only nil) 133 134 (read-only nil) 134 159 (result "DarkGrey" read-only nil) 159 174 (face (:foreground "DarkGrey") read-only nil) 174 184 (face (:background "DarkGrey") read-only nil) 184 216 (face (:foreground "DarkGrey") read-only nil) 216 217 (read-only nil) 217 242 (result "grey" read-only nil) 242 257 (face (:foreground "grey") read-only nil) 257 267 (face (:background "grey") read-only nil) 267 273 (face (:foreground "grey") read-only nil) 273 274 (read-only nil) 274 299 (result "LightGrey" read-only nil) 299 314 (face (:foreground "LightGrey") read-only nil) 314 324 (face (:background "LightGrey") read-only nil) 324 359 (face (:foreground "LightGrey") read-only nil) 359 360 (read-only nil) 360 385 (result "gainsboro" read-only nil) 385 400 (face (:foreground "gainsboro") read-only nil) 400 410 (face (:background "gainsboro") read-only nil) 410 412 (face (:foreground "gainsboro") read-only nil) 412 413 (read-only nil) 413 438 (result "WhiteSmoke" read-only nil) 438 453 (face (:foreground "WhiteSmoke") read-only nil) 453 463 (face (:background "WhiteSmoke") read-only nil) 463 476 (face (:foreground "WhiteSmoke") read-only nil) 476 477 (read-only nil) 477 502 (result "white" read-only nil) 502 517 (face (:foreground "white") read-only nil) 517 527 (face (:background "white") read-only nil) 527 529 (face (:foreground "white") read-only nil) 529 530 (read-only nil) 530 555 (result "red" read-only nil) 555 570 (face (:foreground "red") read-only nil) 570 580 (face (:background "red") read-only nil) 580 582 (face (:foreground "red") read-only nil)))
  ivy--exhibit()
  ivy--minibuffer-setup()
  #[0 "\302\303\301\242\"\210\300 \207" [ivy--minibuffer-setup (#0) remove-hook minibuffer-setup-hook] 3]()
  read-from-minibuffer("%d Emacs color: " nil (keymap keymap (2 . ivy-scroll-down-command) (6 . ivy-scroll-up-command) (67109110 . ivy-avy) (C-return . ivy-immediate-done) (3 keymap (19 . ivy-rotate-sort) (1 . ivy-toggle-ignore) (15 . ivy-occur)) (67108903 . ivy-avy) (33554464 . ivy-restrict-to-matches) (15 . hydra-ivy/body) (22 . ivy-scroll-up-command) (7 . minibuffer-keyboard-quit) (32 . self-insert-command) (18 . ivy-reverse-i-search) (19 . ivy-next-line-or-history) (remap keymap (describe-mode . ivy-help) (kill-ring-save . ivy-kill-ring-save) (kill-line . ivy-kill-line) (scroll-down-command . ivy-scroll-down-command) (scroll-up-command . ivy-scroll-up-command) (end-of-buffer . ivy-end-of-buffer) (beginning-of-buffer . ivy-beginning-of-buffer) (kill-word . ivy-kill-word) (forward-char . ivy-forward-char) (delete-char . ivy-delete-char) (backward-kill-word . ivy-backward-kill-word) (backward-delete-char-untabify . ivy-backward-delete-char) (delete-backward-char . ivy-backward-delete-char) (previous-line . ivy-previous-line) (next-line . ivy-next-line)) (9 . ivy-partial-or-done) (10 . ivy-alt-done) (27 keymap (1 . ivy-read-action) (15 . ivy-dispatching-call) (111 . ivy-dispatching-done-hydra) (105 . ivy-insert-current) (106 . ivy-yank-word) (114 . ivy-toggle-regexp-quote) (16 . ivy-previous-line-and-call) (14 . ivy-next-line-and-call) (118 . ivy-scroll-down-command) (112 . ivy-previous-history-element) (110 . ivy-next-history-element) (10 . ivy-immediate-done) (13 . ivy-call)) (13 . ivy-done)) nil counsel-colors-emacs-history)
  ivy-read("%d Emacs color: " (#("black                    #000000000000              " 0 25 (result "black") 25 40 (face (:foreground "black")) 40 50 (face (:background "black")) 50 52 (face (:foreground "black"))) #("DimGrey                  #696969696969              dim gray, dim grey, DimGray" 0 25 (result "DimGrey") 25 40 (face (:foreground "DimGrey")) 40 50 (face (:background "DimGrey")) 50 79 (face (:foreground "DimGrey"))) #("DarkGrey                 #a9a9a9a9a9a9              dark gray, dark grey, DarkGray" 0 25 (result "DarkGrey") 25 40 (face (:foreground "DarkGrey")) 40 50 (face (:background "DarkGrey")) 50 82 (face (:foreground "DarkGrey"))) #("grey                     #bebebebebebe              gray" 0 25 (result "grey") 25 40 (face (:foreground "grey")) 40 50 (face (:background "grey")) 50 56 (face (:foreground "grey"))) #("LightGrey                #d3d3d3d3d3d3              light gray, light grey, LightGray" 0 25 (result "LightGrey") 25 40 (face (:foreground "LightGrey")) 40 50 (face (:background "LightGrey")) 50 85 (face (:foreground "LightGrey"))) #("gainsboro                #dcdcdcdcdcdc              " 0 25 (result "gainsboro") 25 40 (face (:foreground "gainsboro")) 40 50 (face (:background "gainsboro")) 50 52 (face (:foreground "gainsboro"))) #("WhiteSmoke               #f5f5f5f5f5f5              white smoke" 0 25 (result "WhiteSmoke") 25 40 (face (:foreground "WhiteSmoke")) 40 50 (face (:background "WhiteSmoke")) 50 63 (face (:foreground "WhiteSmoke"))) #("white                    #ffffffffffff              " 0 25 (result "white") 25 40 (face (:foreground "white")) 40 50 (face (:background "white")) 50 52 (face (:foreground "white"))) #("red                      #ffff00000000              " 0 25 (result "red") 25 40 (face (:foreground "red")) 40 50 (face (:background "red")) 50 52 (face (:foreground "red"))) #("OrangeRed                #ffff45450000              orange red" 0 25 (result "OrangeRed") 25 40 (face (:foreground "OrangeRed")) 40 50 (face (:background "OrangeRed")) 50 62 (face (:foreground "OrangeRed"))) #("DarkOrange               #ffff8c8c0000              dark orange" 0 25 (result "DarkOrange") 25 40 (face (:foreground "DarkOrange")) 40 50 (face (:background "DarkOrange")) 50 63 (face (:foreground "DarkOrange"))) #("orange                   #ffffa5a50000              " 0 25 (result "orange") 25 40 (face (:foreground "orange")) 40 50 (face (:background "orange")) 50 52 (face (:foreground "orange"))) #("gold                     #ffffd7d70000              " 0 25 (result "gold") 25 40 (face (:foreground "gold")) 40 50 (face (:background "gold")) 50 52 (face (:foreground "gold"))) #("yellow                   #ffffffff0000              " 0 25 (result "yellow") 25 40 (face (:foreground "yellow")) 40 50 (face (:background "yellow")) 50 52 (face (:foreground "yellow"))) #("chartreuse               #7f7fffff0000              " 0 25 (result "chartreuse") 25 40 (face (:foreground "chartreuse")) 40 50 (face (:background "chartreuse")) 50 52 (face (:foreground "chartreuse"))) #("LawnGreen                #7c7cfcfc0000              lawn green" 0 25 (result "LawnGreen") 25 40 (face (:foreground "LawnGreen")) 40 50 (face (:background "LawnGreen")) 50 62 (face (:foreground "LawnGreen"))) #("green                    #0000ffff0000              " 0 25 (result "green") 25 40 (face (:foreground "green")) 40 50 (face (:background "green")) 50 52 (face (:foreground "green"))) #("SpringGreen              #0000ffff7f7f              spring green" 0 25 (result "SpringGreen") 25 40 (face (:foreground "SpringGreen")) 40 50 (face (:background "SpringGreen")) 50 64 (face (:foreground "SpringGreen"))) #("MediumSpringGreen        #0000fafa9a9a              medium spring green" 0 25 (result "MediumSpringGreen") 25 40 (face (:foreground "MediumSpringGreen")) 40 50 (face (:background "MediumSpringGreen")) 50 71 (face (:foreground "MediumSpringGreen"))) #("cyan                     #0000ffffffff              " 0 25 (result "cyan") 25 40 (face (:foreground "cyan")) 40 50 (face (:background "cyan")) 50 52 (face (:foreground "cyan"))) #("DeepSkyBlue              #0000bfbfffff              deep sky blue" 0 25 (result "DeepSkyBlue") 25 40 (face (:foreground "DeepSkyBlue")) 40 50 (face (:background "DeepSkyBlue")) 50 65 (face (:foreground "DeepSkyBlue"))) #("blue                     #00000000ffff              " 0 25 (result "blue") 25 40 (face (:foreground "blue")) 40 50 (face (:background "blue")) 50 52 (face (:foreground "blue"))) #("MediumBlue               #00000000cdcd              medium blue" 0 25 (result "MediumBlue") 25 40 (face (:foreground "MediumBlue")) 40 50 (face (:background "MediumBlue")) 50 63 (face (:foreground "MediumBlue"))) #("DarkViolet               #94940000d3d3              dark violet" 0 25 (result "DarkViolet") 25 40 (face (:foreground "DarkViolet")) 40 50 (face (:background "DarkViolet")) 50 63 (face (:foreground "DarkViolet"))) #("DarkMagenta              #8b8b00008b8b              dark magenta" 0 25 (result "DarkMagenta") 25 40 (face (:foreground "DarkMagenta")) 40 50 (face (:background "DarkMagenta")) 50 64 (face (:foreground "DarkMagenta"))) #("magenta                  #ffff0000ffff              " 0 25 (result "magenta") 25 40 (face (:foreground "magenta")) 40 50 (face (:background "magenta")) 50 52 (face (:foreground "magenta"))) #("DarkRed                  #8b8b00000000              dark red" 0 25 (result "DarkRed") 25 40 (face (:foreground "DarkRed")) 40 50 (face (:background "DarkRed")) 50 60 (face (:foreground "DarkRed"))) #("brown                    #a5a52a2a2a2a              " 0 25 (result "brown") 25 40 (face (:foreground "brown")) 40 50 (face (:background "brown")) 50 52 (face (:foreground "brown"))) #("firebrick                #b2b222222222              " 0 25 (result "firebrick") 25 40 (face (:foreground "firebrick")) 40 50 (face (:background "firebrick")) 50 52 (face (:foreground "firebrick"))) #("IndianRed                #cdcd5c5c5c5c              indian red" 0 25 (result "IndianRed") 25 40 (face (:foreground "IndianRed")) 40 50 (face (:background "IndianRed")) 50 62 (face (:foreground "IndianRed"))) #("LightCoral               #f0f080808080              light coral" 0 25 (result "LightCoral") 25 40 (face (:foreground "LightCoral")) 40 50 (face (:background "LightCoral")) 50 63 (face (:foreground "LightCoral"))) #("salmon                   #fafa80807272              " 0 25 (result "salmon") 25 40 (face (:foreground "salmon")) 40 50 (face (:background "salmon")) 50 52 (face (:foreground "salmon"))) #("LightSalmon              #ffffa0a07a7a              light salmon" 0 25 (result "LightSalmon") 25 40 (face (:foreground "LightSalmon")) 40 50 (face (:background "LightSalmon")) 50 64 (face (:foreground "LightSalmon"))) #("tomato                   #ffff63634747              " 0 25 (result "tomato") 25 40 (face (:foreground "tomato")) 40 50 (face (:background "tomato")) 50 52 (face (:foreground "tomato"))) #("coral                    #ffff7f7f5050              " 0 25 (result "coral") 25 40 (face (:foreground "coral")) 40 50 (face (:background "coral")) 50 52 (face (:foreground "coral"))) #("DarkSalmon               #e9e996967a7a              dark salmon" 0 25 (result "DarkSalmon") 25 40 (face (:foreground "DarkSalmon")) 40 50 (face (:background "DarkSalmon")) 50 63 (face (:foreground "DarkSalmon"))) #("RosyBrown                #bcbc8f8f8f8f              rosy brown" 0 25 (result "RosyBrown") 25 40 (face (:foreground "RosyBrown")) 40 50 (face (:background "RosyBrown")) 50 62 (face (:foreground "RosyBrown"))) #("sienna                   #a0a052522d2d              " 0 25 (result "sienna") 25 40 (face (:foreground "sienna")) 40 50 (face (:background "sienna")) 50 52 (face (:foreground "sienna"))) #("SaddleBrown              #8b8b45451313              saddle brown" 0 25 (result "SaddleBrown") 25 40 (face (:foreground "SaddleBrown")) 40 50 (face (:background "SaddleBrown")) 50 64 (face (:foreground "SaddleBrown"))) #("chocolate                #d2d269691e1e              " 0 25 (result "chocolate") 25 40 (face (:foreground "chocolate")) 40 50 (face (:background "chocolate")) 50 52 (face (:foreground "chocolate"))) #("peru                     #cdcd85853f3f              " 0 25 (result "peru") 25 40 (face (:foreground "peru")) 40 50 (face (:background "peru")) 50 52 (face (:foreground "peru"))) #("SandyBrown               #f4f4a4a46060              sandy brown" 0 25 (result "SandyBrown") 25 40 (face (:foreground "SandyBrown")) 40 50 (face (:background "SandyBrown")) 50 63 (face (:foreground "SandyBrown"))) #("burlywood                #dedeb8b88787              " 0 25 (result "burlywood") 25 40 (face (:foreground "burlywood")) 40 50 (face (:background "burlywood")) 50 52 (face (:foreground "burlywood"))) #("tan                      #d2d2b4b48c8c              " 0 25 (result "tan") 25 40 (face (:foreground "tan")) 40 50 (face (:background "tan")) 50 52 (face (:foreground "tan"))) #("NavajoWhite              #ffffdedeadad              navajo white" 0 25 (result "NavajoWhite") 25 40 (face (:foreground "NavajoWhite")) 40 50 (face (:background "NavajoWhite")) 50 64 (face (:foreground "NavajoWhite"))) #("wheat                    #f5f5dedeb3b3              " 0 25 (result "wheat") 25 40 (face (:foreground "wheat")) 40 50 (face (:background "wheat")) 50 52 (face (:foreground "wheat"))) #("DarkGoldenrod            #b8b886860b0b              dark goldenrod" 0 25 (result "DarkGoldenrod") 25 40 (face (:foreground "DarkGoldenrod")) 40 50 (face (:background "DarkGoldenrod")) 50 66 (face (:foreground "DarkGoldenrod"))) #("goldenrod                #dadaa5a52020              " 0 25 (result "goldenrod") 25 40 (face (:foreground "goldenrod")) 40 50 (face (:background "goldenrod")) 50 52 (face (:foreground "goldenrod"))) #("LightGoldenrod           #eeeedddd8282              light goldenrod" 0 25 (result "LightGoldenrod") 25 40 (face (:foreground "LightGoldenrod")) 40 50 (face (:background "LightGoldenrod")) 50 67 (face (:foreground "LightGoldenrod"))) #("PaleGoldenrod            #eeeee8e8aaaa              pale goldenrod" 0 25 (result "PaleGoldenrod") 25 40 (face (:foreground "PaleGoldenrod")) 40 50 (face (:background "PaleGoldenrod")) 50 66 (face (:foreground "PaleGoldenrod"))) ...) :require-match t :update-fn #[0 "\302�\303H	>\204�\304\305\306�D\"\210�\307H!\207" [ivy-last cl-struct-ivy-state-tags counsel-colors--update-highlight 0 signal wrong-type-argument ivy-state 23] 5] :action counsel-colors-action-insert-name :history counsel-colors-emacs-history :caller counsel-colors-emacs :sort nil)
  counsel-colors-emacs()
  funcall-interactively(counsel-colors-emacs)
  call-interactively(counsel-colors-emacs nil nil)
  command-execute(counsel-colors-emacs)

I'm not going to reopen this issue, because the bug isn't there with a fresh .emacs.d, But it would be nice if you had a hint for me.

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Mar 28, 2017

Looks like you have "000000" registered as a color, although the proper name for it is "#000000".

(color-name-to-rgb "000000")
;; => nil
(color-name-to-rgb "#000000")
;; =>
;; (0.0 0.0 0.0)

Look through your init to find the code that registers "000000" as a color.

I can add a work-around that returns the same color in case there is an error.

abo-abo added a commit that referenced this issue Mar 28, 2017

counsel.el (counsel-colors--best-contrast-color): Return same color o…
…n error

In case `color-name-to-rgb' returns nil.

Re #921
@Dickby

This comment has been minimized.

Copy link
Author

commented Mar 28, 2017

Thanks.

@Dickby

This comment has been minimized.

Copy link
Author

commented Aug 24, 2017

Looking in this problem again, I found a few things:

counsel-color--name-to-hex returns 12-digit colors.
Because of that, counsel-colors--update-highlight picks the wrong substring.
color-rgb-to-hex has an optional argument to choose the number of hex-digits per color.
This could be used to fix the problem:

(defun counsel-colors--name-to-hex (color)
  (let ((rgb (color-name-to-rgb color)))
    (color-rgb-to-hex (nth 0 rgb) (nth 1 rgb)(nth 2 rgb) 2)))

Another problem is the foreground color of ivy-current-match in counsel-colors-emacs:

for choosing this foreground color counsel-colors--update-highlight uses
counsel-colors--best-contrast-color which returns "#FFFFFF" or "#000000" depending on the background color, to keep the text readable.

This returned color only works if the initial foreground-color of ivy-current-match is set to nil.
Otherwise the foreground color doesn't change.

@Dickby Dickby reopened this Aug 24, 2017

basil-conto added a commit to basil-conto/swiper that referenced this issue Feb 7, 2018

counsel.el: Fix and improve counsel-colors-*
(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.
@basil-conto

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2018

@Dickby Can you please check whether #1436 fixes the issue for you?

@Dickby

This comment has been minimized.

Copy link
Author

commented Feb 7, 2018

Is not fixed on my emacs.

@basil-conto

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2018

@Dickby Please provide more information; your message doesn't give much to work with.

@Dickby

This comment has been minimized.

Copy link
Author

commented Feb 7, 2018

Now that the new counsel hit melpa, it is working. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.