Cucumber 的 ANSI 颜色弄乱了 emacs 编译缓冲区
在 Emacs 中工作时,我使用编译命令(默认为 F12)来运行程序。当我在 Emacs 中运行 Cucumber 时,Cucumber 会输出 Emacs 编译模式无法解释的 ANSI 颜色。结果很丑陋并且难以阅读。下面是 *compilation* 缓冲区的一个片段,显示了丑陋之处:
^[[31m(::) failed steps (::)^[[0m
我正在使用的命令:
( cd ~/lab/rails/todolist && rake cucumber:all )
版本:
- Emacs 23.1
- Cucumber 0.8.3
- Cucumber-rails 0.3.2
如果可以的话,世界将充满阳光和鸟儿歌唱:
- 让 Emacs 来解释ANSI 颜色代码在其编译缓冲区中,或者
- Get Cucumber 停止吐出 ANSI 颜色代码
有什么想法吗?
When working in Emacs, I use the compile command (F12 by default) to run programs. When I run Cucumber in Emacs, Cucumber spits out ANSI colors that the Emacs compilation mode doesn't interpret. The result is ugly and hard to read. Here's a snippet of the *compilation* buffer showing the ugly:
^[[31m(::) failed steps (::)^[[0m
The command I'm using:
( cd ~/lab/rails/todolist && rake cucumber:all )
Versions:
- Emacs 23.1
- Cucumber 0.8.3
- Cucumber-rails 0.3.2
The world would be sunshine and birds singing if I could:
- Get Emacs to interpret ANSI color codes in its compilation buffer, or
- Get Cucumber to stop spitting out ANSI color codes
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我用它来打开编译缓冲区中的 ansi 颜色解释:
I use this to turn on ansi color interpretation in my compilation buffer:
我改进了代码,使其不会像命令一样污染
Mx grep
并且效率更高:I improve code so it doesn't pollute
M-x grep
like commands and more efficient:截至 2023 年,最现代的方式似乎是 xterm-color Emacs 包。
使用
xterm-color
执行Mx package-install
。将以下行添加到您的
~/.emacs
或~/.emacs.d/init.el
中:请参阅 xterm-color 文档。)
请注意,如果
xterm-color
未正确安装,这将提供错误消息。强烈建议这样做,因为在不完整的 Emacs 安装上,它会清楚地向您解释出了什么问题,而不是让您想知道为什么颜色不起作用。但是,如果您确实希望在缺少
xterm-color
时不被通知,请改用:As of 2023, the most modern way appears to be the
xterm-color
Emacs package.Execute
M-x package-install
withxterm-color
.Add the following lines to your
~/.emacs
or~/.emacs.d/init.el
:(See xterm-color documentation.)
Note that this will provide an error message if
xterm-color
was not installed properly. This is strongly advised, because on an incomplete Emacs installation it will clearly explain to you what's wrong, instead of leaving you wondering why the colors don't work.However, if you really prefer to not being informed if
xterm-color
is missing, use instead: