From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#54774: 28.1; ansi-color with no colors in Emacs-28 Date: Sat, 9 Apr 2022 10:31:50 -0700 Message-ID: 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: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36688"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 54774@debbugs.gnu.org To: Thierry Volpiatto Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 09 19:32:10 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 1ndEwT-0009QM-TY for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Apr 2022 19:32:09 +0200 Original-Received: from localhost ([::1]:44440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ndEwS-0004xQ-FC for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Apr 2022 13:32:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndEwM-0004xC-4F for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 13:32:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ndEwL-0002Sg-Q1 for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 13:32:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ndEwL-0006xs-M4 for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 13:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Apr 2022 17:32: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.164952551726762 (code B ref 54774); Sat, 09 Apr 2022 17:32:01 +0000 Original-Received: (at 54774) by debbugs.gnu.org; 9 Apr 2022 17:31:57 +0000 Original-Received: from localhost ([127.0.0.1]:38646 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndEwH-0006xa-Dc for submit@debbugs.gnu.org; Sat, 09 Apr 2022 13:31:57 -0400 Original-Received: from mail-pj1-f48.google.com ([209.85.216.48]:38663) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndEwF-0006xN-Eb for 54774@debbugs.gnu.org; Sat, 09 Apr 2022 13:31:55 -0400 Original-Received: by mail-pj1-f48.google.com with SMTP id s14-20020a17090a880e00b001caaf6d3dd1so14588011pjn.3 for <54774@debbugs.gnu.org>; Sat, 09 Apr 2022 10:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=9CbSnWkS5T72xiQmPQAPkMFgRkskmT5X6NudPMWOB10=; b=QiJGvBg1o83rDbKk+If1kFuxZpNHCUQpJfw8it16rjkQcJG9MOen5x/pjFYYyzLyY4 OurFf7+dneo1n5SQHIf43n6mpL218ubJH9rKSk6Leso5B9AgTde6JjW5A59T+B1mjsJF 3HGweoZYh869VIwJw3+BY0J4alUWXDbq8c0GjNCDK8ls1LNBCrPxQmEBQlvS3CWYS0Wj xTYt3aukBi3t+6l1Ol0QE2qgFVKVAeCl7jG6L8GjAOJBGmTf51NeuolRQWi+EFUwWrFL l7VEAZd7sYuk1wNlg5TAA7uZ6PrhKHvI4U9tY2zV7bnF15QHGBQrfLIpmZP/GG+WQym3 BMkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=9CbSnWkS5T72xiQmPQAPkMFgRkskmT5X6NudPMWOB10=; b=HPKzO4pnDHJZ4RwBDY2SAiVu+2f75/yIlf0L/fWiioCiuWrOiJdxHIgR3ItPzV9Spe fbKbB0bGERhEiJyvF5ZMTN1nLbBr3TVnktq8adtFfrtn0Isx1A4w+roW+4cbHaHOjp+u lJbhAdf29YVaaiHv3fEqksnX3s1UWMqYBdoOLikc/WVu0Gry52YDyU6qN0zEuKqC2CIv 4kMpB1qbjhAbYl2LYQkAjxUhbjz+xieAXG44Z4+XmpOR3MhKJDa5IoMjCcTGPQ8/bGEd t+RDGlicBdXmF6IDAvTB0UvJPfXfG6yTmLeWFHixzF2TXJH4Xu4J+y07/KMzjAzhWvqw RsqQ== X-Gm-Message-State: AOAM530Y9bqeKsgNld4sFTQnaFm9GI5fMFlL/XB+ZdpTEkjKaPPY/65x iuG0cyNyRq63EYw7ODqsScdtC0vzn/s= X-Google-Smtp-Source: ABdhPJxSXcaJoZ4x8IkjbsJLXVd4SJ5EM4mfkeTHqV2BTChnloOjewWvvEX69uwyqpE4UvtY9t5YwA== X-Received: by 2002:a17:90a:578c:b0:1c9:e362:d109 with SMTP id g12-20020a17090a578c00b001c9e362d109mr28272887pji.237.1649525509686; Sat, 09 Apr 2022 10:31:49 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id s14-20020a63dc0e000000b0039cc76bda79sm8056020pgg.40.2022.04.09.10.31.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Apr 2022 10:31:49 -0700 (PDT) In-Reply-To: <874k32zovr.fsf@posteo.net> Content-Language: en-US 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:229628 Archived-At: 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.