nil)))
+(defun c-font-lock-enum-body (limit)
+ ;; Fontify the identifiers of each enum we find by searching forward.
+ ;;
+ ;; 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".
+ (while (search-forward-regexp c-enum-clause-introduction-re limit t)
+ (when (save-excursion
+ (backward-char)
+ (c-backward-over-enum-header))
+ (c-forward-syntactic-ws)
+ (c-font-lock-declarators limit t nil t)))
+ nil)
+
(defun c-font-lock-enum-tail (limit)
;; Fontify an enum's identifiers when POINT is within the enum's brace
;; block.
generic casts and declarations are fontified. Used on level 2 and
higher."
- t `(,@(when (c-lang-const c-brace-id-list-kwds)
+ t `(,@(when (c-lang-const c-brace-list-decl-kwds)
;; Fontify the remaining identifiers inside an enum list when we start
;; inside it.
`(c-font-lock-enum-tail
;; Fontify the identifiers inside enum lists. (The enum type
;; name is handled by `c-simple-decl-matchers' or
;; `c-complex-decl-matchers' below.
- (,(c-make-font-lock-search-function
- (concat
- "\\<\\("
- (c-make-keywords-re nil (c-lang-const c-brace-id-list-kwds))
- "\\)\\>"
- ;; Disallow various common punctuation chars that can't come
- ;; before the '{' of the enum list, to avoid searching too far.
- "[^][{};/#=]*"
- "{")
- '((c-font-lock-declarators limit t nil t)
- (save-match-data
- (goto-char (match-end 0))
- (c-put-char-property (1- (point)) 'c-type
- 'c-decl-id-start)
- (c-forward-syntactic-ws))
- (goto-char (match-end 0)))))))
+ c-font-lock-enum-body))
;; Fontify labels after goto etc.
,@(when (c-lang-const c-before-label-kwds)
c++ "[<;{},>()]")
(c-lang-defvar c-<>-notable-chars-re (c-lang-const c-<>-notable-chars-re))
+(c-lang-defconst c-enum-clause-introduction-re
+ ;; A regexp loosely matching the start of an enum clause, starting at the
+ ;; keyword itself, and extending up to the "{". It may match text which
+ ;; isn't such a construct; more accurate tests will rule these out when
+ ;; needed.
+ t (if (c-lang-const c-brace-list-decl-kwds)
+ (concat
+ "\\<\\("
+ (c-make-keywords-re nil (c-lang-const c-brace-list-decl-kwds))
+ "\\)\\>"
+ ;; Disallow various common punctuation chars that can't come
+ ;; before the '{' of the enum list, to avoid searching too far.
+ "[^][{};/#=]*"
+ "{")
+ "\\<\\>"))
+(c-lang-defvar c-enum-clause-introduction-re
+ (c-lang-const c-enum-clause-introduction-re))
+
(c-lang-defconst c-enums-contain-decls
"Non-nil means that an enum structure can contain declarations."
t nil