ansi-color

Homepage: https://www.gnu.org/software/emacs

Author: Alex Schroeder

Summary

Translate ANSI escape sequences into faces

Commentary

This file provides a function that takes a string or a region
containing Select Graphic Rendition (SGR) control sequences (formerly
known as ANSI escape sequences) and tries to translate these into
faces.

This allows you to run ls --color=yes in shell-mode.  It is now
enabled by default; to disable it, set ansi-color-for-comint-mode
to nil.

Note that starting your shell from within Emacs might set the TERM
environment variable.  The new setting might disable the output of
SGR control sequences.  Using ls --color=yes forces ls to produce
these.

SGR control sequences are defined in section 3.8.117 of the ECMA-48
standard (identical to ISO/IEC 6429), which is freely available as a
PDF file .
The "Graphic Rendition Combination Mode (GRCM)" implemented is
"cumulative mode" as defined in section 7.2.8.  Cumulative mode
means that whenever possible, SGR control sequences are combined
(i.e. blue and bold).

The basic functions are:

`ansi-color-apply' to colorize a string containing SGR control
sequences.

`ansi-color-filter-apply' to filter SGR control sequences from a
string.

`ansi-color-apply-on-region' to colorize a region containing SGR
control sequences.

`ansi-color-filter-region' to filter SGR control sequences from a
region.

Thanks

Georges Brun-Cottan  for improving ansi-color.el
substantially by adding the code needed to cope with arbitrary chunks
of output and the filter functions.

Markus Kuhn  for pointing me to ECMA-48.

Stefan Monnier  for explaining obscure font-lock stuff and for
code suggestions.

Reverse dependencies