diff options
author | Chong Yidong <cyd@gnu.org> | 2012-02-19 21:59:42 +0800 |
---|---|---|
committer | Chong Yidong <cyd@gnu.org> | 2012-02-19 21:59:42 +0800 |
commit | 0fd40f8951f1aaa387e78999ecfbf6bc954ccf8a (patch) | |
tree | 48386211397064dd0eb1bc47fb0a292e3ad4e19f /lisp/shell.el | |
parent | 2375c96a71874756c132de1d0508a224c0fea0ab (diff) | |
download | emacs-0fd40f8951f1aaa387e78999ecfbf6bc954ccf8a.tar.gz |
Use text properties for color escape highlighting in Shell mode.
* ansi-color.el: Don't set comint-output-filter-functions; it is
now in the initial value defined in comint.el.
(ansi-color-apply-face-function): New variable.
(ansi-color-apply-on-region): Use it.
(ansi-color-apply-overlay-face): New function.
* comint.el: Require ansi-color.
(comint-output-filter-functions): Add ansi-color-process-output.
* shell.el (shell): No need to require ansi-color.
(shell-mode): Use ansi-color-apply-face-function to highlight
color escapes using font-lock-face property.
Fixes: debbugs:10835
Diffstat (limited to 'lisp/shell.el')
-rw-r--r-- | lisp/shell.el | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index b4b388655c8..1ed43863452 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -510,6 +510,16 @@ buffer." (set (make-local-variable 'shell-dirstack) nil) (set (make-local-variable 'shell-last-dir) nil) (shell-dirtrack-mode 1) + + ;; By default, ansi-color applies faces using overlays. This is + ;; very inefficient in Shell buffers (e.g. Bug#10835). We use a + ;; custom `ansi-color-apply-face-function' to convert color escape + ;; sequences into `font-lock-face' properties. + (set (make-local-variable 'ansi-color-apply-face-function) + (lambda (beg end face) + (when face + (put-text-property beg end 'font-lock-face face)))) + ;; This is not really correct, since the shell buffer does not really ;; edit this directory. But it is useful in the buffer list and menus. (setq list-buffers-directory (expand-file-name default-directory)) @@ -625,7 +635,6 @@ Otherwise, one argument `-i' is passed to the shell. (read-directory-name "Default directory: " default-directory default-directory t nil)))))))) - (require 'ansi-color) (setq buffer (if (or buffer (not (derived-mode-p 'shell-mode)) (comint-check-proc (current-buffer))) (get-buffer-create (or buffer "*shell*")) |