gpt4 book ai didi

emacs - 如何在任何模式下在 emacs 中显示 ANSI 颜色代码?

转载 作者:行者123 更新时间:2023-12-03 10:49:50 27 4
gpt4 key购买 nike

我有一个使用 ANSI 转义颜色代码来格式化文本的日志文件。模式为fundamental .还有其他已回答的问题可以解决此问题,但我不确定如何将其应用于此模式或任何其他模式。我知道解决方案与配置 ansi-color 有关某种程度上来说。

  • ANSI codes in shell mode
  • ANSI codes in gdb mode
  • 最佳答案

    用户定义函数:

    (defun my-ansi-color (&optional beg end)
    "Interpret ANSI color esacape sequence by colorifying cotent.
    Operate on selected region on whole buffer."
    (interactive
    (if (use-region-p)
    (list (region-beginning) (region-end))
    (list (point-min) (point-max))))
    (ansi-color-apply-on-region beg end))

    对于使用 comint/compilation 的缓冲区,请使用过滤器:
    (ignore-errors
    (require 'ansi-color)
    (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))

    关于emacs - 如何在任何模式下在 emacs 中显示 ANSI 颜色代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23378271/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com