unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: Ergus <spacibba@aol.com>
Cc: Ergus via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Use variable in setcustom
Date: Thu, 14 Nov 2019 17:09:19 +0700	[thread overview]
Message-ID: <CAP_d_8WVxPMQmYcmZeX3qA_GeytbRbNQj2qVMWDkaz=aZohJ7g@mail.gmail.com> (raw)
In-Reply-To: <20191110023036.r2gsq6znmykbol7q@Ergus>

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))))))



  parent reply	other threads:[~2019-11-14 10:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191110023036.r2gsq6znmykbol7q.ref@Ergus>
2019-11-10  2:30 ` Use variable in setcustom Ergus
2019-11-14  9:24   ` Eli Zaretskii
2019-11-14 10:09   ` Yuri Khan [this message]
2019-11-15  1:19     ` [OFFTOPIC] " VanL

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8WVxPMQmYcmZeX3qA_GeytbRbNQj2qVMWDkaz=aZohJ7g@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=spacibba@aol.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).