all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: irenezerafa <irenezerafa@protonmail.com>
Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Using variables instead of hex values
Date: Mon, 8 Nov 2021 19:47:49 +0300	[thread overview]
Message-ID: <YYlUtac47WLeFpOs@protected.localdomain> (raw)
In-Reply-To: <R4oenL21adlC6DlR70eSr19TJLE9IvZurdsl_b3p5G2v4n35VQl0ZLdTeHxbf05ppyuQb82bON3NYtCGwUAh9bkRTQBHOvwxlvmjQMfD50k=@protonmail.com>

* irenezerafa via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-11-08 11:05]:
> I have the following piece of code and would like to use variable names instead of
> using hex values directly.
> 
> (eval-when-compile
> (defmacro rich-faces ()
> (let ( (faces '())
> (light-colors [ "#a8007f" "#005f88" "#904200" "#7f10d0"
> "#006800" "#b60000" "#1f1fce" "#605b00" "#000000"])
> (dark-colors [ "#ff62d4" "#3fdfd0" "#fba849" "#9f80ff"
> "#4fe42f" "#fe6060" "#4fafff" "#f0dd60" "#ffffff" ]) )

(color-name-to-rgb "white") ⇒ (1.0 1.0 1.0)
(color-rgb-to-hex 1.0 1.0 1.0) ⇒ "#ffffffffffff"

(defun my-color-name (color)
  (apply 'color-rgb-to-hex (color-name-to-rgb color)))

(my-color-name "white") ⇒ "#ffffffffffff"
(my-color-name "red") ⇒ "#ffff00000000"
		  		  

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



  reply	other threads:[~2021-11-08 16:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08  8:00 Using variables instead of hex values irenezerafa via Users list for the GNU Emacs text editor
2021-11-08 16:47 ` Jean Louis [this message]
2021-11-09  9:46   ` Jean Louis

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

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

  git send-email \
    --in-reply-to=YYlUtac47WLeFpOs@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=irenezerafa@protonmail.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.