[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f7f2024: Add function for filtering ANSI sequences when compiling
From: |
Lars Ingebrigtsen |
Subject: |
master f7f2024: Add function for filtering ANSI sequences when compiling |
Date: |
Mon, 19 Jul 2021 12:54:33 -0400 (EDT) |
branch: master
commit f7f2024b86bdcf028ce942e59d1cfdba89747d0b
Author: Ivan Sokolov <ivan-p-sokolov@ya.ru>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add function for filtering ANSI sequences when compiling
* lisp/ansi-color.el (ansi-color-for-compilation-mode): New user
option (bug#49609).
(ansi-color-compilation-filter): New function.
---
etc/NEWS | 8 ++++++++
lisp/ansi-color.el | 32 ++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 0c90683..7bf4233 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1601,6 +1601,14 @@ Defaults to 'libravatar', with 'unicornify' and
'gravatar' as options.
** Compilation mode
+---
+*** New function 'ansi-color-compilation-filter'.
+This function is meant to be used in 'compilation-filter-hook'.
+
+---
+*** New user option 'ansi-color-for-compilation-mode'.
+This controls what 'ansi-color-compilation-filter' does.
+
*** Regexp matching of messages is now case-sensitive by default.
The variable 'compilation-error-case-fold-search' can be set for
case-insensitive matching of messages when the old behavior is
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index 44dc035..79dc821 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -75,6 +75,7 @@
;;; Code:
(defvar comint-last-output-start)
+(defvar compilation-filter-start)
;; Customization
@@ -181,6 +182,24 @@ in shell buffers. You set this variable by calling one of:
:group 'ansi-colors
:version "23.2")
+(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")
+
(defvar ansi-color-apply-face-function #'ansi-color-apply-overlay-face
"Function for applying an Ansi Color face to text in a buffer.
This function should accept three arguments: BEG, END, and FACE,
@@ -228,6 +247,19 @@ This is a good function to put in
`comint-output-filter-functions'."
(t
(ansi-color-apply-on-region start-marker end-marker)))))
+;;;###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))))))
+
(define-obsolete-function-alias 'ansi-color-unfontify-region
'font-lock-default-unfontify-region "24.1")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f7f2024: Add function for filtering ANSI sequences when compiling,
Lars Ingebrigtsen <=