all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thievol@posteo.net>
To: Jim Porter <jporterbugs@gmail.com>
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, 09 Apr 2022 07:25:09 +0000	[thread overview]
Message-ID: <874k32zovr.fsf@posteo.net> (raw)
In-Reply-To: <5f2525c7-bfc3-cac7-7dda-a10b11c6592d@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3927 bytes --]


Hello Jim and thanks for clarifications.

Jim Porter <jporterbugs@gmail.com> writes:

> On 4/8/2022 6:23 AM, Lars Ingebrigtsen wrote:
>> Thierry Volpiatto <thievol@posteo.net> writes:
>> 
>>> it seems using ansi-color-apply in Emacs-28 is not working properly,
>>> there is no colors.  In Emacs-29 it is working properly (very nice)
>>> without needing a workaround used previously in emacs-27 (code commented).
>>> See code below to reproduce and Screenshots attached.
>> I'm not sure I understand this bug report.  Are you asking for the
>> code
>> in ansi-color in Emacs 29 to be backported to Emacs 28.2?
>
> I think the issue is that there were some changes in Emacs 28.1 (by
> me, see commit ceb9da3b7125fbdf0da04a3b158ac1e792c87f4f) to add
> support for ANSI "bright" colors.

Yes this is this commit that cause problems, commenting the first cond
clause of `ansi-color-get-face-1` allows having the same behavior as
with Emacs-27 with replacement of 256 colors sequences:

#+begin_src diff
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index b379e710940..e9a251545ba 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -861,8 +861,8 @@ BRIGHT, if non-nil, requests \"bright\" ANSI colors, even if ANSI-CODE
 is a normal-intensity color."
   (when (and bright (<= 30 ansi-code 49))
     (setq ansi-code (+ ansi-code 60)))
-  (cond ((<= 0 ansi-code 7)
-         (aref ansi-color-basic-faces-vector ansi-code))
+  (cond ;; ((<= 0 ansi-code 7)
+        ;;  (aref ansi-color-basic-faces-vector ansi-code))
         ((<= 30 ansi-code 38)
          (list :foreground
                (face-foreground

#+end_src

I made a bug report on github to clarify what's wrong,
see https://github.com/thierryvolpiatto/emacs-config/issues/1.

> In 29, Miha added support for 256-color and 24-bit ANSI colors as well
> (see 0fa2279b90bf5a638d8377032b71135e1374e8fb).

Working fine without the need of replacing 256 sequences.

> I've verified that Emacs 28.1 properly handles normal and bright ANSI
> colors in shell output. Bold/italic/etc works correctly as well, even
> though I added an unnecessary quote to the face definitions - that's
> been fixed in Emacs 29, and could be backported to 28, though I don't
> think it causes any serious problems.
>
> That said, it looks like Thierry had written some code for Emacs 27
> that scans the output of a command that uses ANSI 256-color sequences
> and then translates those sequences into ANSI 8-color sequences that
> ansi-color.el will understand. However, that code no longer works in
> Emacs 28, possibly due to my changes to support ANSI bright
> colors. I'm not sure this is actually a bug in Emacs; it may just mean
> that Thierry's workaround needs to be updated to account for the
> ansi-color.el changes I made.

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'm a little unclear about what actually broke though, and haven't had
> a chance to dig deeper. Some basic testing of `ansi-color-apply' shows
> that it does what I expect. From "emacs -Q":
>
>   (require 'ansi-color)
>   (ansi-color-apply "\033[44mfoo\033[0m")
>     -> #("foo" 0 3 (font-lock-face (:background "blue2")))
>   (ansi-color-apply "\033[44;33mfoo\033[0m")
>     -> #("foo" 0 3 (font-lock-face ((:foreground "yellow3")
>         (:background "blue2"))))
>
> That's the same behavior as Emacs 27.2 with some trivial differences
> (Emacs 27.2 uses `foreground-color' instead of `:foreground').

You can have a try at my code which is here:
https://github.com/thierryvolpiatto/emacs-config/blob/main/tv-utils.el#L1097

with and without advicing `ansi-color-get-face-1`:
https://github.com/thierryvolpiatto/emacs-config/blob/main/init.el#L24

Thanks.

-- 
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]

  reply	other threads:[~2022-04-09  7:25 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 [this message]
2022-04-09 17:31       ` Jim Porter
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874k32zovr.fsf@posteo.net \
    --to=thievol@posteo.net \
    --cc=54774@debbugs.gnu.org \
    --cc=jporterbugs@gmail.com \
    --cc=larsi@gnus.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.