[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#54774: 28.1; ansi-color with no colors in Emacs-28
From: |
Thierry Volpiatto |
Subject: |
bug#54774: 28.1; ansi-color with no colors in Emacs-28 |
Date: |
Sat, 09 Apr 2022 07:25:09 +0000 |
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
signature.asc
Description: PGP signature