xterm-color.el is an ANSI control sequence to text-property translator
- Regular ANSI color support
- XTERM 256 color support
- Bonus: Faster than ansi-color.el
Call xterm-color-filter to propertize strings that you can then insert into a buffer. All state is kept in buffer-local variables which means that control sequences can span xterm-color-filter call boundaries.
(xterm-color-filter "[0;1;3;4") (xterm-color-filter ";35") (xterm-color-filter ";mThis is only a test") (xterm-color-filter "[0m")
If you are inserting into a buffer that has activated font locking, you need to set font-lock-unfontify-region-function to xterm-color-unfontify-region
You can replace ansi-color.el with xterm-color for all comint buffers:
;; comint install (progn (add-hook 'comint-preoutput-filter-functions 'xterm-color-filter) (setq comint-output-filter-functions (remove 'ansi-color-process-output comint-output-filter-functions)) (setq font-lock-unfontify-region-function 'xterm-color-unfontify-region)) ;; comint uninstall (progn (remove-hook 'comint-preoutput-filter-functions 'xterm-color-filter) (add-to-list 'comint-output-filter-functions 'ansi-color-process-output) (setq font-lock-unfontify-region-function 'font-lock-default-unfontify-region))
M-x xterm-color-test For comint: M-x shell wget http://www.frexx.de/xterm-256-notes/data/256colors2.pl wget http://www.frexx.de/xterm-256-notes/data/xterm-colortest perl xterm-colortest && perl 256colors2.pl
The code comes with a BSD-style license so you can basically do with it whatever you want.
xristos (AT) sdf (DOT) lonestar (DOT) org