* Setting colour for comments for light and dark theme
@ 2022-02-01 9:38 goncholden via Users list for the GNU Emacs text editor
2022-02-01 10:34 ` Manuel Giraud
0 siblings, 1 reply; 5+ messages in thread
From: goncholden via Users list for the GNU Emacs text editor @ 2022-02-01 9:38 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Have been using the following code to change the colour of comments according
to whether I have a dark or light background. I am using modus-themes. But these
few days I needed to disable modus-themes when debugging and the code breaks
because there are no instructions for when modus-themes is disabled.
(defvar annotation-chroma
'( (dark . ((low . "#8300E0") (mid . "#AA33FF") (high . "#C370FF")))
(light . ((low . "#C16BFF") (mid . "#AA33FF") (high . "#8000DB"))) )
"Colour contrast for comments, indigo on dark and light background.")
(defun annotation-typeface (chroma)
"Set the foreground colour for comments.
CHROMA Intensity Key used for setting colour of comments ."
(let* ( (colors annotation-chroma)
(levels
(pcase (car custom-enabled-themes)
('modus-operandi (alist-get 'light colors))
('modus-vivendi (alist-get 'dark colors)))) )
(face-remap-add-relative 'font-lock-comment-face
`(:foreground ,(alist-get chroma levels))) ) )
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Setting colour for comments for light and dark theme
2022-02-01 9:38 Setting colour for comments for light and dark theme goncholden via Users list for the GNU Emacs text editor
@ 2022-02-01 10:34 ` Manuel Giraud
2022-02-01 11:28 ` goncholden
0 siblings, 1 reply; 5+ messages in thread
From: Manuel Giraud @ 2022-02-01 10:34 UTC (permalink / raw)
To: goncholden via Users list for the GNU Emacs text editor; +Cc: goncholden
Hi,
Maybe you need a default match. Watch out untested code ahead:
--8<---------------cut here---------------start------------->8---
(defvar annotation-chroma
'((dark . ((low . "#8300E0") (mid . "#AA33FF") (high . "#C370FF")))
(light . ((low . "#C16BFF") (mid . "#AA33FF") (high . "#8000DB")))
(default . ((low . "red") (mid . "green") (high . "blue"))))
"Colour contrast for comments, indigo on dark and light background.")
(defun annotation-typeface (chroma)
"Set the foreground colour for comments.
CHROMA Intensity Key used for setting colour of comments."
(let* ((colors annotation-chroma)
(levels
(pcase (car custom-enabled-themes)
('modus-operandi (alist-get 'light colors))
('modus-vivendi (alist-get 'dark colors))
(_ (alist-get 'default colors)))))
(face-remap-add-relative 'font-lock-comment-face
`(:foreground ,(alist-get chroma levels)))))
--8<---------------cut here---------------end--------------->8---
--
Manuel Giraud
^ permalink raw reply [flat|nested] 5+ messages in thread
* Setting colour for comments for light and dark theme
2022-02-01 10:34 ` Manuel Giraud
@ 2022-02-01 11:28 ` goncholden
2022-02-01 12:35 ` goncholden
2022-02-03 2:13 ` Michael Heerdegen
0 siblings, 2 replies; 5+ messages in thread
From: goncholden @ 2022-02-01 11:28 UTC (permalink / raw)
To: Manuel Giraud; +Cc: goncholden via Users list for the GNU Emacs text editor
On Tuesday, February 1st, 2022 at 10:34 AM, Manuel Giraud <manuel@ledu-giraud.fr> wrote:
> Hi,
>
> Maybe you need a default match. Watch out untested code ahead:
>
> --8<---------------cut here---------------start------------->8---
>
> (defvar annotation-chroma
>
> '((dark . ((low . "#8300E0") (mid . "#AA33FF") (high . "#C370FF")))
>
> (light . ((low . "#C16BFF") (mid . "#AA33FF") (high . "#8000DB")))
>
> (default . ((low . "red") (mid . "green") (high . "blue"))))
>
> "Colour contrast for comments, indigo on dark and light background.")
>
> (defun annotation-typeface (chroma)
>
> "Set the foreground colour for comments.
>
> CHROMA Intensity Key used for setting colour of comments."
>
> (let* ((colors annotation-chroma)
>
> (levels
>
> (pcase (car custom-enabled-themes)
>
> ('modus-operandi (alist-get 'light colors))
>
> ('modus-vivendi (alist-get 'dark colors))
>
> (_ (alist-get 'default colors)))))
>
> (face-remap-add-relative 'font-lock-comment-face
>
> `(:foreground ,(alist-get chroma levels)))))
>
> --8<---------------cut here---------------end--------------->8---
I wonder if there is any way that colours change whether one is using a light or dark theme. Is the light and dark setting inherent to emacs, or inherent to the theme? For instance the default can still check if the theme uses a light or dark background. Better still, the annotation colours could be set up for light and dark background irrespective of the particular instance of modus-themes. Meaning that the colours are set for any theme one could be using.
> --
>
> Manuel Giraud
^ permalink raw reply [flat|nested] 5+ messages in thread
* Setting colour for comments for light and dark theme
2022-02-01 11:28 ` goncholden
@ 2022-02-01 12:35 ` goncholden
2022-02-03 2:13 ` Michael Heerdegen
1 sibling, 0 replies; 5+ messages in thread
From: goncholden @ 2022-02-01 12:35 UTC (permalink / raw)
To: goncholden
Cc: Manuel Giraud,
goncholden via Users list for the GNU Emacs text editor
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, February 1st, 2022 at 11:28 AM, goncholden <goncholden@protonmail.com> wrote:
> On Tuesday, February 1st, 2022 at 10:34 AM, Manuel Giraud manuel@ledu-giraud.fr wrote:
>
> > Hi,
> >
> > Maybe you need a default match. Watch out untested code ahead:
> >
> > --8<---------------cut here---------------start------------->8---
> >
> > (defvar annotation-chroma
> >
> > '((dark . ((low . "#8300E0") (mid . "#AA33FF") (high . "#C370FF")))
> >
> > (light . ((low . "#C16BFF") (mid . "#AA33FF") (high . "#8000DB")))
> >
> > (default . ((low . "red") (mid . "green") (high . "blue"))))
> >
> > "Colour contrast for comments, indigo on dark and light background.")
> >
> > (defun annotation-typeface (chroma)
> >
> > "Set the foreground colour for comments.
> >
> > CHROMA Intensity Key used for setting colour of comments."
> >
> > (let* ((colors annotation-chroma)
> >
> > (levels
> >
> > (pcase (car custom-enabled-themes)
> >
> > ('modus-operandi (alist-get 'light colors))
> >
> > ('modus-vivendi (alist-get 'dark colors))
> >
> > (_ (alist-get 'default colors)))))
> >
> > (face-remap-add-relative 'font-lock-comment-face
> >
> > `(:foreground ,(alist-get chroma levels)))))
> >
> > --8<---------------cut here---------------end--------------->8---
>
> I wonder if there is any way that colours change whether one is using a light or dark theme. Is the light and dark setting inherent to emacs, or inherent to the theme? For instance the default can still check if the theme uses a light or dark background. Better still, the annotation colours could be set up for light and dark background irrespective of the particular instance of modus-themes. Meaning that the colours are set for any theme one could be using.
Have tried using (frame--current-backround-mode nil) but this gives
Symbol's function definition is void: frame--current-backround-mode
I am using Emacs 27.1
> > --
> >
> > Manuel Giraud
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Setting colour for comments for light and dark theme
2022-02-01 11:28 ` goncholden
2022-02-01 12:35 ` goncholden
@ 2022-02-03 2:13 ` Michael Heerdegen
1 sibling, 0 replies; 5+ messages in thread
From: Michael Heerdegen @ 2022-02-03 2:13 UTC (permalink / raw)
To: goncholden
Cc: goncholden via Users list for the GNU Emacs text editor,
Manuel Giraud
goncholden <goncholden@protonmail.com> writes:
> > (face-remap-add-relative 'font-lock-comment-face
> >
> > `(:foreground ,(alist-get chroma levels)))))
> >
> I wonder if there is any way that colours change whether one is using
> a light or dark theme.
The SPECS in `face-remap-add-relative' can also be faces - see
(info "(elisp) Face Remapping")
So I think you should be able to do what you want if you specify a face
that specifies different foreground colors for the different background
modes.
Michael.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-03 2:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-01 9:38 Setting colour for comments for light and dark theme goncholden via Users list for the GNU Emacs text editor
2022-02-01 10:34 ` Manuel Giraud
2022-02-01 11:28 ` goncholden
2022-02-01 12:35 ` goncholden
2022-02-03 2:13 ` Michael Heerdegen
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.