Summary: massage the intro a little
< ansi-color.el -- translate ANSI into text-properties
< This file provides functions translating Select Graphic Rendition
< (SGR) control sequences (formerly known as ANSI escape sequences) into
< overlays, text-properties, or extents. Emacs will thus
< render the output in the correct colors.
< 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
> <code>ansi-color.el</code> translates ANSI SGR (Select Graphic Rendition) escape sequences like "Esc [ 30 m" into EmacsOverlays, TextProperties, or XEmacsExtents with face colours, bold, etc.
> These escape sequences are best known as "ANSI" which is where they were first standardized. They can be found in ECMA-48 (section 3.8.117, identical to ISO/IEC 6429), freely available as a PDF file.
> * http://www.ecma-international.org/publications/standards/Ecma-048.htm
> The "Graphic Rendition Combination Mode (GRCM)" implemented by <code>ansi-color.el</code>
< * http://www.ecma-international.org/publications/standards/Ecma-048.htm
These escape sequences are best known as “ANSI” which is where they were first standardized. They can be found in ECMA-48 (section 3.8.117, identical to ISO/IEC 6429), freely available as a PDF file.
The “Graphic Rendition Combination Mode (GRCM)” implemented by
ansi-color.el is “cumulative mode” as defined in section 7.2.8. Cumulative mode means that whenever possible, SGR control sequences are combined (ie. blue and bold).
ansi-color.el is part of Emacs!
To install it, put the following into your InitFile:
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
Some GNU/Linux distributions allow you to install a “color gcc” – the warnings and errors are colored using escape sequences. These usually display as garbage within Emacs. The above code fixes this as well.
You can also get a copy of ansi-color.el from this wiki.
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
If you want to use it with [[Eshell?]], try the following to remove escape sequences from the output:
(add-hook 'eshell-preoutput-filter-functions 'ansi-color-filter-apply)
The following will add colors, but its very slow. Don’t try it on /dev or similar huge directories:
(add-hook 'eshell-preoutput-filter-functions 'ansi-color-apply)
‘M-x term’ and
‘M-x ansi-term’ do their own hilighting. It makes no sense to add ansi-color to these modes. If you still want to investigate this, take a look at term-emulate-terminal. That is the function where you would have to add your stuff.