+2012-01-08 Alan Mackenzie <acm@muc.de>
+
+ Optimise font locking in long enum definitions.
+
+ * progmodes/cc-fonts.el (c-font-lock-declarations): Add an extra
+ arm to a cond form to handle enums.
+ * progmodes/cc-langs.el (c-enums-contain-decls): New lang variable.
+ * progmodes/cc-mode.el (c-font-lock-fontify-region): Correct a typo.
+
2012-01-07 Paul Eggert <eggert@cs.ucla.edu>
* files.el (move-file-to-trash): Preserve default file modes on error.
(c-fontify-recorded-types-and-refs)
nil)
+ ((and (not c-enums-contain-decls)
+ ;; An optimisation quickly to eliminate scans of long enum
+ ;; declarations in the next cond arm.
+ (let ((paren-state (c-parse-state)))
+ (and
+ (numberp (car paren-state))
+ (save-excursion
+ (goto-char (car paren-state))
+ (c-backward-token-2)
+ (or (looking-at c-brace-list-key)
+ (progn
+ (c-backward-token-2)
+ (looking-at c-brace-list-key)))))))
+ t)
+
(t
;; Are we at a declarator? Try to go back to the declaration
;; to check this. If we get there, check whether a "typedef"
(consp (c-lang-const c-<>-arglist-kwds))))
(c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists))
+(c-lang-defconst c-enums-contain-decls
+ "Non-nil means that an enum structure can contain declarations."
+ t nil
+ java t)
+(c-lang-defvar c-enums-contain-decls (c-lang-const c-enums-contain-decls))
+
(c-lang-defconst c-recognize-paren-inits
"Non-nil means that parenthesis style initializers exist,
i.e. constructs like
;; Effectively advice around `font-lock-fontify-region' which extends the
;; region (BEG END), for example, to avoid context fontification chopping
;; off the start of the context. Do not do anything if it's already been
- ;; done (i.e. from and after-change fontification. An example (C++) where
+ ;; done (i.e. from an after-change fontification. An example (C++) where
;; this used to happen is this:
;;
;; template <typename T>