jdtsmith / indent-bars

Fast, configurable indentation guide-bars for Emacs
GNU General Public License v3.0
359 stars 14 forks source link

Issue with indent-bars-reset-styles with tty-color-mode 'no #81

Closed shipmints closed 2 days ago

shipmints commented 2 days ago

This isn't urgent but might highlight something work fixing for other cases.

I've been experimenting with making themes work better in tty. This issue recurs when

(set-frame-parameter nil 'tty-color-mode 'no)

but is fine otherwise.

Debugger entered--Lisp error: (wrong-number-of-arguments (3 . 4) 0)
  color-rgb-to-hex()
  apply(color-rgb-to-hex nil)
  indent-bars--blend-colors("unspecified-bg" "black" 0.325)
  indent-bars--main-color(#s(indent-bars-style :tag nil :main-color "#533200000000" :depth-palette nil :faces [indent-bars-1 indent-bars-2 indent-bars-3 indent-bars-4 indent-bars-5 indent-bars-6 indent-bars-7] :stipple-face indent-bars-face :no-stipple-chars [#("│" 0 1 (face indent-bars-1)) #("│" 0 1 (face indent-bars-2)) #("│" 0 1 (face indent-bars-3)) #("│" 0 1 (face indent-bars-4)) #("│" 0 1 (face indent-bars-5)) #("│" 0 1 (face indent-bars-6)) #("│" 0 1 (face indent-bars-7))] :current-stipple-face nil :current-bg-color nil :current-depth-palette "#ffff66666666"))
  indent-bars--initialize-style(#s(indent-bars-style :tag nil :main-color "#533200000000" :depth-palette nil :faces [indent-bars-1 indent-bars-2 indent-bars-3 indent-bars-4 indent-bars-5 indent-bars-6 indent-bars-7] :stipple-face indent-bars-face :no-stipple-chars [#("│" 0 1 (face indent-bars-1)) #("│" 0 1 (face indent-bars-2)) #("│" 0 1 (face indent-bars-3)) #("│" 0 1 (face indent-bars-4)) #("│" 0 1 (face indent-bars-5)) #("│" 0 1 (face indent-bars-6)) #("│" 0 1 (face indent-bars-7))] :current-stipple-face nil :current-bg-color nil :current-depth-palette "#ffff66666666"))
  mapc(indent-bars--initialize-style (#s(indent-bars-style :tag nil :main-color "#533200000000" :depth-palette nil :faces [indent-bars-1 indent-bars-2 indent-bars-3 indent-bars-4 indent-bars-5 indent-bars-6 indent-bars-7] :stipple-face indent-bars-face :no-stipple-chars [#("│" 0 1 (face indent-bars-1)) #("│" 0 1 (face indent-bars-2)) #("│" 0 1 (face indent-bars-3)) #("│" 0 1 (face indent-bars-4)) #("│" 0 1 (face indent-bars-5)) #("│" 0 1 (face indent-bars-6)) #("│" 0 1 (face indent-bars-7))] :current-stipple-face nil :current-bg-color nil :current-depth-palette "#ffff66666666")))
  indent-bars-reset-styles(user)
  run-hook-with-args(indent-bars-reset-styles user)
  enable-theme(user)
  enable-theme(modus-operandi)
jdtsmith commented 2 days ago

I'm not seeing this. What does M-: (indent-bars--style (car indent-bars--styles) "color") tell you? Somehow you have configured the main color custom var to something which has no defined color. If it mentions highlight, what does M-: (face-background 'highlight) give?

jdtsmith commented 2 days ago

For me with tty-color-mode=no, highlight background is all black.

shipmints commented 2 days ago

(indent-bars--style (car indent-bars--styles) "color") yields (highlight :face-bg t :blend 0.325)

(face-background 'highlight) yields nil

The theme is latest ELPA modus-vivendi (dark) and switching to modus-operanti (light) is what triggers the issue. Perhaps Prot hasn't tested with tty-color-mode.

jdtsmith commented 2 days ago

Hmm, that's actually the value of the default face in the default theme too. I pushed a new change which guards against the foreground/background color default color being unspecified, give a try and see if that fixes this.

jdtsmith commented 2 days ago

This language from the elisp manual is confusing:

The ‘default’ face must explicitly specify all attributes, and cannot use the special value ‘reset’.

But it can and does use "unspecified-" colors on TTY. See also Emacs bug#55623 and alphapapa/ement.el#34.

shipmints commented 2 days ago

That is good defense.

Hah, it's always something, these rabbit holes... Now, it's @alphapapa's prism. But, it could be my own color setter that needs to first check. Nope, I disabled my color selector which runs post-theme and still prism not happy even if I set prism-num-faces to 1.

Debugger entered--Lisp error: (cl-assertion-failed (colors "No non-unspecified colors remain of %s"))
  cl--assertion-failed(colors "No non-unspecified colors remain of %s" nil ((font-lock-type-face font-lock-function-name-face font-lock-keyword-face font-lock-doc-face)))
  prism-set-colors()
  prism-after-theme(modus-operandi :no-confirm)
  apply(prism-after-theme (modus-operandi :no-confirm))
  load-theme(modus-operandi :no-confirm)
  modus-themes-load-theme(modus-operandi)
  modus-themes-toggle()
jdtsmith commented 2 days ago

Yeah. So looks like the defense is working for indent-bars. I already had variables in place to allow users to specify "this the actual fg/bg color on terminal" so not such a big deal to utilize. There should probably be variables like this emacs-wide.

alphapapa commented 2 days ago

That is good defense.

Hah, it's always something, these rabbit holes... Now, it's @alphapapa's prism. But, it could be my own color setter that needs to first check. Nope, I disabled my color selector which runs post-theme and still prism not happy even if I set prism-num-faces to 1.

Debugger entered--Lisp error: (cl-assertion-failed (colors "No non-unspecified colors remain of %s"))
  cl--assertion-failed(colors "No non-unspecified colors remain of %s" nil ((font-lock-type-face font-lock-function-name-face font-lock-keyword-face font-lock-doc-face)))
  prism-set-colors()
  prism-after-theme(modus-operandi :no-confirm)
  apply(prism-after-theme (modus-operandi :no-confirm))
  load-theme(modus-operandi :no-confirm)
  modus-themes-load-theme(modus-operandi)
  modus-themes-toggle()

That's weird. See https://github.com/alphapapa/prism.el/commit/4549c84f72feb3a7aa7a5df7202cdfb5d9c729a4

shipmints commented 1 day ago

Not sure. As this is a low-priority edge-case, I'm going to not use monochrome tty. It doesn't work well and I suspect I need an old-timey vt100 terminal to use it. So take this as an FYI in case it comes up for this case or something similar.

alphapapa commented 1 day ago

monochrome tty

Oh, I think that explains it.

shipmints commented 22 hours ago

Shades of gray are colors, too, I suppose.