-(add-hook 'comint-output-filter-functions
- 'ansi-color-process-output)
-
-
-;; Alternative font-lock-unfontify-region-function for Emacs only
-
-(defun ansi-color-unfontify-region (beg end &rest xemacs-stuff)
- "Replacement function for `font-lock-default-unfontify-region'.
-
-As text properties are implemented using extents in XEmacs, this
-function is probably not needed. In Emacs, however, things are a bit
-different: When font-lock is active in a buffer, you cannot simply add
-face text properties to the buffer. Font-lock will remove the face
-text property using `font-lock-unfontify-region-function'. If you want
-to insert the strings returned by `ansi-color-apply' into such buffers,
-you must set `font-lock-unfontify-region-function' to
-`ansi-color-unfontify-region'. This function will not remove all face
-text properties unconditionally. It will keep the face text properties
-if the property `ansi-color' is set.
-
-The region from BEG to END is unfontified. XEMACS-STUFF is ignored.
-
-A possible way to install this would be:
-
-\(add-hook 'font-lock-mode-hook
- \(function (lambda ()
- \(setq font-lock-unfontify-region-function
- 'ansi-color-unfontify-region))))"
- ;; Simplified now that font-lock-unfontify-region uses save-buffer-state.
- (when (boundp 'font-lock-syntactic-keywords)
- (remove-text-properties beg end '(syntax-table nil)))
- ;; instead of just using (remove-text-properties beg end '(face
- ;; nil)), we find regions with a non-nil face text-property, skip
- ;; positions with the ansi-color property set, and remove the
- ;; remaining face text-properties.
- (while (setq beg (text-property-not-all beg end 'face nil))
- (setq beg (or (text-property-not-all beg end 'ansi-color t) end))
- (when (get-text-property beg 'face)
- (let ((end-face (or (text-property-any beg end 'face nil)
- end)))
- (remove-text-properties beg end-face '(face nil))
- (setq beg end-face)))))