From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#54774: 28.1; ansi-color with no colors in Emacs-28 Date: Sat, 09 Apr 2022 18:18:18 +0000 Message-ID: <87ee262jta.fsf@posteo.net> References: <877d80pstl.fsf@posteo.net> <87tub37lqe.fsf@gnus.org> <5f2525c7-bfc3-cac7-7dda-a10b11c6592d@gmail.com> <874k32zovr.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25421"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 54774@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 09 20:29:42 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndFqA-0006Vu-Bi for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Apr 2022 20:29:42 +0200 Original-Received: from localhost ([::1]:56366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ndFq9-00019m-Dv for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Apr 2022 14:29:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndFpW-00017w-6S for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 14:29:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ndFpV-0001gJ-Ud for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 14:29:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ndFpV-0008KF-QR for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 14:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Apr 2022 18:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54774 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 54774-submit@debbugs.gnu.org id=B54774.164952889631945 (code B ref 54774); Sat, 09 Apr 2022 18:29:01 +0000 Original-Received: (at 54774) by debbugs.gnu.org; 9 Apr 2022 18:28:16 +0000 Original-Received: from localhost ([127.0.0.1]:38668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndFol-0008JB-PM for submit@debbugs.gnu.org; Sat, 09 Apr 2022 14:28:16 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:37821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndFoj-0008Ix-Dy for 54774@debbugs.gnu.org; Sat, 09 Apr 2022 14:28:14 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 7CB3B240107 for <54774@debbugs.gnu.org>; Sat, 9 Apr 2022 20:28:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1649528887; bh=1c4uhAQcyYPuuUFZPS3l3B55Aw2EcHqpouM5yC0jF/g=; h=From:To:Cc:Subject:Date:Autocrypt:From; b=JD6AhDv6Wk8ykLTHjVd4WV53kRLcOoWO7nf1Zif4lJuTqu509obFKXpbORrBbSNbd v4Oj6CMDwUPzY/ql/2Mug7V9cUO7Z2/5g2MKTo3KvDH3RA9CSeIHtiO2ptHQw1kgSw tfKi/GRcIRL9d02c47BMr5I2JV21BJzd3cYCNuDbaMRBPKNu13Ge5xL7FzKQanS+oi t42/yIj41uucocMu85Y/gFi2PaeRRfjdfAB5NhaEazaZwCv22bFdFINlrBAP+1YIpZ szZ+puJbjCAPEGn7Qp+8m3GJ1G9FG3ZuyuAK2FWQp2mFqtz5wTZBMbUbGYZ7qJBUQc hlu9WZAeTDrcQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4KbNsK6WdQz9rxT; Sat, 9 Apr 2022 20:28:05 +0200 (CEST) In-reply-to: Autocrypt: addr=thievol@posteo.net; prefer-encrypt=mutual; keydata= mQGNBF8ylcIBDADG+hy+zR6L4/vbdDDZuSaMmSrU3A5QZJpeBCvxTr7MpzzruZbhLPW1K3R6N2MA edi8Y+C8o27FVRIjpdbaKMGu9je7JV/TbUQYo3SOwCK1vM4LUn4V6ZLzSYkuiEt4eyMoiDdyvN0p kcK6P9x9DCetcEVszXzQg+yzCVrQ2hXWDXWT4M18EC3wtO7RHPouMqGiwBFhBAYErCqFWFxQHkfb tG/4yGyJ58rglb65O3qijjMWvYwcWZun9/7qm8Z4/4mHopmo2zgU+OrptnLSZfkZGz3Y7Uf452xQ GVq0Fv75NPvQru7y+DYVhuVXXyAmGxt+vf4rIiixMBbhKEPjcxEPAa2LTzex2IsTZR+QVG9uDnqC WcgaOEQ58fzXNvNhtwwF/Rgio2XWAJVdmFWS59/k9W58CIUSNKBMZh2XeGdEmtHvDtCxW3z6FJha 36RzOM3fMNNiAGdFZJA84gcdloJR+sHCDTTPT3784fjr+V8An7sI581NGFzkRQqPvEQCZbUAEQEA AbQSdGhpZXZvbEBwb3N0ZW8ubmV0iQHUBBMBCgA+FiEEI9twfRN7r3nig/xwDsVtFB0W75MFAl8y lcICGwMFCQPCZwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQDsVtFB0W75MB3QwAlTsVzFmr +S/tMKwwwOibjhNPi/OZiUC2AYfaqfVAiIHDT3RbzDe03sAJoomJkJnYVjGzQZwibCMO2+ITkMPV 2wvrd4CbgS1KCVbrltwcuK/nxPCBaHytOCZUIInnhJo5PE/h03K X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:229630 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Jim Porter writes: > 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. Many thanks to take the time to look into this. > 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=20 > 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=20 > capabilities (unless there's a way to send them in the request?). Ok, thanks for explaining. > 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. Indeed following your advice it work fine with both Emacs-28 and Emacs-27: (while (re-search-forward "\\(38;5;[0-9]+\\)m" nil t) (when (< emacs-major-version 29) (replace-match (pcase (match-string 1) ("38;5;154" "32") ; green ("38;5;190" "31") ; red ("38;5;118" "32") ; green ("38;5;208" "37") ; white ("38;5;202" "34") ; blue ("38;5;214" "35") ; magenta ("38;5;220" "36") ; cyan ("38;5;226" "33") ; yellow (r r)) t t nil 1))) =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmJR0DETHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvk4EsC/9Ys4a/529R6yNX1Dl9PiOHCNcNL359 VS6VguaiSeT/hoPVxUJCJSBDguPUzk6HBbuoxmoF3SWtSHu4F/K8hPNUN7wLAe1a 4QU+bcQmhudVPcUAdw7DR4PojNYNxLBwfNvi6JG6rLvJH5n1eeKb3o3CG6E/N+vz yjyEeuM1pisEUTVmaRXS/cIb+LjS7eQpTsgLxwqFm/M0RIQVRGGQbEVTvJK167/h mKY4EkmNmyFNWZYa00qfKAvCtIqC4xWATkW2Fm5go+QGfGMjalhIILyR96f072HB xV+lfVUXmMHce2sfPjXocRKRMjQGhKNCG3QF2/ijZxKFCvOL1+EF26+QASvfJs8R sdtGQMF5KyE3bkYzHspULCmnTStxf4YPh2rd/JJxuB9tKPo2Y/nJzqIcOODm3lT+ wNzqfszKNEfiocJ+qVxZi5qH44YZT3BYvK8xjRyTh8vHSF3Bt5V81xVV4aYngqcv ktb8x3qA9B6ICiVttpPQ3/Z0ryQp22PUrBM= =rYPS -----END PGP SIGNATURE----- --=-=-=--