2013-06-20 01:03:57 +00:00
|
|
|
|
;;; ansi-color.el --- translate ANSI escape sequences into faces -*- lexical-binding: t -*-
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
2022-01-01 07:45:51 +00:00
|
|
|
|
;; Copyright (C) 1999-2022 Free Software Foundation, Inc.
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
1999-10-19 11:17:23 +00:00
|
|
|
|
;; Author: Alex Schroeder <alex@gnu.org>
|
2001-01-15 11:34:27 +00:00
|
|
|
|
;; Version: 3.4.2
|
|
|
|
|
;; Keywords: comm processes terminals services
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
1999-08-04 16:49:19 +00:00
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; 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.
|
1999-08-04 16:49:19 +00:00
|
|
|
|
;;
|
2009-12-05 21:11:29 +00:00
|
|
|
|
;; 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.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;;
|
|
|
|
|
;; 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.
|
|
|
|
|
;;
|
2000-09-14 12:38:09 +00:00
|
|
|
|
;; 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
|
2020-10-24 18:22:33 +00:00
|
|
|
|
;; PDF file <URL:https://www.ecma-international.org/publications/standards/Ecma-048.htm>.
|
2013-07-24 03:49:24 +00:00
|
|
|
|
;; 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
|
2021-09-14 06:43:18 +00:00
|
|
|
|
;; (i.e. blue and bold).
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
2000-09-14 12:38:09 +00:00
|
|
|
|
;; 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.
|
1999-08-04 16:49:19 +00:00
|
|
|
|
;;
|
2000-09-14 12:38:09 +00:00
|
|
|
|
;; `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
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
2000-09-14 12:38:09 +00:00
|
|
|
|
;; 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.
|
1999-08-04 16:49:19 +00:00
|
|
|
|
;;
|
2000-09-14 12:38:09 +00:00
|
|
|
|
;; Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk> for pointing me to ECMA-48.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;;
|
2011-11-17 09:09:20 +00:00
|
|
|
|
;; Stefan Monnier <foo@acm.com> for explaining obscure font-lock stuff and for
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; code suggestions.
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2005-08-31 13:47:05 +00:00
|
|
|
|
(defvar comint-last-output-start)
|
2021-07-19 16:54:18 +00:00
|
|
|
|
(defvar compilation-filter-start)
|
2005-08-31 13:47:05 +00:00
|
|
|
|
|
1999-10-19 11:17:23 +00:00
|
|
|
|
;; Customization
|
|
|
|
|
|
2000-09-14 12:38:09 +00:00
|
|
|
|
(defgroup ansi-colors nil
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
"Translating SGR control sequences to faces.
|
2000-09-14 12:38:09 +00:00
|
|
|
|
This translation effectively colorizes strings and regions based upon
|
|
|
|
|
SGR control sequences embedded in the text. SGR (Select Graphic
|
2012-08-15 03:33:55 +00:00
|
|
|
|
Rendition) control sequences are defined in section 8.3.117 of the
|
2013-06-20 01:03:57 +00:00
|
|
|
|
ECMA-48 standard (identical to ISO/IEC 6429), which is freely available
|
2020-10-24 18:22:33 +00:00
|
|
|
|
at <URL:https://www.ecma-international.org/publications/standards/Ecma-048.htm>
|
2013-06-20 01:03:57 +00:00
|
|
|
|
as a PDF file."
|
2001-01-10 16:58:11 +00:00
|
|
|
|
:version "21.1"
|
2000-09-14 12:38:09 +00:00
|
|
|
|
:group 'processes)
|
|
|
|
|
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
(defface ansi-color-bold
|
|
|
|
|
'((t :inherit 'bold))
|
|
|
|
|
"Face used to render bold text."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-faint
|
|
|
|
|
'((t :weight light))
|
|
|
|
|
"Face used to render faint text."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-italic
|
|
|
|
|
'((t :inherit 'italic))
|
|
|
|
|
"Face used to render italic text."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-underline
|
|
|
|
|
'((t :inherit 'underline))
|
|
|
|
|
"Face used to render underlined text."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-slow-blink
|
|
|
|
|
'((t :box (:line-width -1)))
|
|
|
|
|
"Face used to render slowly blinking text."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-fast-blink
|
|
|
|
|
'((t :box (:line-width -1)))
|
|
|
|
|
"Face used to render rapidly blinking text."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-inverse
|
|
|
|
|
'((t :inverse-video t))
|
|
|
|
|
"Face used to render inverted video text."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-black
|
|
|
|
|
'((t :foreground "black" :background "black"))
|
|
|
|
|
"Face used to render black color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-red
|
|
|
|
|
'((t :foreground "red3" :background "red3"))
|
|
|
|
|
"Face used to render red color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-green
|
|
|
|
|
'((t :foreground "green3" :background "green3"))
|
|
|
|
|
"Face used to render green color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-yellow
|
|
|
|
|
'((t :foreground "yellow3" :background "yellow3"))
|
|
|
|
|
"Face used to render yellow color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-blue
|
|
|
|
|
'((t :foreground "blue2" :background "blue2"))
|
|
|
|
|
"Face used to render blue color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-magenta
|
|
|
|
|
'((t :foreground "magenta3" :background "magenta3"))
|
|
|
|
|
"Face used to render magenta color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-cyan
|
|
|
|
|
'((t :foreground "cyan3" :background "cyan3"))
|
|
|
|
|
"Face used to render cyan color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-white
|
|
|
|
|
'((t :foreground "grey90" :background "gray90"))
|
|
|
|
|
"Face used to render white color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-bright-black
|
|
|
|
|
'((t :foreground "gray30" :background "gray30"))
|
|
|
|
|
"Face used to render bright black color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-bright-red
|
|
|
|
|
'((t :foreground "red2" :background "red2"))
|
|
|
|
|
"Face used to render bright red color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-bright-green
|
|
|
|
|
'((t :foreground "green2" :background "green2"))
|
|
|
|
|
"Face used to render bright green color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-bright-yellow
|
|
|
|
|
'((t :foreground "yellow2" :background "yellow2"))
|
|
|
|
|
"Face used to render bright yellow color code."
|
|
|
|
|
:group 'ansi-colors)
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-bright-blue
|
|
|
|
|
'((t :foreground "blue1" :background "blue1"))
|
|
|
|
|
"Face used to render bright blue color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-bright-magenta
|
|
|
|
|
'((t :foreground "magenta2" :background "magenta2"))
|
|
|
|
|
"Face used to render bright magenta color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-bright-cyan
|
|
|
|
|
'((t :foreground "cyan2" :background "cyan2"))
|
|
|
|
|
"Face used to render bright cyan color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface ansi-color-bright-white
|
|
|
|
|
'((t :foreground "white" :background "white"))
|
|
|
|
|
"Face used to render bright white color code."
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
2000-09-14 12:38:09 +00:00
|
|
|
|
(defcustom ansi-color-faces-vector
|
2012-06-02 10:56:09 +00:00
|
|
|
|
[default bold default italic underline success warning error]
|
2000-09-14 12:38:09 +00:00
|
|
|
|
"Faces used for SGR control sequences determining a face.
|
|
|
|
|
This vector holds the faces used for SGR control sequence parameters 0
|
|
|
|
|
to 7.
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
This variable is obsolete. To customize the display of faces used by
|
|
|
|
|
ansi-color, change 'ansi-color-FACE', e.g. `ansi-color-bold'. To
|
|
|
|
|
customize the actual faces used (e.g. to temporarily display SGR
|
|
|
|
|
control sequences differently), use `ansi-color-basic-faces-vector'."
|
2000-09-14 12:38:09 +00:00
|
|
|
|
:type '(vector face face face face face face face face)
|
|
|
|
|
:group 'ansi-colors)
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
(make-obsolete-variable 'ansi-color-faces-vector 'ansi-color-basic-faces-vector
|
|
|
|
|
"28.1")
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
|
|
|
|
(defcustom ansi-color-names-vector
|
2014-03-09 21:55:35 +00:00
|
|
|
|
["black" "red3" "green3" "yellow3" "blue2" "magenta3" "cyan3" "gray90"]
|
2000-09-14 12:38:09 +00:00
|
|
|
|
"Colors used for SGR control sequences determining a color.
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
This vector holds the colors used for SGR control sequence parameters
|
2013-06-20 01:03:57 +00:00
|
|
|
|
30 to 37 (foreground colors) and 40 to 47 (background colors).
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
This variable is obsolete. To customize the display of colors used by
|
|
|
|
|
ansi-color, change 'ansi-color-COLOR', e.g. `ansi-color-red'. To
|
|
|
|
|
customize the actual faces used (e.g. to temporarily display SGR
|
|
|
|
|
control sequences differently), use `ansi-color-normal-colors-vector'."
|
2011-03-27 01:56:35 +00:00
|
|
|
|
:type '(vector (choice color (cons color color))
|
|
|
|
|
(choice color (cons color color))
|
|
|
|
|
(choice color (cons color color))
|
|
|
|
|
(choice color (cons color color))
|
|
|
|
|
(choice color (cons color color))
|
|
|
|
|
(choice color (cons color color))
|
|
|
|
|
(choice color (cons color color))
|
|
|
|
|
(choice color (cons color color)))
|
2014-03-09 21:55:35 +00:00
|
|
|
|
:version "24.4" ; default colors copied from `xterm-standard-colors'
|
2000-09-14 12:38:09 +00:00
|
|
|
|
:group 'ansi-colors)
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
(make-obsolete-variable 'ansi-color-faces-vector
|
|
|
|
|
'ansi-color-normal-colors-vector "28.1")
|
|
|
|
|
|
|
|
|
|
(defvar ansi-color-basic-faces-vector
|
|
|
|
|
[nil
|
|
|
|
|
ansi-color-bold
|
|
|
|
|
ansi-color-faint
|
|
|
|
|
ansi-color-italic
|
|
|
|
|
ansi-color-underline
|
|
|
|
|
ansi-color-slow-blink
|
|
|
|
|
ansi-color-fast-blink
|
|
|
|
|
ansi-color-inverse]
|
|
|
|
|
"Faces used for SGR control sequences determining a face.
|
|
|
|
|
This vector holds the faces used for SGR control sequence parameters 0
|
|
|
|
|
to 7.
|
|
|
|
|
|
|
|
|
|
Parameter Description
|
|
|
|
|
0 default
|
|
|
|
|
1 bold
|
|
|
|
|
2 faint
|
|
|
|
|
3 italic
|
|
|
|
|
4 underlined
|
|
|
|
|
5 slowly blinking
|
|
|
|
|
6 rapidly blinking
|
|
|
|
|
7 negative image")
|
|
|
|
|
|
|
|
|
|
(defvar ansi-color-normal-colors-vector
|
|
|
|
|
[ansi-color-black
|
|
|
|
|
ansi-color-red
|
|
|
|
|
ansi-color-green
|
|
|
|
|
ansi-color-yellow
|
|
|
|
|
ansi-color-blue
|
|
|
|
|
ansi-color-magenta
|
|
|
|
|
ansi-color-cyan
|
|
|
|
|
ansi-color-white]
|
|
|
|
|
"Faces used for SGR control sequences determining a color.
|
|
|
|
|
This vector holds the faces used for SGR control sequence parameters
|
|
|
|
|
30 to 37 (foreground colors) and 40 to 47 (background colors).
|
|
|
|
|
|
|
|
|
|
Parameter Color
|
|
|
|
|
30 40 black
|
|
|
|
|
31 41 red
|
|
|
|
|
32 42 green
|
|
|
|
|
33 43 yellow
|
|
|
|
|
34 44 blue
|
|
|
|
|
35 45 magenta
|
|
|
|
|
36 46 cyan
|
|
|
|
|
37 47 white")
|
|
|
|
|
|
|
|
|
|
(defvar ansi-color-bright-colors-vector
|
|
|
|
|
[ansi-color-bright-black
|
|
|
|
|
ansi-color-bright-red
|
|
|
|
|
ansi-color-bright-green
|
|
|
|
|
ansi-color-bright-yellow
|
|
|
|
|
ansi-color-bright-blue
|
|
|
|
|
ansi-color-bright-magenta
|
|
|
|
|
ansi-color-bright-cyan
|
|
|
|
|
ansi-color-bright-white]
|
|
|
|
|
"Faces used for SGR control sequences determining a \"bright\" color.
|
|
|
|
|
This vector holds the faces used for SGR control sequence parameters
|
|
|
|
|
90 to 97 (bright foreground colors) and 100 to 107 (bright background
|
|
|
|
|
colors).
|
|
|
|
|
|
|
|
|
|
Parameter Color
|
|
|
|
|
90 100 bright black
|
|
|
|
|
91 101 bright red
|
|
|
|
|
92 102 bright green
|
|
|
|
|
93 103 bright yellow
|
|
|
|
|
94 104 bright blue
|
|
|
|
|
95 105 bright magenta
|
|
|
|
|
96 106 bright cyan
|
|
|
|
|
97 107 bright white")
|
|
|
|
|
|
|
|
|
|
(defcustom ansi-color-bold-is-bright nil
|
|
|
|
|
"If set to non-nil, combining ANSI bold and a color produces the bright
|
|
|
|
|
version of that color."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1"
|
|
|
|
|
:group 'ansi-colors)
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
2017-06-16 03:23:44 +00:00
|
|
|
|
(defconst ansi-color-control-seq-regexp
|
|
|
|
|
;; See ECMA 48, section 5.4 "Control Sequences".
|
|
|
|
|
"\e\\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]"
|
|
|
|
|
"Regexp matching an ANSI control sequence.")
|
2010-05-29 18:25:00 +00:00
|
|
|
|
|
2000-09-14 12:38:09 +00:00
|
|
|
|
(defconst ansi-color-parameter-regexp "\\([0-9]*\\)[m;]"
|
|
|
|
|
"Regexp that matches SGR control sequence parameters.")
|
|
|
|
|
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; Convenience functions for comint modes (eg. shell-mode)
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
|
|
|
|
|
2009-12-05 21:05:51 +00:00
|
|
|
|
(defcustom ansi-color-for-comint-mode t
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
"Determines what to do with comint output.
|
|
|
|
|
If nil, do nothing.
|
|
|
|
|
If the symbol `filter', then filter all SGR control sequences.
|
|
|
|
|
If anything else (such as t), then translate SGR control sequences
|
2010-05-29 18:25:00 +00:00
|
|
|
|
into text properties.
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
In order for this to have any effect, `ansi-color-process-output' must
|
|
|
|
|
be in `comint-output-filter-functions'.
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
This can be used to enable colorized ls --color=yes output
|
|
|
|
|
in shell buffers. You set this variable by calling one of:
|
|
|
|
|
\\[ansi-color-for-comint-mode-on]
|
|
|
|
|
\\[ansi-color-for-comint-mode-off]
|
|
|
|
|
\\[ansi-color-for-comint-mode-filter]"
|
|
|
|
|
:type '(choice (const :tag "Do nothing" nil)
|
|
|
|
|
(const :tag "Filter" filter)
|
|
|
|
|
(const :tag "Translate" t))
|
2009-12-06 15:33:09 +00:00
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "23.2")
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
2021-07-19 16:54:18 +00:00
|
|
|
|
(defcustom ansi-color-for-compilation-mode t
|
|
|
|
|
"Determines what to do with compilation output.
|
|
|
|
|
If nil, do nothing.
|
|
|
|
|
|
|
|
|
|
If the symbol `filter', then filter all ANSI graphical control
|
|
|
|
|
sequences.
|
|
|
|
|
|
|
|
|
|
If anything else (such as t), then translate ANSI graphical
|
|
|
|
|
control sequences into text properties.
|
|
|
|
|
|
|
|
|
|
In order for this to have any effect, `ansi-color-compilation-filter'
|
|
|
|
|
must be in `compilation-filter-hook'."
|
|
|
|
|
:type '(choice (const :tag "Do nothing" nil)
|
|
|
|
|
(const :tag "Filter" filter)
|
|
|
|
|
(other :tag "Translate" t))
|
|
|
|
|
:group 'ansi-colors
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
2017-10-12 14:18:10 +00:00
|
|
|
|
(defvar ansi-color-apply-face-function #'ansi-color-apply-overlay-face
|
2012-02-19 13:59:42 +00:00
|
|
|
|
"Function for applying an Ansi Color face to text in a buffer.
|
|
|
|
|
This function should accept three arguments: BEG, END, and FACE,
|
|
|
|
|
and it should apply face FACE to the text between BEG and END.")
|
|
|
|
|
|
2001-01-29 15:40:44 +00:00
|
|
|
|
;;;###autoload
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
(defun ansi-color-for-comint-mode-on ()
|
|
|
|
|
"Set `ansi-color-for-comint-mode' to t."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq ansi-color-for-comint-mode t))
|
|
|
|
|
|
|
|
|
|
(defun ansi-color-for-comint-mode-off ()
|
|
|
|
|
"Set `ansi-color-for-comint-mode' to nil."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq ansi-color-for-comint-mode nil))
|
|
|
|
|
|
|
|
|
|
(defun ansi-color-for-comint-mode-filter ()
|
|
|
|
|
"Set `ansi-color-for-comint-mode' to symbol `filter'."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq ansi-color-for-comint-mode 'filter))
|
|
|
|
|
|
2001-01-29 15:40:44 +00:00
|
|
|
|
;;;###autoload
|
2009-04-28 04:02:57 +00:00
|
|
|
|
(defun ansi-color-process-output (ignored)
|
2010-05-29 18:25:00 +00:00
|
|
|
|
"Maybe translate SGR control sequences of comint output into text properties.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
|
|
|
|
Depending on variable `ansi-color-for-comint-mode' the comint output is
|
|
|
|
|
either not processed, SGR control sequences are filtered using
|
|
|
|
|
`ansi-color-filter-region', or SGR control sequences are translated into
|
2010-05-29 18:25:00 +00:00
|
|
|
|
text properties using `ansi-color-apply-on-region'.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
|
|
|
|
The comint output is assumed to lie between the marker
|
|
|
|
|
`comint-last-output-start' and the process-mark.
|
|
|
|
|
|
|
|
|
|
This is a good function to put in `comint-output-filter-functions'."
|
2012-05-07 03:14:21 +00:00
|
|
|
|
(let ((start-marker (if (and (markerp comint-last-output-start)
|
|
|
|
|
(eq (marker-buffer comint-last-output-start)
|
|
|
|
|
(current-buffer))
|
|
|
|
|
(marker-position comint-last-output-start))
|
|
|
|
|
comint-last-output-start
|
|
|
|
|
(point-min-marker)))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
(end-marker (process-mark (get-buffer-process (current-buffer)))))
|
|
|
|
|
(cond ((eq ansi-color-for-comint-mode nil))
|
|
|
|
|
((eq ansi-color-for-comint-mode 'filter)
|
|
|
|
|
(ansi-color-filter-region start-marker end-marker))
|
|
|
|
|
(t
|
|
|
|
|
(ansi-color-apply-on-region start-marker end-marker)))))
|
|
|
|
|
|
2021-07-19 16:54:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun ansi-color-compilation-filter ()
|
|
|
|
|
"Maybe translate SGR control sequences into text properties.
|
|
|
|
|
This function depends on the `ansi-color-for-compilation-mode'
|
|
|
|
|
variable, and is meant to be used in `compilation-filter-hook'."
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(pcase ansi-color-for-compilation-mode
|
|
|
|
|
('nil nil)
|
|
|
|
|
('filter
|
|
|
|
|
(ansi-color-filter-region compilation-filter-start (point)))
|
|
|
|
|
(_
|
|
|
|
|
(ansi-color-apply-on-region compilation-filter-start (point))))))
|
|
|
|
|
|
Use declare forms, where possible, to mark obsolete functions.
* lisp/allout.el (allout-passphrase-hint-string): Likewise.
(allout-init): Use a declare form to mark obsolete.
* lisp/calendar/calendar.el (calendar-version):
* lisp/calendar/icalendar.el (icalendar-extract-ical-from-buffer)
(icalendar-convert-diary-to-ical):
* lisp/cus-edit.el (custom-mode):
* lisp/ansi-color.el (ansi-color-unfontify-region):
* lisp/international/latin1-disp.el (latin1-char-displayable-p):
* lisp/progmodes/cwarn.el (turn-on-cwarn-mode):
* lisp/progmodes/which-func.el (which-func-update-1): Use
define-obsolete-function-alias.
* lisp/bookmark.el (bookmark-jump-noselect): Use a declare form to mark
this function obsolete.
* lisp/calendar/cal-x.el (calendar-two-frame-setup)
(calendar-only-one-frame-setup, calendar-one-frame-setup):
* lisp/calendar/calendar.el (american-calendar, european-calendar)
(calendar-for-loop):
* lisp/comint.el (comint-dynamic-simple-complete)
(comint-dynamic-complete-as-filename, comint-unquote-filename):
* lisp/desktop.el (desktop-load-default):
* lisp/dired-x.el (dired-omit-here-always)
(dired-hack-local-variables, dired-default-directory):
* lisp/emacs-lisp/derived.el (derived-mode-class):
* lisp/emacs-lisp/timer.el (timer-set-time-with-usecs):
* lisp/emacs-lock.el (toggle-emacs-lock):
* lisp/epa.el (epa-display-verify-result):
* lisp/epg.el (epg-sign-keys, epg-start-sign-keys)
(epg-passphrase-callback-function):
* lisp/eshell/esh-util.el (eshell-for):
* lisp/eshell/eshell.el (eshell-remove-from-window-buffer-names)
(eshell-add-to-window-buffer-names):
* lisp/files.el (locate-file-completion):
* lisp/imenu.el (imenu-example--create-c-index)
(imenu-example--create-lisp-index)
(imenu-example--lisp-extract-index-name)
(imenu-example--name-and-position):
* lisp/international/mule-cmds.el (princ-list):
* lisp/international/mule-diag.el (decode-codepage-char):
* lisp/international/mule-util.el (detect-coding-with-priority):
* lisp/iswitchb.el (iswitchb-read-buffer):
* lisp/mail/mailalias.el (mail-complete):
* lisp/mail/sendmail.el (mail-sent-via):
* lisp/mouse.el (mouse-popup-menubar-stuff, mouse-popup-menubar)
(mouse-major-mode-menu):
* lisp/password-cache.el (password-read-and-add):
* lisp/pcomplete.el (pcomplete-parse-comint-arguments):
* lisp/progmodes/sh-script.el (sh-maybe-here-document):
* lisp/replace.el (query-replace-regexp-eval):
* lisp/savehist.el (savehist-load):
* lisp/simple.el (choose-completion-delete-max-match):
* lisp/term.el (term-dynamic-simple-complete):
* lisp/vc/ediff-init.el (ediff-check-version):
* lisp/vc/ediff-wind.el (ediff-choose-window-setup-function-automatically):
* lisp/vc/vc.el (vc-diff-switches-list):
* lisp/view.el (view-return-to-alist-update): Likewise.
* lisp/iswitchb.el (iswitchb-read-buffer): Move code of
iswitchb-define-mode-map here, and delete that obsolete function.
* lisp/subr.el (eval-next-after-load, makehash, insert-string)
(assoc-ignore-representation, assoc-ignore-case): Use declare to
mark obsolete.
(mode-line-inverse-video): Variable deleted.
* lisp/emacs-lisp/byte-run.el (make-obsolete): Doc fix; emphasize that
this applies to functions.
* lisp/erc/erc.el (erc-send-command): Use define-obsolete-function-alias.
* lisp/international/mule-util.el (string-to-sequence): Remove.
* lisp/net/newst-backend.el (newsticker-cache-filename):
* lisp/net/newst-treeview.el (newsticker-groups-filename): Fix
incorrect obsolescence declaration.
* lisp/net/snmp-mode.el (snmp-font-lock-keywords-3): Don't use obsolete
font-lock-reference-face.
* lisp/url/url-parse.el (url-recreate-url-attributes):
* lisp/url/url-util.el (url-generate-unique-filename): Use declare to mark
obsolete.
* src/xdisp.c (mode_line_inverse_video): Delete obsolete variable.
2012-09-25 04:13:02 +00:00
|
|
|
|
(define-obsolete-function-alias 'ansi-color-unfontify-region
|
|
|
|
|
'font-lock-default-unfontify-region "24.1")
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
|
|
|
|
;; Working with strings
|
2013-06-20 01:03:57 +00:00
|
|
|
|
(defvar-local ansi-color-context nil
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
"Context saved between two calls to `ansi-color-apply'.
|
2012-08-15 03:33:55 +00:00
|
|
|
|
This is a list of the form (CODES FRAGMENT) or nil. CODES
|
|
|
|
|
represents the state the last call to `ansi-color-apply' ended
|
|
|
|
|
with, currently a list of ansi codes, and FRAGMENT is a string
|
|
|
|
|
starting with an escape sequence, possibly the start of a new
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
escape sequence.")
|
|
|
|
|
|
|
|
|
|
(defun ansi-color-filter-apply (string)
|
2010-05-29 18:25:00 +00:00
|
|
|
|
"Filter out all ANSI control sequences from STRING.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
|
|
|
|
Every call to this function will set and use the buffer-local variable
|
|
|
|
|
`ansi-color-context' to save partial escape sequences. This information
|
|
|
|
|
will be used for the next call to `ansi-color-apply'. Set
|
|
|
|
|
`ansi-color-context' to nil if you don't want this.
|
1999-08-04 16:49:19 +00:00
|
|
|
|
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
This function can be added to `comint-preoutput-filter-functions'."
|
|
|
|
|
(let ((start 0) end result)
|
|
|
|
|
;; if context was saved and is a string, prepend it
|
|
|
|
|
(if (cadr ansi-color-context)
|
|
|
|
|
(setq string (concat (cadr ansi-color-context) string)
|
|
|
|
|
ansi-color-context nil))
|
|
|
|
|
;; find the next escape sequence
|
2017-06-16 03:23:44 +00:00
|
|
|
|
(while (setq end (string-match ansi-color-control-seq-regexp string start))
|
|
|
|
|
(push (substring string start end) result)
|
|
|
|
|
(setq start (match-end 0)))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; save context, add the remainder of the string to the result
|
|
|
|
|
(let (fragment)
|
2017-06-16 03:23:44 +00:00
|
|
|
|
(push (substring string start
|
|
|
|
|
(if (string-match "\033" string start)
|
|
|
|
|
(let ((pos (match-beginning 0)))
|
|
|
|
|
(setq fragment (substring string pos))
|
|
|
|
|
pos)
|
|
|
|
|
nil))
|
|
|
|
|
result)
|
2010-12-06 16:51:37 +00:00
|
|
|
|
(setq ansi-color-context (if fragment (list nil fragment))))
|
2017-06-16 03:23:44 +00:00
|
|
|
|
(apply #'concat (nreverse result))))
|
1999-10-19 11:17:23 +00:00
|
|
|
|
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(defun ansi-color--find-face (codes)
|
|
|
|
|
"Return the face corresponding to CODES."
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
;; Sort the codes in ascending order to guarantee that "bold" comes before
|
|
|
|
|
;; any of the colors. This ensures that `ansi-color-bold-is-bright' is
|
|
|
|
|
;; applied correctly.
|
|
|
|
|
(let (faces bright (codes (sort (copy-sequence codes) #'<)))
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(while codes
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
(when-let ((face (ansi-color-get-face-1 (pop codes) bright)))
|
|
|
|
|
(when (and ansi-color-bold-is-bright (eq face 'ansi-color-bold))
|
|
|
|
|
(setq bright t))
|
|
|
|
|
(push face faces)))
|
2012-08-15 03:33:55 +00:00
|
|
|
|
;; Avoid some long-lived conses in the common case.
|
|
|
|
|
(if (cdr faces)
|
|
|
|
|
(nreverse faces)
|
|
|
|
|
(car faces))))
|
|
|
|
|
|
1999-10-19 11:17:23 +00:00
|
|
|
|
(defun ansi-color-apply (string)
|
2010-05-29 18:25:00 +00:00
|
|
|
|
"Translates SGR control sequences into text properties.
|
|
|
|
|
Delete all other control sequences without processing them.
|
1999-10-19 11:17:23 +00:00
|
|
|
|
|
2000-09-14 12:38:09 +00:00
|
|
|
|
Applies SGR control sequences setting foreground and background colors
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
to STRING using text properties and returns the result. See function
|
|
|
|
|
`ansi-color-apply-sequence' for details.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
|
|
|
|
Every call to this function will set and use the buffer-local variable
|
2012-08-15 03:33:55 +00:00
|
|
|
|
`ansi-color-context' to save partial escape sequences and current ansi codes.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
This information will be used for the next call to `ansi-color-apply'.
|
|
|
|
|
Set `ansi-color-context' to nil if you don't want this.
|
|
|
|
|
|
2010-12-06 16:51:37 +00:00
|
|
|
|
This function can be added to `comint-preoutput-filter-functions'."
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(let ((codes (car ansi-color-context))
|
2017-06-16 03:23:44 +00:00
|
|
|
|
(start 0) end result)
|
2010-05-29 18:25:00 +00:00
|
|
|
|
;; If context was saved and is a string, prepend it.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
(if (cadr ansi-color-context)
|
|
|
|
|
(setq string (concat (cadr ansi-color-context) string)
|
|
|
|
|
ansi-color-context nil))
|
2010-05-29 18:25:00 +00:00
|
|
|
|
;; Find the next escape sequence.
|
2017-06-16 03:23:44 +00:00
|
|
|
|
(while (setq end (string-match ansi-color-control-seq-regexp string start))
|
|
|
|
|
(let ((esc-end (match-end 0)))
|
|
|
|
|
;; Colorize the old block from start to end using old face.
|
|
|
|
|
(when codes
|
|
|
|
|
(put-text-property start end 'font-lock-face
|
|
|
|
|
(ansi-color--find-face codes) string))
|
|
|
|
|
(push (substring string start end) result)
|
|
|
|
|
(setq start (match-end 0))
|
|
|
|
|
;; If this is a color escape sequence,
|
|
|
|
|
(when (eq (aref string (1- esc-end)) ?m)
|
|
|
|
|
;; create a new face from it.
|
|
|
|
|
(setq codes (ansi-color-apply-sequence
|
|
|
|
|
(substring string end esc-end) codes)))))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; if the rest of the string should have a face, put it there
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(when codes
|
2013-06-20 01:03:57 +00:00
|
|
|
|
(put-text-property start (length string)
|
|
|
|
|
'font-lock-face (ansi-color--find-face codes) string))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; save context, add the remainder of the string to the result
|
|
|
|
|
(let (fragment)
|
|
|
|
|
(if (string-match "\033" string start)
|
|
|
|
|
(let ((pos (match-beginning 0)))
|
2010-05-29 18:25:00 +00:00
|
|
|
|
(setq fragment (substring string pos))
|
|
|
|
|
(push (substring string start pos) result))
|
|
|
|
|
(push (substring string start) result))
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(setq ansi-color-context (if (or codes fragment) (list codes fragment))))
|
2010-05-29 18:25:00 +00:00
|
|
|
|
(apply 'concat (nreverse result))))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
|
|
|
|
;; Working with regions
|
|
|
|
|
|
2013-06-20 01:03:57 +00:00
|
|
|
|
(defvar-local ansi-color-context-region nil
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
"Context saved between two calls to `ansi-color-apply-on-region'.
|
2012-08-15 03:33:55 +00:00
|
|
|
|
This is a list of the form (CODES MARKER) or nil. CODES
|
|
|
|
|
represents the state the last call to `ansi-color-apply-on-region'
|
|
|
|
|
ended with, currently a list of ansi codes, and MARKER is a
|
|
|
|
|
buffer position within an escape sequence or the last position
|
|
|
|
|
processed.")
|
1999-10-19 11:17:23 +00:00
|
|
|
|
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
(defun ansi-color-filter-region (begin end)
|
2010-05-29 18:25:00 +00:00
|
|
|
|
"Filter out all ANSI control sequences from region BEGIN to END.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
|
|
|
|
Every call to this function will set and use the buffer-local variable
|
|
|
|
|
`ansi-color-context-region' to save position. This information will be
|
|
|
|
|
used for the next call to `ansi-color-apply-on-region'. Specifically,
|
|
|
|
|
it will override BEGIN, the start of the region. Set
|
|
|
|
|
`ansi-color-context-region' to nil if you don't want this."
|
|
|
|
|
(let ((end-marker (copy-marker end))
|
|
|
|
|
(start (or (cadr ansi-color-context-region) begin)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char start)
|
2017-06-16 03:23:44 +00:00
|
|
|
|
;; Delete escape sequences.
|
|
|
|
|
(while (re-search-forward ansi-color-control-seq-regexp end-marker t)
|
|
|
|
|
(delete-region (match-beginning 0) (match-end 0)))
|
2010-05-29 18:25:00 +00:00
|
|
|
|
;; save context, add the remainder of the string to the result
|
|
|
|
|
(if (re-search-forward "\033" end-marker t)
|
|
|
|
|
(setq ansi-color-context-region (list nil (match-beginning 0)))
|
|
|
|
|
(setq ansi-color-context-region nil)))))
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
2020-11-14 15:24:26 +00:00
|
|
|
|
(defun ansi-color-apply-on-region (begin end &optional preserve-sequences)
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
"Translates SGR control sequences into overlays or extents.
|
2010-05-29 18:25:00 +00:00
|
|
|
|
Delete all other control sequences without processing them.
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
2012-06-23 09:28:10 +00:00
|
|
|
|
SGR control sequences are applied by calling the function
|
|
|
|
|
specified by `ansi-color-apply-face-function'. The default
|
|
|
|
|
function sets foreground and background colors to the text
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
between BEGIN and END, using overlays. See function
|
2012-06-23 09:28:10 +00:00
|
|
|
|
`ansi-color-apply-sequence' for details.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
2012-08-15 03:33:55 +00:00
|
|
|
|
Every call to this function will set and use the buffer-local
|
|
|
|
|
variable `ansi-color-context-region' to save position and current
|
|
|
|
|
ansi codes. This information will be used for the next call to
|
|
|
|
|
`ansi-color-apply-on-region'. Specifically, it will override
|
|
|
|
|
BEGIN, the start of the region and set the face with which to
|
|
|
|
|
start. Set `ansi-color-context-region' to nil if you don't want
|
2020-11-14 15:24:26 +00:00
|
|
|
|
this.
|
|
|
|
|
|
|
|
|
|
If PRESERVE-SEQUENCES is t, the sequences are hidden instead of
|
|
|
|
|
being deleted."
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(let ((codes (car ansi-color-context-region))
|
2020-11-14 15:24:26 +00:00
|
|
|
|
(start-marker (or (cadr ansi-color-context-region)
|
|
|
|
|
(copy-marker begin)))
|
|
|
|
|
(end-marker (copy-marker end)))
|
2000-09-14 12:38:09 +00:00
|
|
|
|
(save-excursion
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
(goto-char start-marker)
|
2017-06-16 03:23:44 +00:00
|
|
|
|
;; Find the next escape sequence.
|
|
|
|
|
(while (re-search-forward ansi-color-control-seq-regexp end-marker t)
|
2020-11-14 15:24:26 +00:00
|
|
|
|
;; Extract escape sequence.
|
|
|
|
|
(let ((esc-seq (buffer-substring
|
2017-06-16 03:23:44 +00:00
|
|
|
|
(match-beginning 0) (point))))
|
2020-11-14 15:24:26 +00:00
|
|
|
|
(if preserve-sequences
|
|
|
|
|
;; Make the escape sequence transparent.
|
|
|
|
|
(overlay-put (make-overlay (match-beginning 0) (point))
|
|
|
|
|
'invisible t)
|
|
|
|
|
;; Otherwise, strip.
|
|
|
|
|
(delete-region (match-beginning 0) (point)))
|
|
|
|
|
|
2017-06-16 03:23:44 +00:00
|
|
|
|
;; Colorize the old block from start to end using old face.
|
|
|
|
|
(funcall ansi-color-apply-face-function
|
|
|
|
|
(prog1 (marker-position start-marker)
|
|
|
|
|
;; Store new start position.
|
|
|
|
|
(set-marker start-marker (point)))
|
|
|
|
|
(match-beginning 0) (ansi-color--find-face codes))
|
|
|
|
|
;; If this is a color sequence,
|
|
|
|
|
(when (eq (aref esc-seq (1- (length esc-seq))) ?m)
|
|
|
|
|
;; update the list of ansi codes.
|
|
|
|
|
(setq codes (ansi-color-apply-sequence esc-seq codes)))))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; search for the possible start of a new escape sequence
|
|
|
|
|
(if (re-search-forward "\033" end-marker t)
|
|
|
|
|
(progn
|
|
|
|
|
;; if the rest of the region should have a face, put it there
|
2012-02-19 13:59:42 +00:00
|
|
|
|
(funcall ansi-color-apply-face-function
|
2012-08-15 03:33:55 +00:00
|
|
|
|
start-marker (point) (ansi-color--find-face codes))
|
|
|
|
|
;; save codes and point
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
(setq ansi-color-context-region
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(list codes (copy-marker (match-beginning 0)))))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; if the rest of the region should have a face, put it there
|
2012-02-19 13:59:42 +00:00
|
|
|
|
(funcall ansi-color-apply-face-function
|
2012-08-15 03:33:55 +00:00
|
|
|
|
start-marker end-marker (ansi-color--find-face codes))
|
2020-10-20 11:09:16 +00:00
|
|
|
|
;; Save a restart position when there are codes active. It's
|
|
|
|
|
;; convenient for man.el's process filter to pass `begin'
|
|
|
|
|
;; positions that overlap regions previously colored; these
|
|
|
|
|
;; `codes' should not be applied to that overlap, so we need
|
|
|
|
|
;; to know where they should really start.
|
2021-02-22 15:47:38 +00:00
|
|
|
|
(setq ansi-color-context-region
|
|
|
|
|
(if codes (list codes (copy-marker (point)))))))
|
2019-05-04 18:47:29 +00:00
|
|
|
|
;; Clean up our temporary markers.
|
|
|
|
|
(unless (eq start-marker (cadr ansi-color-context-region))
|
|
|
|
|
(set-marker start-marker nil))
|
2020-10-20 11:09:16 +00:00
|
|
|
|
(unless (eq end-marker (cadr ansi-color-context-region))
|
|
|
|
|
(set-marker end-marker nil))))
|
2012-02-19 13:59:42 +00:00
|
|
|
|
|
|
|
|
|
(defun ansi-color-apply-overlay-face (beg end face)
|
|
|
|
|
"Make an overlay from BEG to END, and apply face FACE.
|
|
|
|
|
If FACE is nil, do nothing."
|
|
|
|
|
(when face
|
2019-06-19 19:56:43 +00:00
|
|
|
|
(overlay-put (ansi-color-make-extent beg end) 'face face)))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
2019-05-04 18:47:29 +00:00
|
|
|
|
(defun ansi-color-apply-text-property-face (beg end face)
|
|
|
|
|
"Set the `font-lock-face' property to FACE in region BEG..END.
|
|
|
|
|
If FACE is nil, do nothing."
|
|
|
|
|
(when face
|
|
|
|
|
(put-text-property beg end 'font-lock-face face)))
|
|
|
|
|
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; This function helps you look for overlapping overlays. This is
|
2011-12-05 08:55:25 +00:00
|
|
|
|
;; useful in comint-buffers. Overlapping overlays should not happen!
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
;; A possible cause for bugs are the markers. If you create an overlay
|
|
|
|
|
;; up to the end of the region, then that end might coincide with the
|
|
|
|
|
;; process-mark. As text is added BEFORE the process-mark, the overlay
|
|
|
|
|
;; will keep growing. Therefore, as more overlays are created later on,
|
|
|
|
|
;; there will be TWO OR MORE overlays covering the buffer at that point.
|
|
|
|
|
;; This function helps you check your buffer for these situations.
|
|
|
|
|
; (defun ansi-color-debug-overlays ()
|
|
|
|
|
; (interactive)
|
|
|
|
|
; (let ((pos (point-min)))
|
|
|
|
|
; (while (< pos (point-max))
|
|
|
|
|
; (if (<= 2 (length (overlays-at pos)))
|
|
|
|
|
; (progn
|
|
|
|
|
; (goto-char pos)
|
|
|
|
|
; (error "%d overlays at %d" (length (overlays-at pos)) pos))
|
|
|
|
|
; (let (message-log-max)
|
|
|
|
|
; (message "Reached %d." pos)))
|
|
|
|
|
; (setq pos (next-overlay-change pos)))))
|
|
|
|
|
|
|
|
|
|
(defun ansi-color-make-face (property color)
|
|
|
|
|
"Return a face with PROPERTY set to COLOR.
|
2003-02-04 11:26:42 +00:00
|
|
|
|
PROPERTY can be either symbol `foreground' or symbol `background'.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
2019-06-19 19:56:43 +00:00
|
|
|
|
For Emacs, we just return the cons cell (PROPERTY . COLOR)."
|
|
|
|
|
(cond ((eq property 'foreground)
|
|
|
|
|
(cons 'foreground-color color))
|
|
|
|
|
((eq property 'background)
|
|
|
|
|
(cons 'background-color color))
|
|
|
|
|
(t
|
|
|
|
|
(cons property color))))
|
|
|
|
|
|
|
|
|
|
(defun ansi-color-make-extent (from to &optional buffer)
|
|
|
|
|
"Make an extent for the range [FROM, TO) in BUFFER.
|
|
|
|
|
|
|
|
|
|
BUFFER defaults to the current buffer."
|
|
|
|
|
;; The overlay might end at the process-mark in comint
|
|
|
|
|
;; buffers. In that case, new text will be inserted before the
|
|
|
|
|
;; process-mark, ie. inside the overlay (using insert-before-marks).
|
|
|
|
|
;; In order to avoid this, we use the `insert-behind-hooks' overlay
|
|
|
|
|
;; property to make sure it works.
|
|
|
|
|
(let ((overlay (make-overlay from to buffer)))
|
|
|
|
|
(overlay-put overlay 'evaporate t)
|
|
|
|
|
(overlay-put overlay 'modification-hooks '(ansi-color-freeze-overlay))
|
|
|
|
|
(overlay-put overlay 'insert-behind-hooks '(ansi-color-freeze-overlay))
|
|
|
|
|
overlay))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
|
|
|
|
(defun ansi-color-freeze-overlay (overlay is-after begin end &optional len)
|
|
|
|
|
"Prevent OVERLAY from being extended.
|
|
|
|
|
This function can be used for the `modification-hooks' overlay
|
|
|
|
|
property."
|
|
|
|
|
;; if stuff was inserted at the end of the overlay
|
|
|
|
|
(when (and is-after
|
|
|
|
|
(= 0 len)
|
|
|
|
|
(= end (overlay-end overlay)))
|
|
|
|
|
;; reset the end of the overlay
|
|
|
|
|
(move-overlay overlay (overlay-start overlay) begin)))
|
|
|
|
|
|
|
|
|
|
(defun ansi-color-set-extent-face (extent face)
|
2019-06-19 19:56:43 +00:00
|
|
|
|
"Set the `face' property of EXTENT to FACE."
|
|
|
|
|
(declare (obsolete overlay-put "27.1"))
|
|
|
|
|
(overlay-put extent 'face face))
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
1999-10-19 11:17:23 +00:00
|
|
|
|
;; Helper functions
|
|
|
|
|
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(defsubst ansi-color-parse-sequence (escape-seq)
|
|
|
|
|
"Return the list of all the parameters in ESCAPE-SEQ.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
2012-08-15 03:33:55 +00:00
|
|
|
|
ESCAPE-SEQ is a SGR control sequences such as \\033[34m. The parameter
|
|
|
|
|
34 is used by `ansi-color-get-face-1' to return a face definition.
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
2012-08-15 03:33:55 +00:00
|
|
|
|
Returns nil only if there's no match for `ansi-color-parameter-regexp'."
|
|
|
|
|
(let ((i 0)
|
|
|
|
|
codes val)
|
|
|
|
|
(while (string-match ansi-color-parameter-regexp escape-seq i)
|
|
|
|
|
(setq i (match-end 0)
|
|
|
|
|
val (string-to-number (match-string 1 escape-seq) 10))
|
|
|
|
|
;; It so happens that (string-to-number "") => 0.
|
|
|
|
|
(push val codes))
|
|
|
|
|
(nreverse codes)))
|
|
|
|
|
|
|
|
|
|
(defun ansi-color-apply-sequence (escape-sequence codes)
|
2013-06-20 01:03:57 +00:00
|
|
|
|
"Apply ESCAPE-SEQUENCE to CODES and return the new list of codes.
|
2012-08-15 03:33:55 +00:00
|
|
|
|
|
2013-06-20 01:03:57 +00:00
|
|
|
|
ESCAPE-SEQUENCE is an escape sequence parsed by
|
|
|
|
|
`ansi-color-parse-sequence'.
|
2012-08-15 03:33:55 +00:00
|
|
|
|
|
2012-11-12 17:12:33 +00:00
|
|
|
|
For each new code, the following happens: if it is 1-7, add it to
|
|
|
|
|
the list of codes; if it is 21-25 or 27, delete appropriate
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
parameters from the list of codes; if it is 30-37 (or 90-97) resp. 39,
|
|
|
|
|
the foreground color code is replaced or added resp. deleted; if it
|
|
|
|
|
is 40-47 (or 100-107) resp. 49, the background color code is replaced
|
|
|
|
|
or added resp. deleted; any other code is discarded together with the
|
|
|
|
|
old codes. Finally, the so changed list of codes is returned."
|
2012-08-15 03:33:55 +00:00
|
|
|
|
(let ((new-codes (ansi-color-parse-sequence escape-sequence)))
|
|
|
|
|
(while new-codes
|
2012-11-12 17:12:33 +00:00
|
|
|
|
(let* ((new (pop new-codes))
|
|
|
|
|
(q (/ new 10)))
|
|
|
|
|
(setq codes
|
|
|
|
|
(pcase q
|
|
|
|
|
(0 (unless (memq new '(0 8 9))
|
|
|
|
|
(cons new (remq new codes))))
|
|
|
|
|
(2 (unless (memq new '(20 26 28 29))
|
|
|
|
|
;; The standard says `21 doubly underlined' while
|
2020-10-01 13:24:21 +00:00
|
|
|
|
;; https://en.wikipedia.org/wiki/ANSI_escape_code claims
|
2012-11-12 17:12:33 +00:00
|
|
|
|
;; `21 Bright/Bold: off or Underline: Double'.
|
|
|
|
|
(remq (- new 20) (pcase new
|
|
|
|
|
(22 (remq 1 codes))
|
|
|
|
|
(25 (remq 6 codes))
|
|
|
|
|
(_ codes)))))
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
((or 3 4 9 10) (let ((r (mod new 10)))
|
2012-11-12 17:12:33 +00:00
|
|
|
|
(unless (= r 8)
|
|
|
|
|
(let (beg)
|
|
|
|
|
(while (and codes (/= q (/ (car codes) 10)))
|
|
|
|
|
(push (pop codes) beg))
|
|
|
|
|
(setq codes (nconc (nreverse beg) (cdr codes)))
|
|
|
|
|
(if (= r 9)
|
|
|
|
|
codes
|
|
|
|
|
(cons new codes))))))
|
|
|
|
|
(_ nil)))))
|
2012-08-15 03:33:55 +00:00
|
|
|
|
codes))
|
(ansi-color-process-output): Use markers instead
of positions for start and end of region.
(ansi-color-apply-on-region): Rewrote code to make it more robust.
Previously, occasional mistakes happend when fontifying many
chunks of output (eg. ls --color=yes /dev). This happened
whenever an overlay was created up to the end of the region, which
coincided with the process-mark. New text would then be added
within that overlay instead of after it.
(ansi-color-make-extent): Overlays are created with the property
`modification-hooks' set to '(ansi-color-freeze-overlay).
(ansi-color-freeze-overlay): New function. When inserting text at
the end of the overlay, the overlay will resize.
(ansi-color-process-output): Doc change.
(ansi-color-unfontify-region): Doc change. No longer installed
automatically in font-lock-unfontify-region-function.
(ansi-color-apply): Doc change.
(ansi-color-apply-on-region): Use extents or overlays instead of
text-properties.
(ansi-color-make-extent): New function.
(ansi-color-set-extent-face): New function.
(ansi-color-process): Removed, Emacs and XEmacs
both use ansi-color-process-output, now.
(ansi-color-process-output): Doesn't return string anymore. It is
installed in comint-output-filter-functions for both Emacs and
XEmacs, now.
(ansi-color-unfontify-region): Simplified code removing variables
pos and start-ansi.
(ansi-color-apply): Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-context-region): Doc change.
(ansi-color-filter-region): Simplified code.
(ansi-color-apply-on-region): Changed start to start-marker, using
a marker explicitly. Put text-property ansi-color before putting
text-property face because ansi-color-unfontify-region is called
immediately after the call to put-text-property.
(ansi-color-faces-vector): Doc change.
(ansi-color-for-comint-mode): Changed :type property to choice.
(ansi-color-last-context): Removed.
(ansi-color-process-output): Don't use ansi-color-last-context, as
the main functions will store their context now.
(ansi-color-context): Doc change.
(ansi-color-filter-apply): Rewrote it based on ansi-color-apply.
Uses ansi-color-context such that repeated calls will strip
partial escape sequences, too.
(ansi-color-apply): Simplified code. Colorize end of string if
face is not null. Store context in new (FACE STRING) format, such
that repeated calls will strip partial escape sequences, too.
Append faces to face property using ansi-color-apply-sequence such
that cumulative mode actually works.
(ansi-color-context-region): New variable.
(ansi-color-filter-region): Rewrote it based on
ansi-color-apply-on-region. Uses ansi-color-context-region such
that repeated calls will strip partial escape sequences, too.
(ansi-color-apply-on-region): Simplified code. Colorize end of
region if face is not null. Store context in new (FACE POS)
format, such that repeated calls will strip partial escape
sequences, too. Append faces to face property using
ansi-color-apply-sequence such that cumulative mode actually
works.
(ansi-color-apply-sequence): New function.
(ansi-color-get-face): When the default face is added to the list
of faces, all previous settings are discarded and the list of
faces is set to '(default).
(ansi-color-faces-vector): Use nil for the default
face, such that ansi-color-apply and ansi-color-apply-on-region
will do the right thing.
(ansi-color-apply): Do the right thing, ie. if ansi-color-get-face
returns nil, set the list of faces back to nil instead of
appending the result of ansi-color-get-face to the front of the
list.
(ansi-color-for-comint-mode): Doc change.
(ansi-color-process): Doc change.
(ansi-color-last-context): New buffer-local variable.
(ansi-color-process-output): New function. It is automatically
added to comint-output-filter-functions if this is XEmacs.
(ansi-color-unfontify-region): New optional parameter for XEmacs
compatibility. Check wether font-lock-syntactic-keywords is
boundp before removing the syntax table text property, as XEmacs
doesn't have it.
(ansi-color-filter-region): Doc change.
(ansi-color-apply-on-region): Doc change.
(ansi-color-make-face): New function. Compatibility layer for
XEmacs. Return temporary faces instead of cons cells for XEmacs.
(ansi-color-make-color-map): Use ansi-color-make-face.
(ansi-color-get-face): Avoid face text property '(nil) as results
in an errow for XEmacs.
(ansi-color-unfontify-region): New function. Uses
text-property ansi-color in order to preserve fontification by
ansi-color. When the package is loaded, a lambda expression is
put onto font-lock-mode-hook. This lambda expression will check
font-lock-unfontify-region-function and replace
font-lock-default-unfontify-region with
ansi-color-unfontify-region.
(ansi-color-apply): Add text-property ansi-color in addition to
text-property face.
(ansi-color-apply-on-region): Add text-property ansi-color in
addition to text-property face.
(save-buffer-state): Copy of the macro that is also used by
lazy-lock and font-lock.
(ansi-color-for-comint-mode): New option.
(ansi-color-for-comint-mode-on): Set ansi-color-for-comint-mode.
(ansi-color-for-comint-mode-off): Ditto.
(ansi-color-for-comint-mode-filter): Ditto.
(ansi-color-process): New function. Uses
ansi-color-for-comint-mode to decide what to do. This function is
added to comint-preoutput-filter-functions when the package is
loaded.
(ansi-color-for-shell-mode-set): Removed.
(ansi-color-for-shell-mode): Removed.
(ansi-color-for-shell-mode-set): New function with
the lambda expression from the ansi-color-for-shell-mode :set
property. Additionally, modify shell-mode-hook to enable or
disable font-lock-mode for future shell buffers.
(ansi-color-for-shell-mode): The :set property calls
ansi-color-for-shell-mode-set instead of a lambda expression.
(ansi-color-for-shell-mode): Doc change.
(ansi-color-context): New variable.
(ansi-color-apply): Save context between calls.
2001-01-09 11:38:28 +00:00
|
|
|
|
|
2000-09-14 12:38:09 +00:00
|
|
|
|
(defun ansi-color-make-color-map ()
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Create a vector of face definitions and return it.
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
|
|
|
|
The index into the vector is an ANSI code. See the documentation of
|
|
|
|
|
`ansi-color-map' for an example.
|
|
|
|
|
|
|
|
|
|
The face definitions are based upon the variables
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
`ansi-color-faces-vector' and `ansi-color-names-vector'.
|
|
|
|
|
|
|
|
|
|
This function is obsolete, and no longer needed to use ansi-color."
|
2021-08-26 13:22:28 +00:00
|
|
|
|
(let ((map (make-vector 50 nil))
|
2000-09-14 12:38:09 +00:00
|
|
|
|
(index 0))
|
|
|
|
|
;; miscellaneous attributes
|
2007-09-25 10:42:16 +00:00
|
|
|
|
(mapc
|
2020-11-12 21:06:47 +00:00
|
|
|
|
(lambda (e)
|
|
|
|
|
(aset map index e)
|
|
|
|
|
(setq index (1+ index)) )
|
2000-09-14 12:38:09 +00:00
|
|
|
|
ansi-color-faces-vector)
|
|
|
|
|
;; foreground attributes
|
2021-08-26 13:22:28 +00:00
|
|
|
|
(setq index 30)
|
|
|
|
|
(mapc
|
|
|
|
|
(lambda (e)
|
|
|
|
|
(aset map index
|
|
|
|
|
(ansi-color-make-face 'foreground
|
|
|
|
|
(if (consp e) (car e) e)))
|
|
|
|
|
(setq index (1+ index)) )
|
|
|
|
|
ansi-color-names-vector)
|
2000-09-14 12:38:09 +00:00
|
|
|
|
;; background attributes
|
2021-08-26 13:22:28 +00:00
|
|
|
|
(setq index 40)
|
|
|
|
|
(mapc
|
|
|
|
|
(lambda (e)
|
|
|
|
|
(aset map index
|
|
|
|
|
(ansi-color-make-face 'background
|
|
|
|
|
(if (consp e) (cdr e) e)))
|
|
|
|
|
(setq index (1+ index)) )
|
|
|
|
|
ansi-color-names-vector)
|
2013-06-20 01:03:57 +00:00
|
|
|
|
map))
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
(make-obsolete 'ansi-color-make-color-map "you can remove it." "28.1")
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
(defvar ansi-color-map
|
|
|
|
|
(with-no-warnings (ansi-color-make-color-map))
|
|
|
|
|
"A brand new color map, formerly suitable for `ansi-color-get-face'.
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
|
|
|
|
The value of this variable is usually constructed by
|
|
|
|
|
`ansi-color-make-color-map'. The values in the array are such that the
|
|
|
|
|
numbers included in an SGR control sequences point to the correct
|
|
|
|
|
foreground or background colors.
|
|
|
|
|
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
This variable is obsolete, and no longer needed to use ansi-color.")
|
|
|
|
|
(make-obsolete-variable 'ansi-color-map "you can remove it." "28.1")
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
|
|
|
|
(defun ansi-color-map-update (symbol value)
|
|
|
|
|
"Update `ansi-color-map'.
|
|
|
|
|
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
This function is obsolete, and no longer needed to use ansi-color."
|
2000-09-14 12:38:09 +00:00
|
|
|
|
(set-default symbol value)
|
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic)
(ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink)
(ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow)
(ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white)
(ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow)
(ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan)
(ansi-color-bright-white): New faces.
(ansi-color-basic-faces-vector, ansi-color-normal-colors-vector)
(ansi-color-bright-colors-vector): New constants.
(ansi-color-faces-vector, ansi-color-names-vector): Make obsolete.
(ansi-color-bold-is-bright): New defcustom.
(ansi-color--find-face): Sort ANSI codes and check
'ansi-color-bold-is-bright'.
(ansi-color-apply-sequence): Support bright ANSI colors.
(ansi-color-make-color-map, ansi-color-map, ansi-color-map-update):
Make obsolete.
(ansi-color-get-face-1): Add BRIGHT parameter.
* lisp/man.el (Man-ansi-color-basic-faces-vector): New variable.
(Man-ansi-color-map): Make obsolete.
(Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here.
* test/lisp/ansi-color-tests.el
(ansi-color-apply-on-region-bold-is-bright-test): New function.
2021-09-23 01:37:52 +00:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(setq ansi-color-map (ansi-color-make-color-map))))
|
|
|
|
|
(make-obsolete 'ansi-color-map-update "you can remove it." "28.1")
|
|
|
|
|
|
|
|
|
|
(defun ansi-color-get-face-1 (ansi-code &optional bright)
|
|
|
|
|
"Get face definition for ANSI-CODE.
|
|
|
|
|
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))
|
|
|
|
|
((<= 30 ansi-code 38)
|
|
|
|
|
(list :foreground
|
|
|
|
|
(face-foreground
|
|
|
|
|
(aref ansi-color-normal-colors-vector (- ansi-code 30))
|
|
|
|
|
nil 'default)))
|
|
|
|
|
((<= 40 ansi-code 48)
|
|
|
|
|
(list :background
|
|
|
|
|
(face-background
|
|
|
|
|
(aref ansi-color-normal-colors-vector (- ansi-code 40))
|
|
|
|
|
nil 'default)))
|
|
|
|
|
((<= 90 ansi-code 98)
|
|
|
|
|
(list :foreground
|
|
|
|
|
(face-foreground
|
|
|
|
|
(aref ansi-color-bright-colors-vector (- ansi-code 90))
|
|
|
|
|
nil 'default)))
|
|
|
|
|
((<= 100 ansi-code 108)
|
|
|
|
|
(list :background
|
|
|
|
|
(face-background
|
|
|
|
|
(aref ansi-color-bright-colors-vector (- ansi-code 100))
|
|
|
|
|
nil 'default)))))
|
2000-09-14 12:38:09 +00:00
|
|
|
|
|
1999-08-04 16:49:19 +00:00
|
|
|
|
(provide 'ansi-color)
|
|
|
|
|
|
1999-10-19 11:17:23 +00:00
|
|
|
|
;;; ansi-color.el ends here
|