summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2022-11-30 19:49:42 +0100
committerUlrich Müller <ulm@gentoo.org>2022-11-30 19:49:42 +0100
commite44b6e8d161dadbccdbeb9c72ed6d531dbf9cc40 (patch)
treec8bd2df339695ec8330f5b23ade917bf4be30c61
parentProvide own history lists for ebuild-run-command and friends (diff)
downloadebuild-mode-e44b6e8d161dadbccdbeb9c72ed6d531dbf9cc40.tar.gz
ebuild-mode-e44b6e8d161dadbccdbeb9c72ed6d531dbf9cc40.tar.bz2
ebuild-mode-e44b6e8d161dadbccdbeb9c72ed6d531dbf9cc40.zip
Filter SGR control sequences in compilation output
* ebuild-mode.el (ebuild-compilation-mode): New mode for compilation buffers, filters SGR control sequences. (ebuild-log-buffer-mode): Default to it. (ebuild-mode-run-pkgdev, ebuild-mode-run-pkgcheck): Call compile with ebuild-log-buffer-mode. (ebuild-mode-process-environment): Don't set NOCOLOR if ansi-color is available. Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--ChangeLog10
-rw-r--r--ebuild-mode.el24
2 files changed, 30 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d5edf6..040b537 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-11-30 Ulrich Müller <ulm@gentoo.org>
+
+ * ebuild-mode.el (ebuild-compilation-mode): New mode for
+ compilation buffers, filters SGR control sequences.
+ (ebuild-log-buffer-mode): Default to it.
+ (ebuild-mode-run-pkgdev, ebuild-mode-run-pkgcheck): Call compile
+ with ebuild-log-buffer-mode.
+ (ebuild-mode-process-environment): Don't set NOCOLOR if ansi-color
+ is available.
+
2022-11-28 Ulrich Müller <ulm@gentoo.org>
* ebuild-mode.el (ebuild-mode-ebuild-history)
diff --git a/ebuild-mode.el b/ebuild-mode.el
index 6bd2c80..dcc2e9a 100644
--- a/ebuild-mode.el
+++ b/ebuild-mode.el
@@ -121,7 +121,9 @@ If nil, use two spaces."
:group 'ebuild)
(defcustom ebuild-mode-process-environment
- '("NOCOLOR=true")
+ (if (or (featurep 'xemacs)
+ (not (fboundp 'ansi-color-compilation-filter)))
+ '("NOCOLOR=true"))
"List of additional environment variables for subprocesses.
Each element should be a string of the form NAME=VALUE. This will
be prepended to `process-environment' when calling a subprocess."
@@ -407,7 +409,7 @@ of the elements."
(defvar ebuild-mode-pkgdev-history nil)
(defvar ebuild-mode-pkgcheck-history nil)
-(defvar ebuild-log-buffer-mode nil
+(defvar ebuild-log-buffer-mode 'ebuild-compilation-mode
"Major mode for the log buffer of `ebuild-run-command'.
If nil, `compilation-mode' will be used.")
@@ -430,6 +432,16 @@ If nil, `compilation-mode' will be used.")
(compile shell-command)
(compile shell-command ebuild-log-buffer-mode))))
+(define-derived-mode ebuild-compilation-mode compilation-mode "Compilation"
+ "Like `compilation-mode' but with color support.
+Translates ANSI graphical control sequences into text properties
+(if the Emacs version supports it).
+Variable `ansi-color-for-compilation-mode' must be non-nil for
+this to have any effect."
+ (if (fboundp 'ansi-color-compilation-filter)
+ (add-hook 'compilation-filter-hook
+ 'ansi-color-compilation-filter nil t)))
+
(defun ebuild-mode-get-completion-function (mode)
"Get completion function for completion mode MODE."
(cond ((null mode) 'try-completion)
@@ -494,7 +506,9 @@ Like `compile', but with autocompletion for pkgdev."
(let ((process-environment (append ebuild-mode-process-environment
process-environment))
(compilation-buffer-name-function (lambda (mode) "*pkgdev*")))
- (compile command)))
+ (if (featurep 'xemacs)
+ (compile command)
+ (compile command ebuild-log-buffer-mode))))
(defun ebuild-mode-run-pkgcheck (command)
"Run pkgcheck COMMAND with output to a compilation buffer.
@@ -507,7 +521,9 @@ Like `compile', but with autocompletion for pkgcheck."
(let ((process-environment (append ebuild-mode-process-environment
process-environment))
(compilation-buffer-name-function (lambda (mode) "*pkgcheck*")))
- (compile command)))
+ (if (featurep 'xemacs)
+ (compile command)
+ (compile command ebuild-log-buffer-mode))))
;;; Modify package keywords.