help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use variable in setcustom


From: Yuri Khan
Subject: Re: Use variable in setcustom
Date: Thu, 14 Nov 2019 17:09:19 +0700

On Sun, 10 Nov 2019 at 09:31, Ergus <spacibba@aol.com> wrote:
>
> Hi I want to have a simple colour palette that must be compatible with
> tui and gui.

The practical solution to that is to use a (stack of) terminal
emulator(s) that supports 24-bit colors.

> The problem is that the color names are not the same so for example the
> brightblack are not available in gui only in tui.
>
> To work around this I made:
>
> ```
> (defconst my/colors '((black . "#000000")
>                       (red . "#cd0000")
>                        ...
>                        (brightcyan . "#00ffff")
>                       (brightwhite . "#ffffff"))
>    "List of colors.")
> ```
>
> And then I assign the colors with something like:
>
> ```
> (set-face-foreground 'font-lock-preprocessor-face (cdr (assq 'magenta
> my/colors)))
> ```
>
> But if I try to use a better method for my colors as Stefan suggested:
>
> (custom-set-face ...)
>
> It doesn't work. Do we have some method to define colours or paletes?

Custom themes. Which are arbitrary Elisp code and can thus define and
use variables:

    (defconst yk-scarletred "#ef2929")

    (custom-theme-set-faces 'yk-dark-theme
      …
      `(yk-incorrect
        ((((type graphic)) . (:underline (:color ,yk-scarletred :style wave)))
         (((min-colors 16777216)) . (:foreground ,yk-scarletred :underline t))))
      `(trailing-whitespace ((default . (:inherit yk-incorrect))))
      …)

    (provide-theme 'yk-dark-theme)

You can use anti-quoted variables or expressions with custom-set-face,
too (I just think themes are cleaner):

    (custom-set-faces
     `(font-lock-preprocessor-face
       ((default :foreground ,(cdr (assq 'magenta my/colors))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]