File: ansi-color.el.html
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 <URL:https://www.ecma-international.org/publications/standards/Ecma-048.htm>.
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 <gbruncot@emc.com> for improving ansi-color.el substantially by adding the code needed to cope with arbitrary chunks of output and the filter functions.
Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk> for pointing me to ECMA-48.
Stefan Monnier <foo@acm.com> for explaining obscure font-lock stuff and for code suggestions.
Defined variables (15)
ansi-color--control-seq-fragment-regexp | Regexp matching a partial ANSI control sequence. |
ansi-color-apply-face-function | Function for applying an Ansi Color face to text in a buffer. |
ansi-color-basic-faces-vector | Faces used for SGR control sequences determining a face. |
ansi-color-bold-is-bright | If set to non-nil, combining ANSI bold and a color produces the bright |
ansi-color-bright-colors-vector | Faces used for SGR control sequences determining a "bright" color. |
ansi-color-context | Context saved between two calls to ‘ansi-color-apply’. |
ansi-color-context-region | Context saved between two calls to ‘ansi-color-apply-on-region’. |
ansi-color-control-seq-regexp | Regexp matching an ANSI control sequence. |
ansi-color-faces-vector | Faces used for SGR control sequences determining a face. |
ansi-color-for-comint-mode | Determines what to do with comint output. |
ansi-color-for-compilation-mode | Determines what to do with compilation output. |
ansi-color-map | A brand new color map, formerly suitable for ‘ansi-color-get-face’. |
ansi-color-names-vector | Colors used for SGR control sequences determining a color. |
ansi-color-normal-colors-vector | Faces used for SGR control sequences determining a color. |
ansi-color-parameter-regexp | Regexp that matches SGR control sequence parameters. |
Defined functions (24)
ansi-color--code-as-hex | (COLOR) |
ansi-color--ensure-context | (CONTEXT-SYM POSITION) |
ansi-color--face-vec-face | (FACE-VEC) |
ansi-color--update-face-vec | (FACE-VEC ITERATOR) |
ansi-color-apply | (STRING) |
ansi-color-apply-on-region | (BEGIN END &optional PRESERVE-SEQUENCES) |
ansi-color-apply-overlay-face | (BEG END FACE) |
ansi-color-apply-sequence | (ESCAPE-SEQUENCE CODES) |
ansi-color-apply-text-property-face | (BEG END FACE) |
ansi-color-compilation-filter | () |
ansi-color-filter-apply | (STRING) |
ansi-color-filter-region | (BEGIN END) |
ansi-color-for-comint-mode-filter | () |
ansi-color-for-comint-mode-off | () |
ansi-color-for-comint-mode-on | () |
ansi-color-freeze-overlay | (OVERLAY IS-AFTER BEGIN END &optional LEN) |
ansi-color-get-face-1 | (ANSI-CODE &optional BRIGHT) |
ansi-color-make-color-map | () |
ansi-color-make-extent | (FROM TO &optional BUFFER) |
ansi-color-make-face | (PROPERTY COLOR) |
ansi-color-map-update | (SYMBOL VALUE) |
ansi-color-parse-sequence | (ESCAPE-SEQ) |
ansi-color-process-output | (IGNORED) |
ansi-color-set-extent-face | (EXTENT FACE) |
Defined faces (23)
ansi-color-black | Face used to render black color code. |
ansi-color-blue | Face used to render blue color code. |
ansi-color-bold | Face used to render bold text. |
ansi-color-bright-black | Face used to render bright black color code. |
ansi-color-bright-blue | Face used to render bright blue color code. |
ansi-color-bright-cyan | Face used to render bright cyan color code. |
ansi-color-bright-green | Face used to render bright green color code. |
ansi-color-bright-magenta | Face used to render bright magenta color code. |
ansi-color-bright-red | Face used to render bright red color code. |
ansi-color-bright-white | Face used to render bright white color code. |
ansi-color-bright-yellow | Face used to render bright yellow color code. |
ansi-color-cyan | Face used to render cyan color code. |
ansi-color-faint | Face used to render faint text. |
ansi-color-fast-blink | Face used to render rapidly blinking text. |
ansi-color-green | Face used to render green color code. |
ansi-color-inverse | Face used to render inverted video text. |
ansi-color-italic | Face used to render italic text. |
ansi-color-magenta | Face used to render magenta color code. |
ansi-color-red | Face used to render red color code. |
ansi-color-slow-blink | Face used to render slowly blinking text. |
ansi-color-underline | Face used to render underlined text. |
ansi-color-white | Face used to render white color code. |
ansi-color-yellow | Face used to render yellow color code. |