jdtsmith / kind-icon

Completion kind text/icon prefix labelling for emacs in-region completion
GNU Affero General Public License v3.0
174 stars 4 forks source link

Handle faces with named colors instead of hex when blending #12

Closed ghost closed 2 years ago

ghost commented 2 years ago

The title is a little bit of a guess, but when I tried out motform/stimmung-themes, which uses named colors (like "gray12") for faces Corfu began breaking. I don't get a backtrace with toggle-debug-on-error, but no completions appear and this message is echoed:

Error in post-command-hook (corfu--post-command): (wrong-number-of-arguments #<subr color-rgb-to-hex> 0)

The error does not occur on every completion. For instance pressing tab after (set-face-attr| works, but pressing tab after (set-face-attribute 'ta| results in the error.

(setq kind-icon-blend-background nil) causes completions to work as normal.

I reproduced the issue with the below minimal init file on Emacs 28.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4) of 2022-02-24"

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'corfu)
(straight-use-package 'kind-icon)
(straight-use-package 'stimmung-themes)

(setq tab-always-indent 'complete)
(require 'corfu)
(require 'kind-icon)

(setq kind-icon-face 'corfu-default)
(corfu-global-mode)
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)

(load-theme 'stimmung-themes-dark t)
jdtsmith commented 2 years ago

I just tried stimmung theme and had no issues with it (other than there's no real color discrimination between kinds). I would recommend you turn off kind-icon-blend-background, since there's not much point blending the same foreground color for different kinds. If you set this outside customize you'll need to M-x kind-icon-reset-cache.

Backtraces are inhibited in post command hooks by default; see the new debug advice at the bottom of the README.

ghost commented 2 years ago

Backtraces are inhibited in post command hooks by default; see the new debug advice at the bottom of the README.

Ah, in that case:

Debugger entered--Lisp error: (wrong-number-of-arguments #<subr color-rgb-to-hex> 0)
  color-rgb-to-hex()
  kind-icon-formatted(text)
  #f(compiled-function (cand) #<bytecode -0x19d9e310d2f64515>)(#("tab" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))))
  corfu--affixate((#("tab" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("tan" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("tar" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("talk" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("table" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("tabify" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("tab-bar" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("tab-new" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("tab-last" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference))) #("tab-line" 0 2 (face (completions-common-part)) 2 3 (face (completions-first-difference)))))
  corfu--candidates-popup(#<marker at 810 in init.el>)
  corfu--update()
  #<subr corfu--post-command>()
  funcall(#<subr corfu--post-command>)
  (condition-case err (funcall func) ((debug error) (signal (car err) (cdr err))))
  (lambda (func) (condition-case err (funcall func) ((debug error) (signal (car err) (cdr err)))))(#<subr corfu--post-command>)
  apply((lambda (func) (condition-case err (funcall func) ((debug error) (signal (car err) (cdr err))))) #<subr corfu--post-command> nil)
  corfu--post-command()
jdtsmith commented 2 years ago

It seems there must be some color misconfigured in the theme for a particular candidate kind that's not showing up for me. Can you M-x trace-function color-name-to-rgb, trigger the problematic completion, and check the *trace-output* buffer for problematic return values (like nil)? Return values should be a list of 3 floating numbers (red green blue).

jdtsmith commented 2 years ago

Do you still have this problem @dm19 ?

jdtsmith commented 2 years ago

Closing for now; let me know if you continue to have this issue.