如何在emacs中显示任何模式的ANSI颜色代码? [英] How do I display ANSI color codes in emacs for any mode?
问题描述
基本的
。还有其他回答的问题解决这个问题,但我不知道如何将它应用于此模式或任何其他模式。我知道解决方案与某些方式配置 ansi-color
有关。 - gdb模式中的ANSI代码
<李>> of title =shell模式下的ASCII码> shell模式下的ANSI代码
您可以使用
下的代码 (require'ansi-color)
defun display-ansi-colors()
(interactive)
(ansi-color-apply-on-region(point-min)(point-max)))
然后,您可以通过Mx通过键绑定执行 display-ansi-colors
或者通过某些编程条件(也许您的日志文件有一个扩展名或匹配某些正则表达式的名称)
如果你想做这可以使用只读缓冲区(日志文件,grep结果),您可以使用 prohib-read-only
,因此该功能将是:
(defun display-ansi-colors()
(interactive)
(let((prohib-read-only t))
(ansi-color-apply-on-region(point-min)(point-max))))
I have a log file that uses ANSI escape color codes to format the text. The mode is fundamental
. There are other answered questions that address this issue but I'm not sure how to apply it to this mode or any other mode. I know the solution has something to do with configuring ansi-color
in some way.
You could use code below
(require 'ansi-color)
(defun display-ansi-colors ()
(interactive)
(ansi-color-apply-on-region (point-min) (point-max)))
Then you can execute display-ansi-colors
via M-x, via a key-binding of your choosing, or via some programmatic condition (maybe your log files have a extension or name that matches some regexp)
If you want to do this with read-only buffers (log files, grep results), you may use inhibit-read-only
, so the function will be:
(defun display-ansi-colors ()
(interactive)
(let ((inhibit-read-only t))
(ansi-color-apply-on-region (point-min) (point-max))))
这篇关于如何在emacs中显示任何模式的ANSI颜色代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!