ansi颜色不在emacs窗口中显示

时间:2013-01-18 00:04:27

标签: python emacs colors ansi-escape

我知道之前已经问过这个问题的变体......但我必须遇到一个不同的问题,因为解决方案对我不起作用。我有一个使用ANSI代码的文本文件,当我cat文件到终端时,它很好地显示。当我将23.2.1文件发送给emacs时,我看到这样的事情:

^[[36mText^[[0m

如果重要,^[在该行中都是红色的(emacs将其视为一个字符),其余文本为黑色。我希望在emacs编辑器中该行是浅蓝色的。提及我使用python代码

创建此文件可能会有所帮助
python
>>> myfile = open("test.txt","w")
>>> myfile.write("\033[36mText\033[0m\n")
>>> myfile.close()

生成该文本。环顾四周,我尝试了几种解决方案:

(require 'ansi-color)                                                                                                                                                                                              
;(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)                                                                                                                                                      

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)                                                                                                                                                         

;(setq ansi-term-color-vector [unspecified "#3f3f3f" "#cc9393" "#7f9f7f" "#f0dfaf"  "#8cd0d3" "#dc8cc3" "#93e0e3" "#dcdccc"]) 

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

;(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)))))) 

但这些都没有奏效。我不是emacs / lisp专家......所以我自己在这里很无助。我还尝试清除.emacs文件中的所有其他内容,以防万一发生冲突。

关于我可以尝试的任何其他想法?

0 个答案:

没有答案