Commit 9d5a8f0b authored by Alan Mackenzie's avatar Alan Mackenzie
Browse files

Optimise font locking in long enum definitions.

parent 1355012a
2012-01-08 Alan Mackenzie <>
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 <>
* files.el (move-file-to-trash): Preserve default file modes on error.
......@@ -1428,6 +1428,21 @@ casts and declarations are fontified. Used on level 2 and higher."
((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)))
(numberp (car paren-state))
(goto-char (car paren-state))
(or (looking-at c-brace-list-key)
(looking-at c-brace-list-key)))))))
;; Are we at a declarator? Try to go back to the declaration
;; to check this. If we get there, check whether a "typedef"
......@@ -2938,6 +2938,12 @@ expression is considered to be a type."
(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
......@@ -1158,7 +1158,7 @@ Note that the style variables are always made local to the buffer."
;; 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>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment