Function: c-font-lock-doc-comments
c-font-lock-doc-comments is a byte-compiled function defined in
cc-fonts.el.gz.
Signature
(c-font-lock-doc-comments PREFIX LIMIT KEYWORDS)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-fonts.el.gz
(defun c-font-lock-doc-comments (prefix limit keywords)
;; Fontify the comments between the point and LIMIT whose start
;; matches PREFIX with `c-doc-face-name'. Assumes comments have been
;; fontified with `font-lock-comment-face' already. nil is always
;; returned.
;;
;; After the fontification of a matching comment, fontification
;; according to KEYWORDS is applied inside it. It's a list like
;; `font-lock-keywords' except that anchored matches and eval
;; clauses aren't supported and that some abbreviated forms can't be
;; used. The buffer is narrowed to the comment while KEYWORDS is
;; applied; leading comment starters are included but trailing
;; comment enders for block comment are not.
;;
;; Note that faces added through KEYWORDS should never replace the
;; existing `c-doc-face-name' face since the existence of that face
;; is used as a flag in other code to skip comments.
;;
;; This function might do hidden buffer changes.
(declare (indent 2))
(let (comment-beg region-beg comment-mid)
(if (memq (get-text-property (point) 'face)
'(font-lock-comment-face font-lock-comment-delimiter-face))
;; Handle the case when the fontified region starts inside a
;; comment.
(let ((start (c-literal-start)))
(setq region-beg (point)
comment-mid (point))
(when start
(goto-char start))
(when (looking-at prefix)
(setq comment-beg (point)))))
(while (or
comment-beg
;; Search for the prefix until a match is found at the start
;; of a comment.
(while (when (re-search-forward prefix limit t)
(setq comment-beg (match-beginning 0))
(or (not (c-got-face-at comment-beg
c-literal-faces))
(and (/= comment-beg (point-min))
;; Cheap check which is unreliable (the previous
;; character could be the end of a previous
;; comment).
(c-got-face-at (1- comment-beg)
c-literal-faces)
;; Expensive reliable check.
(save-excursion
(goto-char comment-beg)
(c-in-literal)))))
(setq comment-beg nil))
(setq region-beg comment-beg
comment-mid comment-beg))
(if (elt (parse-partial-sexp comment-beg (+ comment-beg 2)) 7)
;; Collect a sequence of doc style line comments.
(progn
(goto-char comment-beg)
(while (and (progn
(c-forward-single-comment)
(c-put-font-lock-face comment-mid (point)
c-doc-face-name)
(skip-syntax-forward " ")
(setq comment-beg (point)
comment-mid (point))
(< (point) limit))
(looking-at prefix))))
(goto-char comment-beg)
(c-forward-single-comment)
(c-put-font-lock-face region-beg (point) c-doc-face-name))
(if (> (point) limit) (goto-char limit))
(setq comment-beg nil)
(let ((region-end (point))
(keylist keywords) keyword matcher highlights)
(save-restriction
;; Narrow to the doc comment. Among other things, this
;; helps by making "^" match at the start of the comment.
;; Do not include a trailing block comment ender, though.
(and (> region-end (1+ region-beg))
(progn (goto-char region-end)
(backward-char 2)
(looking-at "\\*/"))
(setq region-end (point)))
(narrow-to-region region-beg region-end)
(while keylist
(setq keyword (car keylist)
keylist (cdr keylist)
matcher (car keyword))
(goto-char region-beg)
(while (if (stringp matcher)
(re-search-forward matcher region-end t)
(funcall matcher region-end))
(setq highlights (cdr keyword))
(if (consp (car highlights))
(while highlights
(font-lock-apply-highlight (car highlights))
(setq highlights (cdr highlights)))
(font-lock-apply-highlight highlights))))
(goto-char region-end)))))
nil)