当我做M-!在我的 emacs 21.4 中,ANSI 代码是字面意思。例如:ls --color
^[[0m^[[0m05420273.pdf^[[0m
^[[0m100829_Baño1.pdf^[[0m
有没有办法同时使用颜色和UTF8?
同样的问题已经被之前在SO中回答过 https://stackoverflow.com/questions/4726220/how-to-have-colors-in-the-output-of-emacs-shell-command但结果并不完全令人满意(给出的解决方案是打开 shell 模式)。我知道如何在贝壳中添加颜色。我只想知道怎么才能和M有颜色! (shell 命令)或者如果根本不可能。
当您只想快速显示某些内容并且不想移动到此缓冲区并且希望它在不使用 C-x-k 的情况下自动消失时,shell 模式的干扰性太大。显然,在某些情况下,shell 缓冲区更方便,但由于另一个问题,我发现了如何将颜色添加到 shell 模式。
【注意】emacs使用中
builder6.centos.org 上的 2008 年 6 月 15 日的 GNU Emacs 21.4.1(x86_64-redhat-linux-gnu、X 工具包、Xaw3d 滚动条)
ansi-color.el
包含处理 ANSI 颜色代码的函数。不幸的是,并没有真正的好方法将其挂接到shell-command
。这是一个 hack,但它有效:
(require 'ansi-color)
(defadvice display-message-or-buffer (before ansi-color activate)
"Process ANSI color codes in shell output."
(let ((buf (ad-get-arg 0)))
(and (bufferp buf)
(string= (buffer-name buf) "*Shell Command Output*")
(with-current-buffer buf
(ansi-color-apply-on-region (point-min) (point-max))))))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)