Function: fast-lock-get-face-properties

fast-lock-get-face-properties is a byte-compiled function defined in fast-lock.el.gz.

Signature

(fast-lock-get-face-properties)

Documentation

Return a list of face text properties in the current buffer.

Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) where VALUE is a face property value and STARTx and ENDx are positions.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/fast-lock.el.gz
;; Text Properties Processing Functions:

;; This is fast, but fails if adjacent characters have different `face' text
;; properties.  Maybe that's why I dropped it in the first place?
;(defun fast-lock-get-face-properties ()
;  "Return a list of `face' text properties in the current buffer.
;Each element of the list is of the form (VALUE START1 END1 START2 END2 ...)
;where VALUE is a `face' property value and STARTx and ENDx are positions."
;  (save-restriction
;    (widen)
;    (let ((start (text-property-not-all (point-min) (point-max) 'face nil))
;	  (limit (point-max)) end properties value cell)
;      (while start
;	(setq end (next-single-property-change start 'face nil limit)
;	      value (get-text-property start 'face))
;	;; Make, or add to existing, list of regions with same `face'.
;	(if (setq cell (assq value properties))
;	    (setcdr cell (cons start (cons end (cdr cell))))
;	  (setq properties (cons (list value start end) properties)))
;	(setq start (next-single-property-change end 'face)))
;      properties)))

;; This is slow, but copes if adjacent characters have different `face' text
;; properties, but fails if they are lists.
;(defun fast-lock-get-face-properties ()
;  "Return a list of `face' text properties in the current buffer.
;Each element of the list is of the form (VALUE START1 END1 START2 END2 ...)
;where VALUE is a `face' property value and STARTx and ENDx are positions.
;Only those `face' VALUEs in `fast-lock-save-faces' are returned."
;  (save-restriction
;    (widen)
;    (let ((faces (or fast-lock-save-faces (face-list))) (limit (point-max))
;	  properties regions face start end)
;      (while faces
;	(setq face (car faces) faces (cdr faces) regions () end (point-min))
;	;; Make a list of start/end regions with `face' property face.
;	(while (setq start (text-property-any end limit 'face face))
;	  (setq end (or (text-property-not-all start limit 'face face) limit)
;		regions (cons start (cons end regions))))
;	;; Add `face' face's regions, if any, to properties.
;	(when regions
;	  (push (cons face regions) properties)))
;      properties)))

(defun fast-lock-get-face-properties ()
  "Return a list of `face' text properties in the current buffer.
Each element of the list is of the form (VALUE START1 END1 START2 END2 ...)
where VALUE is a `face' property value and STARTx and ENDx are positions."
  (save-restriction
    (widen)
    (let ((start (text-property-not-all (point-min) (point-max) 'face nil))
	  end properties value cell)
      (while start
	(setq end (next-single-property-change start 'face nil (point-max))
	      value (get-text-property start 'face))
	;; Make, or add to existing, list of regions with same `face'.
	(cond ((setq cell (assoc value properties))
	       (setcdr cell (cons start (cons end (cdr cell)))))
	      ((fast-lock-save-facep value)
	       (push (list value start end) properties)))
	(setq start (text-property-not-all end (point-max) 'face nil)))
      properties)))