Endless Parentheses

Concise ramblings on Emacs productivity.

ANSI-colors in the compilation buffer output

Countless build tools and shell scripts use ANSI escape codes to colorize their output. This provides impressive improvements to readability when running from a terminal that supports them, but tends to cause a catastrophic mess anywhere else. Emacs’ compilation buffer is one such place. It doesn’t support ANSI colors by default, but that’s very easy to fix.

Emacs already has a library for interpreting ANSI escape. All we need is to hook it onto compilation-mode.

(require 'ansi-color)
(defun endless/colorize-compilation ()
  "Colorize from `compilation-filter-start' to `point'."
  (let ((inhibit-read-only t))
     compilation-filter-start (point))))

(add-hook 'compilation-filter-hook
Say thanks on Gratipay
comments powered by Disqus