aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc/cc-mode.texi
diff options
context:
space:
mode:
authorAlan Mackenzie2021-10-24 19:59:18 +0000
committerAlan Mackenzie2021-10-24 19:59:18 +0000
commit374f14fb9936d2b8fb30a123457ff4b12160f5f3 (patch)
tree40a64a795a614a055ba1ebeee95fdd1ce9cc0fec /doc/misc/cc-mode.texi
parent89365d748f15f2fd789c3818480a16849ac05a94 (diff)
downloademacs-374f14fb9936d2b8fb30a123457ff4b12160f5f3.tar.gz
emacs-374f14fb9936d2b8fb30a123457ff4b12160f5f3.zip
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-type-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, c-inhibit-type-finder): New variables. (c-leave-cc-mode-mode): Nullify c-post-command-hook, c-post-gc-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/Install c-post-command, c-c-type-finder-pos, c-type-finder-timer, and c-post-gc-hook. (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-post-gc-hook): New hook to prevent CC Mode activity immediately following GC, thus allowing keyboard/mouse input to be registered. (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.
Diffstat (limited to 'doc/misc/cc-mode.texi')
-rw-r--r--doc/misc/cc-mode.texi56
1 files changed, 56 insertions, 0 deletions
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi
index 98ded68e713..c255d9870fb 100644
--- a/doc/misc/cc-mode.texi
+++ b/doc/misc/cc-mode.texi
@@ -283,6 +283,8 @@ Font Locking
283* Font Locking Preliminaries:: 283* Font Locking Preliminaries::
284* Faces:: 284* Faces::
285* Doc Comments:: 285* Doc Comments::
286* Wrong Comment Style::
287* Found Types::
286* Misc Font Locking:: 288* Misc Font Locking::
287* AWK Mode Font Locking:: 289* AWK Mode Font Locking::
288 290
@@ -2162,6 +2164,60 @@ which aren't of the default style will be fontified with
2162@end defvar 2164@end defvar
2163 2165
2164@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2166@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2167@node Found Types
2168@comment node-name, next, previous, up
2169@section ``Found Type'' handling.
2170@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2171
2172In most languages handled by CC Mode, @dfn{found types} are recognized
2173as types by their context in the source code. These contrast with
2174types which are basic to a language or are declared as types (e.g. by
2175@code{typedef} in C).
2176
2177In earlier versions of @ccmode{}, when @code{jit-lock-mode} was
2178enabled in Emacs (which it is by default), found types would
2179frequently fail to get fontified properly. This happened when the
2180fontification functions scanned a use of the found type before
2181scanning the code which caused it to be recognized.
2182
2183From @ccmode{} version 5.36, a timer mechanism scans the entire buffer
2184for found types in the seconds immediately after starting the major
2185mode. When a found type gets recognized, all its occurrences in the
2186buffer get marked for (re)fontification. This scanning happens in
2187short time slices interleaved with other processing, such as keyboard
2188handling, so that the responsiveness of Emacs should be barely
2189affected. This mechanism can be disabled (see below). It is only
2190active when @code{jit-lock-mode} is also active.
2191
2192@defvar c-type-finder-time-slot
2193@vindex type-finder-time-slot (c-)
2194The approximate time in seconds that CC Mode spends in scanning source
2195code before relinquishing control to other Emacs activities. The
2196default value is 0.05. To disable the scanning mechanism, set this
2197variable to @code{nil}.
2198@end defvar
2199
2200@defvar c-type-finder-repeat-time
2201@vindex type-finder-repeat-time (c-)
2202The approximate frequency (in seconds) with which the scanning
2203mechanism is triggered. This time must be greater than
2204@code{c-type-finder-time-slot}. Its default value is 0.1. If a less
2205powerful machine becomes sluggish due to the scanning, increase the
2206value of @code{c-type-finder-repeat-time} to compensate.
2207@end defvar
2208
2209@defvar c-type-finder-chunk-size
2210@vindex type-finder-chunk-size (c-)
2211The approximate size (in characters) of the buffer chunk processed as
2212a unit before the scanning mechanism checks whether
2213@code{c-type-finder-time-slot} seconds have passed. The default value
2214is 1000. A too small value here will cause inefficiencies due to the
2215initialization which happens for each chunk, whereas a too large value
2216will cause the processing to consume an excessive proportion of the
2217@code{c-type-finder-repeat-time}.
2218@end defvar
2219
2220@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2165@node Misc Font Locking 2221@node Misc Font Locking
2166@comment node-name, next, previous, up 2222@comment node-name, next, previous, up
2167@section Miscellaneous Font Locking 2223@section Miscellaneous Font Locking