From: Jim Porter <jporterbugs@gmail.com>
To: Thierry Volpiatto <thievol@posteo.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 54774@debbugs.gnu.org
Subject: bug#54774: 28.1; ansi-color with no colors in Emacs-28
Date: Sat, 9 Apr 2022 10:31:50 -0700 [thread overview]
Message-ID: <fa1a0da8-7a3f-0712-87a7-5b8f7db2d987@gmail.com> (raw)
In-Reply-To: <874k32zovr.fsf@posteo.net>
On 4/9/2022 12:25 AM, Thierry Volpiatto wrote:
> Apart advicing `ansi-color-get-face-1` I couldn't find how to fix my
> code as your changes are binding ansi-code 5 to `ansi-color-slow-blink`
> face which create unwanted squares.
I had a chance to look into this a bit more. ansi-color.el has
mis-parsed 256-color and 24-bit color escapes for a long time. For
example, you can try this under Emacs 27.2:
(ansi-color-apply "\033[38;5;2mhi\033[0m")
-> #("hi" 0 2 (font-lock-face success))
This should actually be equivalent to the 8-color green value (ANSI SGR
value 32). (Note: Under Emacs 27.2, the "slow blink" face is mapped to
`success', whereas in 28.1, it's mapped to `ansi-color-slow-blink'. In
Emacs 29, this properly sets the foreground to green.)
Normally this isn't an issue, since Emacs' shell/term modes indicate
that they only support 8-color mode, so commands usually don't emit
256-color sequences. However, in your case this looks to be some text
from a web service, so it obviously can't inspect your terminal
capabilities (unless there's a way to send them in the request?).
Looking at your code in more detail, I think you just got lucky that
things worked ok in Emacs 27. See here:
(while (re-search-forward "38;5;\\([0-9]+\\)m" nil t)
;; ...
(replace-match (pcase (match-string 1)
("154" "32")
("190" "31")
("118" "32")
("208" "37")
("202" "34")
("214" "35")
("220" "36")
("226" "33")
(r r))
t t nil 1))
This replaces an ANSI escape like "\033[38;5;154m" with "\033[38;5;32m".
So the 256-color ANSI escape is still there, just slightly transformed.
I think you want the result to be "\033[32m" instead, so that you're not
using 256-color escape sequences at all.
If you adjust the regexp/replacement to remove the "38;5;" bit, I think
your existing code should work fine in both Emacs 27 and 28.
next prev parent reply other threads:[~2022-04-09 17:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 19:49 bug#54774: 28.1; ansi-color with no colors in Emacs-28 Thierry Volpiatto
2022-04-07 20:10 ` Thierry Volpiatto
2022-04-07 20:24 ` Thierry Volpiatto
2022-04-08 13:23 ` Lars Ingebrigtsen
2022-04-08 17:48 ` Thierry Volpiatto
2022-04-08 18:23 ` Jim Porter
2022-04-09 7:25 ` Thierry Volpiatto
2022-04-09 17:31 ` Jim Porter [this message]
2022-04-09 18:18 ` Thierry Volpiatto
2022-04-10 12:01 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fa1a0da8-7a3f-0712-87a7-5b8f7db2d987@gmail.com \
--to=jporterbugs@gmail.com \
--cc=54774@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=thievol@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).