aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/shell.el
diff options
context:
space:
mode:
authorChong Yidong2012-02-19 21:59:42 +0800
committerChong Yidong2012-02-19 21:59:42 +0800
commit0fd40f8951f1aaa387e78999ecfbf6bc954ccf8a (patch)
tree48386211397064dd0eb1bc47fb0a292e3ad4e19f /lisp/shell.el
parent2375c96a71874756c132de1d0508a224c0fea0ab (diff)
downloademacs-0fd40f8951f1aaa387e78999ecfbf6bc954ccf8a.tar.gz
emacs-0fd40f8951f1aaa387e78999ecfbf6bc954ccf8a.zip
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.el11
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."
510 (set (make-local-variable 'shell-dirstack) nil) 510 (set (make-local-variable 'shell-dirstack) nil)
511 (set (make-local-variable 'shell-last-dir) nil) 511 (set (make-local-variable 'shell-last-dir) nil)
512 (shell-dirtrack-mode 1) 512 (shell-dirtrack-mode 1)
513
514 ;; By default, ansi-color applies faces using overlays. This is
515 ;; very inefficient in Shell buffers (e.g. Bug#10835). We use a
516 ;; custom `ansi-color-apply-face-function' to convert color escape
517 ;; sequences into `font-lock-face' properties.
518 (set (make-local-variable 'ansi-color-apply-face-function)
519 (lambda (beg end face)
520 (when face
521 (put-text-property beg end 'font-lock-face face))))
522
513 ;; This is not really correct, since the shell buffer does not really 523 ;; This is not really correct, since the shell buffer does not really
514 ;; edit this directory. But it is useful in the buffer list and menus. 524 ;; edit this directory. But it is useful in the buffer list and menus.
515 (setq list-buffers-directory (expand-file-name default-directory)) 525 (setq list-buffers-directory (expand-file-name default-directory))
@@ -625,7 +635,6 @@ Otherwise, one argument `-i' is passed to the shell.
625 (read-directory-name 635 (read-directory-name
626 "Default directory: " default-directory default-directory 636 "Default directory: " default-directory default-directory
627 t nil)))))))) 637 t nil))))))))
628 (require 'ansi-color)
629 (setq buffer (if (or buffer (not (derived-mode-p 'shell-mode)) 638 (setq buffer (if (or buffer (not (derived-mode-p 'shell-mode))
630 (comint-check-proc (current-buffer))) 639 (comint-check-proc (current-buffer)))
631 (get-buffer-create (or buffer "*shell*")) 640 (get-buffer-create (or buffer "*shell*"))