Function: c-trim-found-types

c-trim-found-types is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-trim-found-types BEG END OLD-LEN)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-trim-found-types (beg end _old-len)
  ;; An after change function which, in conjunction with the info in
  ;; c-maybe-stale-found-type (set in c-before-change), removes a type
  ;; from `c-found-types', should this type have become stale.  For
  ;; example, this happens to "foo" when "foo \n bar();" becomes
  ;; "foo(); \n bar();".  Such stale types, if not removed, foul up
  ;; the fontification.
  ;;
  ;; Have we, perhaps, added non-ws characters to the front/back of a found
  ;; type?
  (when (> end beg)
    (save-excursion
      (when (< end (point-max))
	(goto-char end)
	(if (and (c-beginning-of-current-token) ; only moves when we started in the middle
		 (progn (goto-char end)
			(c-end-of-current-token)))
	    (c-unfind-type (buffer-substring-no-properties
			    end (point)))))
      (when (> beg (point-min))
	(goto-char beg)
	(if (and (c-end-of-current-token) ; only moves when we started in the middle
		 (progn (goto-char beg)
			(c-beginning-of-current-token)))
	    (c-unfind-type (buffer-substring-no-properties
			    (point) beg))))))

  (if c-maybe-stale-found-type ; e.g. (c-decl-id-start "foo" 97 107 " (* ooka) " "o")
      (cond
       ;; Changing the amount of (already existing) whitespace - don't do anything.
       ((and (c-partial-ws-p beg end)
	     (or (= beg end)		; removal of WS
		 (string-match "^[ \t\n\r\f\v]*$" (nth 5 c-maybe-stale-found-type)))))

       ;; The syntactic relationship which defined a "found type" has been
       ;; destroyed.
       ((eq (car c-maybe-stale-found-type) 'c-decl-id-start)
	(c-unfind-type (cadr c-maybe-stale-found-type)))
;;        ((eq (car c-maybe-stale-found-type) 'c-decl-type-start)  FIXME!!!
	)))