I have my emacs set up so that colors in shell buffers work great. I also use the compile command to run individual test files in my ruby on rails environment But when I do that, the ror test functionality puts lots of shell/terminal escape characters into my compilation buffer. Is there any way to get that stuff to display in terminal colors?
我已经设置了我的emacs,以便shell缓冲区中的颜色工作得很好。我还使用compile命令在ruby on rails环境中运行单独的测试文件,但是当我这么做时,ror测试功能将大量shell/终端转义字符放入我的编译缓冲区中。有没有办法让这些东西以终端颜色显示?
BTW: I searched around and tried some things, but they didn't work.
顺便说一句:我四处搜寻,尝试了一些东西,但都没用。
Thanks!
谢谢!
2 个解决方案
#1
3
Here's what I have in my .emacs file now. It does not work until the end, but that's OK.
这是我现在的。emacs文件。它直到最后才会起作用,但没关系。
Thanks!!!
谢谢! ! !
;; This stuff is to ansi-colorize the compilation buffer after a rails test so the terminal colors come through. (define-derived-mode ansi-compilation-mode compilation-mode "ansi compilation" "Compilation mode that understands ansi colors." (require 'ansi-color) (toggle-read-only 0) (ansi-color-apply-on-region (point-min) (point-max))) (defun colorize-compilation (one two) "ansi colorize the compilation buffer." (ansi-compilation-mode) ) (setq compilation-finish-function 'colorize-compilation)
EDIT
编辑
I have switched from using the compile mode to using an async shell command. Here's the lisp:
我已经从使用编译模式切换到使用异步shell命令。lisp是这样的:
(defun run-it () "Run it on the current file." (interactive) (save-buffer) (shell-command (format "my_command %s &" (shell-quote-argument (buffer-name))))) (global-set-key "\C-ct" 'run-it)
It saves the buffer first. The &
makes it actually interactive so I can enter text in the buffer and the command will get that input. And it colors the command output on the fly, which my compile buffer was not doing.
它首先保存缓冲区。&使它具有交互性,这样我就可以在缓冲区中输入文本,命令就会得到输入。它动态地为命令输出着色,而我的编译缓冲区没有这样做。
#2
1
Backing the comment by Alex Vorobiev, which delivered the answer.
支持亚历克斯·沃罗别夫的评论,他给出了答案。
Seems you've put a comint-mode aside and with that the ansi-color-process-output filter.
看来你已经把comint模式放在一边了,还有ansi-color-process-output过滤器。
AFAIU fontifying is done on a per-buffer-base, run from an idle-timer resp. triggered by buffer-changes. If enabled in a output-shell, Emacs might hang, as a lot of changes may occur in short time. Therefor fontification is commonly off here. An alternative approach: M-x MY-MODE at the shell-buffer. Which might need some reset to shell environment or re-start then.
AFAIU固定是在每个缓冲基上完成的,从一个空闲计时器resp上运行。由缓冲区修改引起的。如果在输出shell中启用Emacs,则可能会挂起,因为许多更改可能在短时间内发生。这里通常不加糖。另一种方法:M-x MY-MODE at shell-buffer。可能需要对shell环境进行重置或重新启动。
#1
3
Here's what I have in my .emacs file now. It does not work until the end, but that's OK.
这是我现在的。emacs文件。它直到最后才会起作用,但没关系。
Thanks!!!
谢谢! ! !
;; This stuff is to ansi-colorize the compilation buffer after a rails test so the terminal colors come through. (define-derived-mode ansi-compilation-mode compilation-mode "ansi compilation" "Compilation mode that understands ansi colors." (require 'ansi-color) (toggle-read-only 0) (ansi-color-apply-on-region (point-min) (point-max))) (defun colorize-compilation (one two) "ansi colorize the compilation buffer." (ansi-compilation-mode) ) (setq compilation-finish-function 'colorize-compilation)
EDIT
编辑
I have switched from using the compile mode to using an async shell command. Here's the lisp:
我已经从使用编译模式切换到使用异步shell命令。lisp是这样的:
(defun run-it () "Run it on the current file." (interactive) (save-buffer) (shell-command (format "my_command %s &" (shell-quote-argument (buffer-name))))) (global-set-key "\C-ct" 'run-it)
It saves the buffer first. The &
makes it actually interactive so I can enter text in the buffer and the command will get that input. And it colors the command output on the fly, which my compile buffer was not doing.
它首先保存缓冲区。&使它具有交互性,这样我就可以在缓冲区中输入文本,命令就会得到输入。它动态地为命令输出着色,而我的编译缓冲区没有这样做。
#2
1
Backing the comment by Alex Vorobiev, which delivered the answer.
支持亚历克斯·沃罗别夫的评论,他给出了答案。
Seems you've put a comint-mode aside and with that the ansi-color-process-output filter.
看来你已经把comint模式放在一边了,还有ansi-color-process-output过滤器。
AFAIU fontifying is done on a per-buffer-base, run from an idle-timer resp. triggered by buffer-changes. If enabled in a output-shell, Emacs might hang, as a lot of changes may occur in short time. Therefor fontification is commonly off here. An alternative approach: M-x MY-MODE at the shell-buffer. Which might need some reset to shell environment or re-start then.
AFAIU固定是在每个缓冲基上完成的,从一个空闲计时器resp上运行。由缓冲区修改引起的。如果在输出shell中启用Emacs,则可能会挂起,因为许多更改可能在短时间内发生。这里通常不加糖。另一种方法:M-x MY-MODE at shell-buffer。可能需要对shell环境进行重置或重新启动。