Here's the original code:
(defadvice compilation-filter (before ansify-compilation-output activate)
(with-current-buffer (process-buffer (ad-get-arg 0))
(font-lock-mode -1)
(ad-set-arg 1 (ansi-color-apply (ad-get-arg 1))))
The problem is that turning off font-lock-mode strips all the colors from the current buffer's text. If your process produces multiple pieces of output, you get this effect sort of like a line of sparks. The rightmost few are bright and colorful, but they quickly fade out and become dull gray.
The fix is to turn off font-lock-mode only when it's on. That is, like so:
(defadvice compilation-filter (before ansify-compilation-output activate)
(with-current-buffer (process-buffer (ad-get-arg 0))
(if font-lock-mode (font-lock-mode -1))
(ad-set-arg 1 (ansi-color-apply (ad-get-arg 1)))))
Now the compilation process's output starts out and stays colorful.
No comments:
Post a Comment