I have set up some custom colors for various faces in Emacs. They mostly look like this:
(custom-set-faces ; ... '(font-lock-constant-face ((((type tty)) (:foreground "bright magenta")) (t (:foreground "#6c71c4")))) ; ... )
When running in a terminal, Emacs used to use the basic 16-color escape codes for these colors. For example, the above would cause Emacs to issue the escape sequence
^[[95 to set the color to whatever the terminal had defined as "bright magenta".
Now, however, Emacs tries to detect whether the terminal supports 24-bit colors or 256 color mode; if so, it uses its own idea of what "bright magenta" should be (RGB triple
(65535 0 65535)) and picks the closest 24-bit color or 256-color-palette entry to it.
For various reasons⁰, I would like to tell Emacs to use the older 16 color escape codes, even when more color options are available. I'd also prefer not to do it by messing with the termcap/terminfo definitions for my terminal emulator.
Is there a way to get the behavior I want from Emacs, using Emacs's configuration files (or command line)?
I'm on Debian 12, with Emacs 28.2 and xterm 379.
⁰In some cases, I use a set of nested terminal emulators, with Emacs running in TTY mode inside them. The nesting interferes with 24-bit color in such a way that Emacs will think it's available, but I don't end up with the right colors being displayed. Since 16-color escape sequences work properly, I'm hoping to sidestep the nested emulator problem for the moment by restricting Emacs's behavior.