diff --git a/justl.el b/justl.el index 89b4dd8..d099099 100644 --- a/justl.el +++ b/justl.el @@ -24,7 +24,7 @@ ;; Keywords: just justfile tools processes ;; URL: https://github.com/psibi/justl.el ;; License: GNU General Public License >= 3 -;; Package-Requires: ((transient "0.1.0") (emacs "25.3") (xterm-color "2.0") (s "1.2.0") (f "0.20.0")) +;; Package-Requires: ((transient "0.1.0") (emacs "25.3") (s "1.2.0") (f "0.20.0")) ;;; Commentary: @@ -60,12 +60,23 @@ ;; ;; You can also control the width of the RECIPE column in the justl ;; buffer via `justl-recipe width`. By default it has a value of 20. +;; +;; You can enable coloring of the output by adding proper hook to +;; `compilation-filter-hook`. For Emacs older than 28.1 you need to +;; define it like this: +;; (require 'ansi-color) +;; (defun my-color-compilation-filter () +;; (let ((inhibit-read-only t)) +;; (ansi-color-apply-on-region compilation-filter-start (point)))) +;; (add-hook 'compilation-filter-hook 'my-color-compilation-filter) +;; For Emacs 28.1 or newer it's as simple as: +;; (require 'ansi-color) +;; (add-hook 'compilation-filter-hook 'ansi-color-compilation-filter) ;;; Code: (require 'transient) (require 'cl-lib) -(require 'xterm-color) (require 'eshell) (require 'esh-mode) (require 's) @@ -283,21 +294,6 @@ CMD is the just command as a list." process-name err)))))) -(defun justl--xterm-color-filter (proc string) - "Filter function for PROC handling colors. - -STRING is the data returned by the PROC" - (when (buffer-live-p (process-buffer proc)) - (with-current-buffer (process-buffer proc) - (let ((inhibit-read-only t) - (moving (= (point) (process-mark proc)))) - (save-excursion - ;; Insert the text, advancing the process marker. - (goto-char (process-mark proc)) - (insert (xterm-color-filter string)) - (set-marker (process-mark proc) (point))) - (if moving (goto-char (process-mark proc))))))) - (defun justl-compilation-setup-buffer (buf dir mode &optional no-mode-line) "Setup the compilation buffer for just-compile-mode. @@ -349,7 +345,7 @@ ARGS is a plist that affects how the process is run. (setq-local justl--justfile (justl--justfile-from-arg (elt command 1))) (run-hook-with-args 'compilation-start-hook process) - (set-process-filter process 'justl--xterm-color-filter) + (set-process-filter process 'compilation-filter) (set-process-sentinel process sentinel) (set-process-coding-system process 'utf-8-emacs-unix 'utf-8-emacs-unix) (pop-to-buffer buf))))) @@ -430,7 +426,7 @@ ARGS is a ist of arguments." (justl--log-command process-name cmd) (make-process :name process-name :buffer buffer-name - :filter 'justl--xterm-color-filter + :filter 'compilation-filter :sentinel #'justl--sentinel :file-handler t :stderr nil