[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#51715: defface forms not having dynamic value
From: |
irenezerafa |
Subject: |
bug#51715: defface forms not having dynamic value |
Date: |
Tue, 09 Nov 2021 15:36:43 +0000 |
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, November 9th, 2021 at 3:00 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Tue, 09 Nov 2021 14:17:03 +0000
> >
> > From: irenezerafa irenezerafa@protonmail.com
> >
> > Cc: 51715@debbugs.gnu.org
> >
> > > Please tell more. Which face attributes did you want to make dynamic,
> > > and how?
> >
> > I take rainbow-delimiters as example. Specifically, the
> >
> > (eval-when-compile
> >
> > (defmacro rainbow-delimiters--define-depth-faces ()
> > (let ( (faces '())
> > (dark-colors [ "#ff62d4" "#3fdfd0" "#fba849" "#9f80ff"
> > "#4fe42f" "#fe6060" "#4fafff" "#f0dd60" "#ffffff" ])
> > (light-colors [ "#a8007f" "#005f88" "#904200" "#7f10d0"
> > "#006800" "#b60000" "#1f1fce" "#605b00" "#000000"]) )
> >
> > (dotimes (i 9)
> > (push `( defface ,(intern (format "rainbow-delimiters-depth-%d-face" (1+
> > i))) '( (default (:inherit rainbow-delimiters-base-face)) ( ((class color)
> > (background dark)) :foreground ,(aref dark-colors i)) ( ((class color)
> > (background light)) :foreground ,(aref light-colors i)) ) ,(format "Nested
> > delimiter face, depth %d." (1+ i)) :group 'rainbow-delimiters-faces )
> > faces))` (progn ,@faces)) ))
> >
> > (rainbow-delimiters--define-depth-faces)
> >
> > Now, suppose I want to use a colour scheme from modus-themes.
> >
> > (require 'modus-themes)
> >
> > (eval-when-compile
> > (defmacro rainbow-delimiters--define-depth-faces ()
> > (let ( (faces '())
> > (dark-colors (rainbow-delimiters-modus-vivendi-intense-colours
> > (list magenta-intense cyan-intense orange-intense
> > purple-intense green-intense red-intense
> > blue-intense yellow-intense fg-main)))
> > (light-colors (rainbow-delimiters-modus-operandi-intense-colours
> > (list magenta-intense cyan-intense orange-intense
> > purple-intense green-intense red-intense
> > blue-intense yellow-intense fg-main))) )
> > (dotimes (i 9)
> > (push `(defface ,(intern (format "rainbow-delimiters-depth-%d-face" (1+
> > i))) '( (default (:inherit rainbow-delimiters-base-face)) ( ((class color)
> > (background light)) :foreground ,(nth i light-colors)) ( ((class color)
> > (background dark)) :foreground ,(nth i dark-colors)) ) ,(format "Nested
> > delimiter face, depth %d." (1+ i)) :group 'rainbow-delimiters-faces)
> > faces))` (progn ,@faces)) ))
> >
> > This would not be workable in practice. Because the dependency only
> > matters when your macro is being evaluated and the faces are reified.
> > Since you have a package, that will be the moment the package gets
> > required. So you are making it a dependency for everyone.
> I'm still not sure I get this. You want to be able to control the
> colors of a face indirectly, by changing some variable which the face
> references? If not, what do you mean by "the dependency"?
> IOW, what is it that you want to be able to do that isn't possible by
> calling set-face-attribute?
I would like to require modus-themes (and get the list of intense colours frem
there
as defined) if modus-themes is being used. Otherwise, get the
rainbow-delimiters
package to set the face attributes directly (by hex values) using aref.
One could have a flag before calling (require 'rainbow-delimiters), which the
package
could pick up. That could work at runtime. But not at compile time, a
situation that
users are likely going to get (the compiled form) to install the package.
- bug#51715: defface forms not having dynamic value, irenezerafa, 2021/11/09
- bug#51715: defface forms not having dynamic value, Eli Zaretskii, 2021/11/09
- bug#51715: defface forms not having dynamic value, irenezerafa, 2021/11/09
- bug#51715: defface forms not having dynamic value, Lars Ingebrigtsen, 2021/11/09
- bug#51715: defface forms not having dynamic value, Stefan Kangas, 2021/11/10
- bug#51715: defface forms not having dynamic value, Eli Zaretskii, 2021/11/10
- bug#51715: defface forms not having dynamic value, Lars Ingebrigtsen, 2021/11/13