]> git.eshelyaron.com Git - emacs.git/commit
CC Mode: Fontify "found types" which are recognized after being first scanned
authorAlan Mackenzie <acm@muc.de>
Fri, 22 Oct 2021 19:55:01 +0000 (19:55 +0000)
committerAlan Mackenzie <acm@muc.de>
Fri, 22 Oct 2021 19:55:01 +0000 (19:55 +0000)
commit51719617eb19833056618ebac403cdcaf711551a
tree763f33fade202c1d6c32d9dd7d22155f6ede9600
parent4cf06bb751c75dd2ae82c6e845c194107f93ee14
CC Mode: Fontify "found types" which are recognized after being first scanned

This aims to fix the scenario where on jit-lock's first scan of a type, it is
not recognized as such, and only later does this happen.  The fontification of
such found types is now done by background scanning in short time slices
immediately after initialising the mode.

* lisp/progmodes/cc-engine.el (c-add-type-1): New function.
(c-add-type): Extract c-add-type-1 from it, and reformulate the mechanism for
protecting c-found-types from excessive partial identifiers.

* lisp/progmodes/cc-fonts.el (c-font-lock-complex-decl-prepare): Remove the
code which cleared c-found-types on fontification at BOB.
(c-find-types-background): New function, based on c-font-lock-declarations).
(c-types-finder-timer-func): New function.
(c-re-redisplay-timer): New variable.
(c-force-redisplay, c-fontify-new-found-type): New functions.

* lisp/progmodes/cc-mode.el (c-type-finder-timer): New variable.
(c-leave-cc-mode-mode): Nullify c-post-command-hook and c-type-finder-timer
when the last CC Mode buffer of a session is killed.
(c-type-finder-pos): New variable.
(c-basic-common-init): Initialize c-type-finder-pos and c-type-finder-timer.
(c-new-id-start, c-new-id-end, c-new-id-is-type): New variables.
(c-update-new-id): New function.
(c-post-command): New post command hook function, used for checking moving
away from partially typed identifiers, and making them full identifiers.
(c-before-change): Add code to clear c-found-types on a buffer change at BOB.
(c-after-change): Call c-update-new-id to keep track of partially typed
identifiers.

* doc/misc/cc-mode.texi (Found Types): New @section in the @Chapter Font
Locking.

* lisp/progmodes/cc-vars.el (c-type-finder-time-slot)
(c-type-finder-repeat-time, c-type-finder-chunk-size): New customizable
options.
doc/misc/cc-mode.texi
lisp/progmodes/cc-engine.el
lisp/progmodes/cc-fonts.el
lisp/progmodes/cc-mode.el
lisp/progmodes/cc-vars.el