ANSI Coloring in Compilation Mode

后端 未结 5 1682
别那么骄傲
别那么骄傲 2020-12-08 06:29

Have anyone added support for ansi-color in compilation-mode Emacs? If so what property/attribute does the color-writing program have to check for in order to make sure its

5条回答
  •  眼角桃花
    2020-12-08 07:19

    Riffing on @gavenkoa's solution:

    (when (require 'ansi-color nil t)
      (defun my-colorize-compilation-buffer ()
        (when (eq major-mode 'compilation-mode)
          (ansi-color-apply-on-region compilation-filter-start (point-max))))
      (add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer))
    

    This will not block errors but will still not raise an error if ansi-color is unavailable. Personally, I find the wildcard catch semantics of ignore-error distasteful.

提交回复
热议问题