ANSI着色在编译模式 [英] ANSI Coloring in Compilation Mode

查看:210
本文介绍了ANSI着色在编译模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人在编译模式Emacs中添加了对ansi-color的支持?如果是这样的颜色编写程序必须检查的属性/属性,以确保其活动终端支持ANSI转义着色。

解决方案

已经有一个将颜色应用于comint缓冲区的功能。您只需要在编译缓冲区中启用它:

 (require'ansi-color)
(defun colorize-compilation-buffer()
(toggle-read-only)
(ansi-color-apply-on-region compilation-filter-start(point))
切换只读))
(add-hook'compilation-filter-hook'colorize-compilation-buffer)

颜色编写程序应检查 TERM 环境变量和terminfo数据库,以检查终端是否支持颜色。实际上,很多程序忽略这一点,并且依赖于用户设置。默认情况下,Emacs会将编译终端类型设置为 dumb ,但可以通过设置编译环境变量来覆盖。


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 active terminal supports ANSI-escape coloring.

解决方案

There's already a function for applying color to comint buffers. You simply need to enable it on compilation buffers:

(require 'ansi-color)
(defun colorize-compilation-buffer ()
  (toggle-read-only)
  (ansi-color-apply-on-region compilation-filter-start (point))
  (toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)

Color writing programs should check the TERM environment variable and the terminfo database to check if the terminal supports color. In practice, a lot of programs ignore this and rely on a user setting. Emacs will set the compilation terminal type to dumb by default but this can be overriden by setting the compilation-environment variable.

这篇关于ANSI着色在编译模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆