comparison lisp/ansi-color.el @ 59104:33d3fb6cbd6e

(save-buffer-state): Definition deleted. (ansi-color-unfontify-region): Don't use save-buffer-state.
author Richard M. Stallman <rms@gnu.org>
date Mon, 27 Dec 2004 15:40:23 +0000
parents 695cf19ef79e
children a7e02ef1e3d6 95879cc1ed20
comparison
equal deleted inserted replaced
59103:9c9d41548660 59104:33d3fb6cbd6e
217 (add-hook 'comint-output-filter-functions 217 (add-hook 'comint-output-filter-functions
218 'ansi-color-process-output) 218 'ansi-color-process-output)
219 219
220 220
221 ;; Alternative font-lock-unfontify-region-function for Emacs only 221 ;; Alternative font-lock-unfontify-region-function for Emacs only
222
223
224 (eval-when-compile
225 ;; We use this to preserve or protect things when modifying text
226 ;; properties. Stolen from lazy-lock and font-lock. Ugly!!!
227 ;; Probably most of this is not needed?
228 (defmacro save-buffer-state (varlist &rest body)
229 "Bind variables according to VARLIST and eval BODY restoring buffer state."
230 `(let* (,@(append varlist
231 '((modified (buffer-modified-p)) (buffer-undo-list t)
232 (inhibit-read-only t) (inhibit-point-motion-hooks t)
233 before-change-functions after-change-functions
234 deactivate-mark buffer-file-name buffer-file-truename)))
235 ,@body
236 (when (and (not modified) (buffer-modified-p))
237 (set-buffer-modified-p nil))))
238 (put 'save-buffer-state 'lisp-indent-function 1))
239 222
240 (defun ansi-color-unfontify-region (beg end &rest xemacs-stuff) 223 (defun ansi-color-unfontify-region (beg end &rest xemacs-stuff)
241 "Replacement function for `font-lock-default-unfontify-region'. 224 "Replacement function for `font-lock-default-unfontify-region'.
242 225
243 As text-properties are implemented using extents in XEmacs, this 226 As text-properties are implemented using extents in XEmacs, this
257 240
258 \(add-hook 'font-lock-mode-hook 241 \(add-hook 'font-lock-mode-hook
259 \(function (lambda () 242 \(function (lambda ()
260 \(setq font-lock-unfontify-region-function 243 \(setq font-lock-unfontify-region-function
261 'ansi-color-unfontify-region))))" 244 'ansi-color-unfontify-region))))"
262 ;; save-buffer-state is a macro in font-lock.el! 245 ;; Simplified now that font-lock-unfontify-region uses save-buffer-state.
263 (save-buffer-state nil 246 (when (boundp 'font-lock-syntactic-keywords)
264 (when (boundp 'font-lock-syntactic-keywords) 247 (remove-text-properties beg end '(syntax-table nil)))
265 (remove-text-properties beg end '(syntax-table nil))) 248 ;; instead of just using (remove-text-properties beg end '(face
266 ;; instead of just using (remove-text-properties beg end '(face 249 ;; nil)), we find regions with a non-nil face test-property, skip
267 ;; nil)), we find regions with a non-nil face test-property, skip 250 ;; positions with the ansi-color property set, and remove the
268 ;; positions with the ansi-color property set, and remove the 251 ;; remaining face test-properties.
269 ;; remaining face test-properties. 252 (while (setq beg (text-property-not-all beg end 'face nil))
270 (while (setq beg (text-property-not-all beg end 'face nil)) 253 (setq beg (or (text-property-not-all beg end 'ansi-color t) end))
271 (setq beg (or (text-property-not-all beg end 'ansi-color t) end)) 254 (when (get-text-property beg 'face)
272 (when (get-text-property beg 'face) 255 (let ((end-face (or (text-property-any beg end 'face nil)
273 (let ((end-face (or (text-property-any beg end 'face nil) 256 end)))
274 end))) 257 (remove-text-properties beg end-face '(face nil))
275 (remove-text-properties beg end-face '(face nil)) 258 (setq beg end-face)))))
276 (setq beg end-face))))))
277 259
278 ;; Working with strings 260 ;; Working with strings
279 261
280 (defvar ansi-color-context nil 262 (defvar ansi-color-context nil
281 "Context saved between two calls to `ansi-color-apply'. 263 "Context saved between two calls to `ansi-color-apply'.