|
97 | 97 | :group 'arduino-cli
|
98 | 98 | :type 'boolean)
|
99 | 99 |
|
| 100 | +(defcustom arduino-cli-compile-color t |
| 101 | + "If true (default), apply ANSI colors from compilation output." |
| 102 | + :group 'arduino-cli |
| 103 | + :type 'boolean) |
| 104 | + |
100 | 105 | ;;; Internal functions
|
| 106 | +(defun arduino-cli--compilation-filter () |
| 107 | + "Filter function for applying ANSI colors in compilation output." |
| 108 | + (when arduino-cli-compile-color |
| 109 | + (ansi-color-apply-on-region compilation-filter-start (point-max)))) |
| 110 | + |
101 | 111 | (define-compilation-mode arduino-cli-compilation-mode "arduino-cli-compilation"
|
102 | 112 | "Arduino-cli specific `compilation-mode' derivative."
|
103 | 113 | (setq-local compilation-scroll-output t)
|
104 |
| - (require 'ansi-color)) |
| 114 | + (require 'ansi-color) |
| 115 | + (add-hook 'compilation-filter-hook #'arduino-cli--compilation-filter)) |
105 | 116 |
|
106 | 117 | (defun arduino-cli--?map-put (m v k)
|
107 | 118 | "Puts V in M under K when V, else return M."
|
|
122 | 133 | (when arduino-cli-warnings
|
123 | 134 | (concat " --warnings " (symbol-name arduino-cli-warnings))))
|
124 | 135 |
|
| 136 | +(defun arduino-cli--compile-color () |
| 137 | + "Get the current compilation color setting." |
| 138 | + (when (not arduino-cli-compile-color) |
| 139 | + " --no-color")) |
| 140 | + |
125 | 141 | (defun arduino-cli--general-flags ()
|
126 | 142 | "Add flags to CMD, if set."
|
127 | 143 | (concat (unless arduino-cli-compile-only-verbosity
|
|
131 | 147 | "Add flags to CMD, if set."
|
132 | 148 | (concat (arduino-cli--verify)
|
133 | 149 | (arduino-cli--warnings)
|
134 |
| - (arduino-cli--verbosity))) |
| 150 | + (arduino-cli--verbosity) |
| 151 | + (arduino-cli--compile-color))) |
135 | 152 |
|
136 | 153 | (defun arduino-cli--add-flags (mode cmd)
|
137 | 154 | "Add general and MODE flags to CMD, if set."
|
|
0 commit comments