OS: Linux 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
Emacs: GNU Emacs 28.0.50, with a solarized theme from here
Terminal emulator: terminator 1.91, with a solarized (dark) palette
The displays below were done by running the following bash script within a *shell*
buffer (i.e. a buffer started with M-x shell
):
echo -e '\e[30m██\e[31m██\e[32m██\e[33m██\e[34m██\e[35m██\e[36m██\e[37m██\e[0m'
"No-window"/"non-GUI" (-nw
) Emacs process, running on a terminator 1.91 terminal emulator:
How can I make ANSI colors in the GUI Emacs environment look like those in the "non-GUI" environment?
NB: I do not want to modify my terminal emulator in any way. I am happy with it. I want to modify GUI Emacs so that it produces the same behavior as my terminal emulator does.
For what it's worth, below are the first 8 colors in the output for (list-colors-display
) running on "non-GUI" Emacs, which correspond to the colors I get from the ANSI color test shown above:
The colors with the same names (as reported by (list-colors-display)
in "GUI-Emacs" are shown below; again, they match the colors from the ANSI colors test shown earlier:
In light of this, it occurs to me that maybe a way to achieve what I want is to redefine the colors black
, red
, ..., white
? How would I do this?
Is there a "better" ("higher-level", more robust, etc.) way to solve this problem?
EDIT: The accepted answer in #000000 and true black in terminal Emacs colors shows that its OP's issue was due to his gnome-terminal configuration. My question, on the other hand, has nothing to do with gnome-terminal, or with terminal emulators in general. It's about GUI Emacs. The one other answer to https://emacs.stackexchange.com proposes to modify the default
font. This will not solve my problem. Changing the default
font would affect at most one foreground color. I have a problem with 8 colors. Also, the text that exhibits these various colors often have the same face (e.g. comint-highlight-prompt
).
EDIT:
I changed the code for the ANSI color test to this:
echo -e '\e[30m██\e[31m██\e[32m██\e[33m██\e[34m██\e[35m██\e[36m██\e[37m██\e[0m'
echo -e '\e[30mXX\e[31mXX\e[32mXX\e[33mXX\e[34mXX\e[35mXX\e[36mXX\e[37mXX\e[0m'
Now, the output (on "GUI Emacs") is this:
The key point is this: According to describe-face
, all those X's have the default
face. These means that no solution based on modifying faces will solve this problem.
EDIT: First I ran this:
;; just to get a response...
(setq ansi-color-names-vector
["red3" "red3" "red3" "red3" "red3" "red3" "red3" "red3"])
(ansi-color-make-color-map) ;; is this necessary???
Then I started a fresh *shell*
buffer (M-x shell
), and ran the ANSI color test shown above, namely:
echo -e '\e[30m██\e[31m██\e[32m██\e[33m██\e[34m██\e[35m██\e[36m██\e[37m██\e[0m'
echo -e '\e[30mXX\e[31mXX\e[32mXX\e[33mXX\e[34mXX\e[35mXX\e[36mXX\e[37mXX\e[0m'
I got the same results I got earlier. In particular, the 8 colors were different, even though all 8 entries in ansi-color-names-vector
are the same.