aboutsummaryrefslogtreecommitdiffstats
path: root/oni-compilation.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2019-09-19 17:33:38 -0700
committerGravatar Tom Willemse2019-09-19 17:33:38 -0700
commitd37d8f969b6609d2d9d7231282abba97ddfab531 (patch)
tree1bc386195bdeb4369ecdbf4823e4ec3a49837fff /oni-compilation.el
parent8724c976fc75f9820ec9d736f2affe33fa071c9a (diff)
downloademacs-config-d37d8f969b6609d2d9d7231282abba97ddfab531.tar.gz
emacs-config-d37d8f969b6609d2d9d7231282abba97ddfab531.zip
Replace ‘ansi-color’ with ‘xterm-color’
According to a tweet from Mickey Petersen[1], ‘xterm-color’ is faster and more accurate. [1]: https://twitter.com/mickeynp/status/1132236557308579840?s=09
Diffstat (limited to 'oni-compilation.el')
-rw-r--r--oni-compilation.el20
1 files changed, 11 insertions, 9 deletions
diff --git a/oni-compilation.el b/oni-compilation.el
index d11f395..c5c7444 100644
--- a/oni-compilation.el
+++ b/oni-compilation.el
@@ -4,8 +4,8 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2019.0908.172111
-;; Package-Requires: (oni-alert)
+;; Version: 2019.0919.171849
+;; Package-Requires: (oni-alert xterm-color)
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
(require 'compile)
(require 'subr-x)
+(require 'xterm-color)
(setq compilation-scroll-output t)
@@ -45,10 +46,6 @@ ALIST and PLIST contain extra information about the buffer."
(unless (string= (string-trim status) "finished")
(display-buffer buffer)))
-(defun oni-compilation--ansi-color-for-compilation-filter ()
- "Apply ANSI terminal escape codes to compilation output."
- (ansi-color-apply-on-region compilation-filter-start (point)))
-
(defun oni-compilation--compilation-finish-notify-function (buffer status)
"Show an alert of the status of the compliation.
@@ -59,21 +56,26 @@ status of the process."
(alert "Compilation finished succesfully")
(alert "Compilation finished with an error"))))
+(defun oni-compilation--filter-xterm-colors (func proc string)
+ "Call FUNC with PROC and STRING filtered through ‘xterm-color-filter’."
+ (funcall func proc (xterm-color-filter string)))
+
+(setq compilation-environment '("TERM=xterm-256color"))
+
(add-to-list 'display-buffer-alist
'("\\`\\*compilation\\*\\'" display-buffer-in-side-window
(side . bottom)
(slot . 0)
(window-height . 0.33)))
-(add-hook 'compilation-filter-hook
- #'oni-compilation--ansi-color-for-compilation-filter)
-
(add-hook 'compilation-finish-functions
#'oni-compilation--maybe-display-compilation-window)
(add-hook 'compilation-finish-functions
#'oni-compilation--compilation-finish-notify-function)
+(advice-add 'compilation-filter :around #'oni-compilation--filter-xterm-colors)
+
;;;###autoload(with-eval-after-load 'compile (require 'oni-compilation))
(provide 'oni-compilation)