nashamri / spacemacs-theme

Light and dark theme for spacemacs that supports GUI and terminal
GNU General Public License v3.0
605 stars 113 forks source link

spacemacs-theme-custom-colors+variable => wrong-type-argument (emacs 26.2) #149

Open tdd11235813 opened 5 years ago

tdd11235813 commented 5 years ago

As of emacs 26.2 an association list combined with an if-condition fails where the face is defined. The error is:

Debugger entered--Lisp error: (wrong-type-argument stringp (if (eq alternative (quote dark)) "#101010" "#b2b2b2"))
  internal-set-lisp-face-attribute(cursor :background (if (eq alternative (quote dark)) "#101010" "#b2b2b2") #<frame emacs@Mammatus 0x1221c30>)
  set-face-attribute(cursor #<frame emacs@Mammatus 0x1221c30> :background (if (eq alternative (quote dark)) "#101010" "#b2b2b2"))
  apply(set-face-attribute cursor #<frame emacs@Mammatus 0x1221c30> (:background (if (eq alternative (quote dark)) "#101010" "#b2b2b2")))
  face-spec-set-2(cursor #<frame emacs@Mammatus 0x1221c30> (:background (if (eq alternative (quote dark)) "#101010" "#b2b2b2")))
  face-spec-recalc(cursor #<frame emacs@Mammatus 0x1221c30>)
  custom-theme-recalc-face(cursor)
  enable-theme(spacemacs-dark)
  load-theme(spacemacs-dark t)
<snip>

The init.el configuration with spacemacs-common:

(setq debug-on-error t)
(setq alternative 'dark)
(setq spacemacs-theme-custom-colors
        '(
          (cursor . (if (eq alternative 'dark) "#101010" "#b2b2b2"))
          ))
(require 'spacemacs-common)
(load-theme 'spacemacs-dark t)

It seems it just expects a string, because a simple variable will now fail too:

(setq testcolor "#ff0000")
(setq spacemacs-theme-custom-colors
      '(
        (cursor . testcolor)
        ))
;; => wrong-type-argument stringp testcolor

I need the condition expression in the face to interactively switch theme settings. However, I am already trying to find other ways how to overload your theme as part of a new theme without redefining everything (while using heaven-and-hell package for switching). Alas, my lisp skill is close to zero and it seems I have to duplicate code to make it work again (no face-defs with if-conditions).

back to issue: It comes with a change in emacs 26.2 backend (<26.2 worked), but could not find a thing in changelog) and on emacs github (files of face functions have not been touched since 2018).

Update: it is not emacs, but the dyn-let change in spacemacs-common.el from #144

tdd11235813 commented 5 years ago

Referring to issue #139: The related PR #144 is the issue, because it was working before the change for me. Additionally, it seems that not every variable becomes overwritten now. For instance, the color for var cannot be overwritten after that change. I replaced the spacemacs-common.el with the older version, where dyn-let was used. Here, everything the variable-thing works again. So why the behavior here is the opposite to what @jjzmajic and @noctuid have seen?

PS:

;; just for testing which color is set
(custom-set-variables '(spacemacs-theme-custom-colors
      '(                                             
        (str . "#ff0000")                            
        (act1 . "#ff0000")                           
        (act2 . "#ff0000")                           
        (lnum . "#ff0000")                           
        (highlight . "#ff0000")                      
        (green-bg-s . "#ff0000") ; for lazy highlight
        (bg1 . "#ff0000")                            
        (keyword . "#ff0000")                        
        (const . "#ff0000")                          
        (type . "#ff0000")                           
        (var . "#ff0000")                            
        (func . "#ff0000")                           
        (base . "#ff0000")                           
        (base-dim . "#ff0000")                       
        (comment . "#ff0000")                        
        )))                                          
(load-theme 'spacemacs-dark t)                       

Edit: the dyn-let version still might have issues. When I try to use it within another theme, custom colors are mostly not applied, have to play around later. Btw, versions I compared: spacemacs-theme-20181107.1725 vs spacemacs-theme-20190617.633.

tdd11235813 commented 5 years ago

I have prepared a minimal example:

git clone --single-branch --branch test-space-theme https://github.com/tdd11235813/emacs_config.git
emacs -l emacs_config/init.el

UPDATE: Do NOT use -l emacs_config/init.el, this messes up emacs init process.

See git log and the commentary in init.el header. There are three four commits. First commit tests just custom theming with spacemacs-theme. Second one tests the variable issue. Third commit tests combination with heaven-and-hell theme switcher (related heaven-and-hell issue). Fourth commit shows the current solution for heaven-and-hell combination and customized spacemacs-theme as an own theme, wherein setq is used instead of custom-set-variables.

I have also checked a newer dyn-let version, namely spacemacs-theme-20190116.2107, which also showed the same effect.

tdd11235813 commented 5 years ago

I have updated the minimal example branch. The combination with heaven-and-hell is also resolved. Using variables within is still not possible.

git clone --single-branch --branch test-space-theme https://github.com/tdd11235813/emacs_config.git $HOME/.emacs.d
cd $HOME/.emacs.d
git checkout HEAD~2 # to test the variable issue
emacs # error => set-face-attribute: Wrong type argument: stringp, my-var
nashamri commented 5 years ago

Thanks @tdd11235813 for investigate this issue. I'm travelling currently, I'll look into it when I get back.