Function: c-font-lock-<>-arglists

c-font-lock-<>-arglists is a byte-compiled function defined in cc-fonts.el.gz.

Signature

(c-font-lock-<>-arglists LIMIT)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-fonts.el.gz
(defun c-font-lock-<>-arglists (limit)
  ;; This function will be called from font-lock for a region bounded by POINT
  ;; and LIMIT, as though it were to identify a keyword for
  ;; font-lock-keyword-face.  It always returns NIL to inhibit this and
  ;; prevent a repeat invocation.  See elisp/lispref page "Search-based
  ;; Fontification".
  ;;
  ;; Fontify types and references in names containing angle bracket
  ;; arglists from the point to LIMIT.  Note that
  ;; `c-font-lock-declarations' has already handled many of them.
  ;;
  ;; This function might do hidden buffer changes.

  (c-skip-comments-and-strings limit)
  (when (< (point) limit)

    (let (;; The font-lock package in Emacs is known to clobber
	  ;; `parse-sexp-lookup-properties' (when it exists).
	  (parse-sexp-lookup-properties
	   (cc-eval-when-compile
	     (boundp 'parse-sexp-lookup-properties)))
	  (c-parse-and-markup-<>-arglists t)
	  c-restricted-<>-arglists
	  id-start id-end id-face pos kwd-sym
	  old-pos)

      (while (and (< (point) limit)
		  (setq old-pos (point))
		  (c-syntactic-re-search-forward "<" limit t nil t))
	(setq pos (point))
	(save-excursion
	  (backward-char)
	  (c-backward-syntactic-ws old-pos)
	  (if (re-search-backward
	       (concat "\\(\\`\\|" c-nonsymbol-key "\\)\\(" c-symbol-key"\\)\\=")
	       old-pos t)
	      (setq id-start (match-beginning 2)
		    id-end (match-end 2))
	    (setq id-start nil id-end nil)))

	(when id-start
	  (goto-char id-start)
	  (unless (c-skip-comments-and-strings limit)
	    (setq kwd-sym nil
		  c-restricted-<>-arglists nil
		  id-face (get-text-property id-start 'face))

	    (if (cond
		 ((eq id-face 'font-lock-type-face)
		  ;; The identifier got the type face so it has already been
		  ;; handled in `c-font-lock-declarations'.
		  nil)

		 ((eq id-face 'font-lock-keyword-face)
		  (when (looking-at c-opt-<>-sexp-key)
		    ;; There's a special keyword before the "<" that tells
		    ;; that it's an angle bracket arglist.
		    (setq kwd-sym (c-keyword-sym (match-string 2)))))

		 (t
		  ;; There's a normal identifier before the "<".  If we're not in
		  ;; a declaration context then we set `c-restricted-<>-arglists'
		  ;; to avoid recognizing templates in function calls like "foo (a
		  ;; < b, c > d)".
		  (c-backward-syntactic-ws)
		  (when (and (memq (char-before) '(?\( ?,))
			     (not (eq (get-text-property (1- (point)) 'c-type)
				      'c-decl-arg-start)))
		    (setq c-restricted-<>-arglists t))
		  t))

		(progn
		  (goto-char (1- pos))
		  ;; Check for comment/string both at the identifier and
		  ;; at the "<".
		  (unless (c-skip-comments-and-strings limit)

		    (c-fontify-types-and-refs ()
		      (when (c-forward-<>-arglist (c-keyword-member
						   kwd-sym 'c-<>-type-kwds))
			(when (and c-opt-identifier-concat-key
				   (not (get-text-property id-start 'face)))
			  (c-forward-syntactic-ws)
			  (cond ((looking-at c-opt-identifier-concat-key)
				 (c-put-font-lock-face id-start id-end
						       c-reference-face-name))
				((eq (char-after) ?\())
				(t (c-put-font-lock-face id-start id-end
							 'font-lock-type-face))))))

		    (goto-char pos)))
	      (goto-char pos)))))))
  nil)