unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* checking for light or dark background
@ 2022-02-02  9:26 goncholden via Users list for the GNU Emacs text editor
  2022-02-02 12:56 ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: goncholden via Users list for the GNU Emacs text editor @ 2022-02-02  9:26 UTC (permalink / raw)
  To: goncholden via Users list for the GNU Emacs text editor

I want to determine whether emacs is using a light or dark background. This could be set up by emacs itself
or by a theme.

Purhaps I could write a function that I can use in an 'if' clause.

(color-dark-p
(color-name-to-rgb
(face-attribute 'default :background)))

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-02  9:26 checking for light or dark background goncholden via Users list for the GNU Emacs text editor
@ 2022-02-02 12:56 ` Eli Zaretskii
  2022-02-02 13:25   ` goncholden
  2022-02-08  1:33   ` James Cloos
  0 siblings, 2 replies; 14+ messages in thread
From: Eli Zaretskii @ 2022-02-02 12:56 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 02 Feb 2022 09:26:02 +0000
> From:  goncholden via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
> 
> I want to determine whether emacs is using a light or dark background. This could be set up by emacs itself
> or by a theme.

Like this:

  (frame-parameter nil 'background-mode)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* checking for light or dark background
  2022-02-02 12:56 ` Eli Zaretskii
@ 2022-02-02 13:25   ` goncholden
  2022-02-02 13:27     ` goncholden
  2022-02-08  1:33   ` James Cloos
  1 sibling, 1 reply; 14+ messages in thread
From: goncholden @ 2022-02-02 13:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Wednesday, February 2nd, 2022 at 12:56 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> Date: Wed, 02 Feb 2022 09:26:02 +0000
>
> From: goncholden via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org
>
> I want to determine whether emacs is using a light or dark background. This could be set up by emacs itself
>
> or by a theme.

Like this:

(frame-parameter nil 'background-mode)

This evaluates to either light or dark.  Very neat compared to what I was playing with initially.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* checking for light or dark background
  2022-02-02 13:25   ` goncholden
@ 2022-02-02 13:27     ` goncholden
  2022-02-02 14:41       ` Eli Zaretskii
  2022-02-02 14:48       ` Yuri Khan
  0 siblings, 2 replies; 14+ messages in thread
From: goncholden @ 2022-02-02 13:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Wednesday, February 2nd, 2022 at 1:25 PM, goncholden <goncholden@protonmail.com> wrote:

> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Wednesday, February 2nd, 2022 at 12:56 PM, Eli Zaretskii eliz@gnu.org wrote:
>
> > Date: Wed, 02 Feb 2022 09:26:02 +0000
> >
> > From: goncholden via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org
> >
> > I want to determine whether emacs is using a light or dark background. This could be set up by emacs itself
> >
> > or by a theme.
>
> Like this:
>
> (frame-parameter nil 'background-mode)
>
> This evaluates to either light or dark. Very neat compared to what I was playing with initially.


The problem I was having was that for Emacs 27.2, the command (frame--current-backround-mode nil)
was not available.  What is the recommendation for Emacs>=28.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-02 13:27     ` goncholden
@ 2022-02-02 14:41       ` Eli Zaretskii
  2022-02-02 16:18         ` goncholden
  2022-02-02 14:48       ` Yuri Khan
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-02-02 14:41 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 02 Feb 2022 13:27:58 +0000
> From: goncholden <goncholden@protonmail.com>
> Cc: help-gnu-emacs@gnu.org
> 
> 
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> 
> On Wednesday, February 2nd, 2022 at 1:25 PM, goncholden <goncholden@protonmail.com> wrote:
> 
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >
> > On Wednesday, February 2nd, 2022 at 12:56 PM, Eli Zaretskii eliz@gnu.org wrote:
> >
> > > Date: Wed, 02 Feb 2022 09:26:02 +0000
> > >
> > > From: goncholden via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org
> > >
> > > I want to determine whether emacs is using a light or dark background. This could be set up by emacs itself
> > >
> > > or by a theme.
> >
> > Like this:
> >
> > (frame-parameter nil 'background-mode)
> >
> > This evaluates to either light or dark. Very neat compared to what I was playing with initially.
> 
> 
> The problem I was having was that for Emacs 27.2, the command (frame--current-backround-mode nil)
> was not available.  What is the recommendation for Emacs>=28.

I don't understand: (frame-parameter nil 'background-mode) works for
Emacs 28 and later as well.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-02 13:27     ` goncholden
  2022-02-02 14:41       ` Eli Zaretskii
@ 2022-02-02 14:48       ` Yuri Khan
  2022-02-03  4:19         ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 14+ messages in thread
From: Yuri Khan @ 2022-02-02 14:48 UTC (permalink / raw)
  To: goncholden; +Cc: help-gnu-emacs

On Wed, 2 Feb 2022 at 21:05, goncholden <goncholden@protonmail.com> wrote:

> The problem I was having was that for Emacs 27.2, the command (frame--current-backround-mode nil)
> was not available.  What is the recommendation for Emacs>=28.

You should not rely on (frame--current-background-mode) even if it is
available. The double dash in its name tells you it is a semi-private
implementation detail, subject to change at any time. You can access
it, but when it changes and your code breaks, you will get no support.

(frame-parameter FRAME 'background-mode), on the other hand, uses only
public, documented symbols, guaranteed to be available and working
well into the next century. (Exaggerating a bit here, but you get the
idea.)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-02 14:41       ` Eli Zaretskii
@ 2022-02-02 16:18         ` goncholden
  0 siblings, 0 replies; 14+ messages in thread
From: goncholden @ 2022-02-02 16:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Wednesday, February 2nd, 2022 at 2:41 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> Date: Wed, 02 Feb 2022 13:27:58 +0000
>
> From: goncholden goncholden@protonmail.com
>
> Cc: help-gnu-emacs@gnu.org
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Wednesday, February 2nd, 2022 at 1:25 PM, goncholden goncholden@protonmail.com wrote:
>
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >
> > On Wednesday, February 2nd, 2022 at 12:56 PM, Eli Zaretskii eliz@gnu.org wrote:
> >
> > > Date: Wed, 02 Feb 2022 09:26:02 +0000
> > >
> > > From: goncholden via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org
> > >
> > > I want to determine whether emacs is using a light or dark background. This could be set up by emacs itself
> > >
> > > or by a theme.
> >
> > Like this:
> >
> > (frame-parameter nil 'background-mode)
> >
> > This evaluates to either light or dark. Very neat compared to what I was playing with initially.
>
> The problem I was having was that for Emacs 27.2, the command (frame--current-backround-mode nil)
>
> was not available. What is the recommendation for Emacs>=28.

I don't understand: (frame-parameter nil 'background-mode) works for
Emacs 28 and later as well.


Yes, I have now switched to (frame-parameter nil 'background-mode).





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-02 14:48       ` Yuri Khan
@ 2022-02-03  4:19         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-03  4:31           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-03  4:19 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> The problem I was having was that for Emacs 27.2, the
>> command (frame--current-backround-mode nil) was not
>> available. What is the recommendation for Emacs>=28.
>
> You should not rely on (frame--current-background-mode) even
> if it is available. The double dash in its name tells you it
> is a semi-private implementation detail, subject to change
> at any time. You can access it, but when it changes and your
> code breaks, you will get no support.

The designation sure is "semi-private" since it is actually as
public as any other `defun' available on the global
no-namespace market ...

As for what can change and what cannot, I think it is better
to just change what is bad, into something good (or at least
better), and focus on that rather than the supposed status of
the symbol, as communicated by the presence or absence of
a double dash ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-03  4:19         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-02-03  4:31           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-03  4:31 UTC (permalink / raw)
  To: help-gnu-emacs

On can egrep(1) the source for [[:alnum:]]\-\-[[:alnum:]] ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-02 12:56 ` Eli Zaretskii
  2022-02-02 13:25   ` goncholden
@ 2022-02-08  1:33   ` James Cloos
  2022-02-08  3:29     ` Eli Zaretskii
  1 sibling, 1 reply; 14+ messages in thread
From: James Cloos @ 2022-02-08  1:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

>>>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

EZ>   (frame-parameter nil 'background-mode)

i just tried that in emacs-tty on screen.

the underlying terminal is black on white, but that (frame-parameter)
call claimed dark.

it may work in a gui term, but is not reliable elsewhere.

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-08  1:33   ` James Cloos
@ 2022-02-08  3:29     ` Eli Zaretskii
  2022-02-20 19:30       ` James Cloos
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-02-08  3:29 UTC (permalink / raw)
  To: help-gnu-emacs

> From: James Cloos <cloos@jhcloos.com>
> Cc: help-gnu-emacs@gnu.org
> Copyright: Copyright 2022 James Cloos
> OpenPGP-Fingerprint: E9E9 F828 61A4 6EA9 0F2B  63E7 997A 9F17 ED7D AEA6
> Date: Mon, 07 Feb 2022 20:33:36 -0500
> 
> >>>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:
> 
> EZ>   (frame-parameter nil 'background-mode)
> 
> i just tried that in emacs-tty on screen.
> 
> the underlying terminal is black on white, but that (frame-parameter)
> call claimed dark.
> 
> it may work in a gui term, but is not reliable elsewhere.

You didn't tell what terminal you tried this on.  Some of them are
capable of reporting their default background color, others aren't.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-08  3:29     ` Eli Zaretskii
@ 2022-02-20 19:30       ` James Cloos
  2022-02-20 20:05         ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: James Cloos @ 2022-02-20 19:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

>>>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

EZ> You didn't tell what terminal you tried this on.  Some of them are
EZ> capable of reporting their default background color, others aren't.

screen was running on rxvt-unicode.

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-20 19:30       ` James Cloos
@ 2022-02-20 20:05         ` Eli Zaretskii
  2022-02-21 11:16           ` Yuri Khan
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-02-20 20:05 UTC (permalink / raw)
  To: help-gnu-emacs

> From: James Cloos <cloos@jhcloos.com>
> Cc: help-gnu-emacs@gnu.org
> Copyright: Copyright 2022 James Cloos
> OpenPGP-Fingerprint: E9E9 F828 61A4 6EA9 0F2B  63E7 997A 9F17 ED7D AEA6
> Date: Sun, 20 Feb 2022 14:30:43 -0500
> 
> >>>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:
> 
> EZ> You didn't tell what terminal you tried this on.  Some of them are
> EZ> capable of reporting their default background color, others aren't.
> 
> screen was running on rxvt-unicode.

So you are saying rxvt-set-background-mode doesn't work for you?



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: checking for light or dark background
  2022-02-20 20:05         ` Eli Zaretskii
@ 2022-02-21 11:16           ` Yuri Khan
  0 siblings, 0 replies; 14+ messages in thread
From: Yuri Khan @ 2022-02-21 11:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Mon, 21 Feb 2022 at 03:05, Eli Zaretskii <eliz@gnu.org> wrote:

> > screen was running on rxvt-unicode.
>
> So you are saying rxvt-set-background-mode doesn't work for you?

Why would rxvt-set-background-mode even run, if the immediate terminal
is ‘screen’? And term/screen delegates its initialization to
term/xterm, which detects background mode by sending OSC 1 1 ; ? ST
(under some conditions). Screen does not seem to support this sequence
[1].

[1]: https://www.gnu.org/software/screen/manual/html_node/Control-Sequences.html



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-02-21 11:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02  9:26 checking for light or dark background goncholden via Users list for the GNU Emacs text editor
2022-02-02 12:56 ` Eli Zaretskii
2022-02-02 13:25   ` goncholden
2022-02-02 13:27     ` goncholden
2022-02-02 14:41       ` Eli Zaretskii
2022-02-02 16:18         ` goncholden
2022-02-02 14:48       ` Yuri Khan
2022-02-03  4:19         ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-03  4:31           ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-08  1:33   ` James Cloos
2022-02-08  3:29     ` Eli Zaretskii
2022-02-20 19:30       ` James Cloos
2022-02-20 20:05         ` Eli Zaretskii
2022-02-21 11:16           ` Yuri Khan

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