/[emacs]/emacs/lisp/ansi-color.el
ViewVC logotype

Diff of /emacs/lisp/ansi-color.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by miles, Mon Sep 1 15:45:04 2003 UTC revision 1.15 by rms, Mon Dec 27 15:40:23 2004 UTC
# Line 220  This is a good function to put in `comin Line 220  This is a good function to put in `comin
220    
221  ;; Alternative font-lock-unfontify-region-function for Emacs only  ;; Alternative font-lock-unfontify-region-function for Emacs only
222    
   
 (eval-when-compile  
  ;; We use this to preserve or protect things when modifying text  
  ;; properties.  Stolen from lazy-lock and font-lock.  Ugly!!!  
  ;; Probably most of this is not needed?  
  (defmacro save-buffer-state (varlist &rest body)  
    "Bind variables according to VARLIST and eval BODY restoring buffer state."  
    `(let* (,@(append varlist  
                      '((modified (buffer-modified-p)) (buffer-undo-list t)  
                        (inhibit-read-only t) (inhibit-point-motion-hooks t)  
                        before-change-functions after-change-functions  
                        deactivate-mark buffer-file-name buffer-file-truename)))  
      ,@body  
      (when (and (not modified) (buffer-modified-p))  
        (set-buffer-modified-p nil))))  
  (put 'save-buffer-state 'lisp-indent-function 1))  
   
223  (defun ansi-color-unfontify-region (beg end &rest xemacs-stuff)  (defun ansi-color-unfontify-region (beg end &rest xemacs-stuff)
224    "Replacement function for `font-lock-default-unfontify-region'.    "Replacement function for `font-lock-default-unfontify-region'.
225    
# Line 259  A possible way to install this would be: Line 242  A possible way to install this would be:
242            \(function (lambda ()            \(function (lambda ()
243                        \(setq font-lock-unfontify-region-function                        \(setq font-lock-unfontify-region-function
244                              'ansi-color-unfontify-region))))"                              'ansi-color-unfontify-region))))"
245    ;; save-buffer-state is a macro in font-lock.el!    ;; Simplified now that font-lock-unfontify-region uses save-buffer-state.
246    (save-buffer-state nil    (when (boundp 'font-lock-syntactic-keywords)
247      (when (boundp 'font-lock-syntactic-keywords)      (remove-text-properties beg end '(syntax-table nil)))
248        (remove-text-properties beg end '(syntax-table nil)))    ;; instead of just using (remove-text-properties beg end '(face
249      ;; instead of just using (remove-text-properties beg end '(face    ;; nil)), we find regions with a non-nil face test-property, skip
250      ;; nil)), we find regions with a non-nil face test-property, skip    ;; positions with the ansi-color property set, and remove the
251      ;; positions with the ansi-color property set, and remove the    ;; remaining face test-properties.
252      ;; remaining face test-properties.    (while (setq beg (text-property-not-all beg end 'face nil))
253      (while (setq beg (text-property-not-all beg end 'face nil))      (setq beg (or (text-property-not-all beg end 'ansi-color t) end))
254        (setq beg (or (text-property-not-all beg end 'ansi-color t) end))      (when (get-text-property beg 'face)
255        (when (get-text-property beg 'face)        (let ((end-face (or (text-property-any beg end 'face nil)
256          (let ((end-face (or (text-property-any beg end 'face nil)                            end)))
257                              end)))          (remove-text-properties beg end-face '(face nil))
258            (remove-text-properties beg end-face '(face nil))          (setq beg end-face)))))
           (setq beg end-face))))))  
259    
260  ;; Working with strings  ;; Working with strings
261    

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26