GNU bug report logs - #48755
28.0.50; Emacs doesn't detect the terminal background color in macOS Terminal or iTerm2

Previous Next

Package: emacs;

Reported by: Daniel Martín <mardani29 <at> yahoo.es>

Date: Sun, 30 May 2021 22:21:02 UTC

Severity: normal

Found in version 28.0.50

Full log


View this message in rfc822 format

From: Daniel Martín <mardani29 <at> yahoo.es>
To: 48755 <at> debbugs.gnu.org
Subject: bug#48755: 28.0.50; Emacs doesn't detect the terminal background color in macOS Terminal or iTerm2
Date: Mon, 31 May 2021 00:20:35 +0200
Steps to reproduce the problem:

- Start macOS Terminal or iTerm2 (both are probably the most popular
terminals for macOS).

- Switch the terminal background color to a dark color.

- emacs -nw -Q

Actual result:

Colored text is sometimes very difficult to read, because Emacs assumes
it's running on a light terminal background, and configures the faces
accordingly.

Expected result:

Emacs faces are those of a dark background.

Workaround:

Customize frame-background-mode to 'dark.

Here's some information about macOS Terminal and iTerm2.  Apparently,
they both identify as xterm-256color and support querying the background
color:

macOS Terminal:

$ printf '\e[>0c'
1;95;0c

$ printf '\e]11;?\e\'
11;rgb:0000/0000/0000

$ echo $TERM
xterm-256color

iTerm2:

$ printf '\e[>0c'
0;95;0c

$ printf '\e]11;?\e\'
11;rgb:0000/0000/0000

$ echo $TERM
xterm-256color

I tried to fix the problem by taking a look at xterm--version-handler in
xterm.el, but the version logic is a bit difficult to understand.  Is
there some documentation about the versions and capabilities somewhere?
I'm worried about changing things there may cause regressions in other
terminals.

Thanks.




This bug report was last modified 4 years and 16 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.