summaryrefslogtreecommitdiff
path: root/doc/misc/cc-mode.texi
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2021-10-24 19:59:18 +0000
committerAlan Mackenzie <acm@muc.de>2021-10-24 19:59:18 +0000
commit374f14fb9936d2b8fb30a123457ff4b12160f5f3 (patch)
tree40a64a795a614a055ba1ebeee95fdd1ce9cc0fec /doc/misc/cc-mode.texi
parent89365d748f15f2fd789c3818480a16849ac05a94 (diff)
downloademacs-374f14fb9936d2b8fb30a123457ff4b12160f5f3.tar.gz
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
* Font Locking Preliminaries::
* Faces::
* Doc Comments::
+* Wrong Comment Style::
+* Found Types::
* Misc Font Locking::
* AWK Mode Font Locking::
@@ -2162,6 +2164,60 @@ which aren't of the default style will be fontified with
@end defvar
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+@node Found Types
+@comment node-name, next, previous, up
+@section ``Found Type'' handling.
+@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+In most languages handled by CC Mode, @dfn{found types} are recognized
+as types by their context in the source code. These contrast with
+types which are basic to a language or are declared as types (e.g. by
+@code{typedef} in C).
+
+In earlier versions of @ccmode{}, when @code{jit-lock-mode} was
+enabled in Emacs (which it is by default), found types would
+frequently fail to get fontified properly. This happened when the
+fontification functions scanned a use of the found type before
+scanning the code which caused it to be recognized.
+
+From @ccmode{} version 5.36, a timer mechanism scans the entire buffer
+for found types in the seconds immediately after starting the major
+mode. When a found type gets recognized, all its occurrences in the
+buffer get marked for (re)fontification. This scanning happens in
+short time slices interleaved with other processing, such as keyboard
+handling, so that the responsiveness of Emacs should be barely
+affected. This mechanism can be disabled (see below). It is only
+active when @code{jit-lock-mode} is also active.
+
+@defvar c-type-finder-time-slot
+@vindex type-finder-time-slot (c-)
+The approximate time in seconds that CC Mode spends in scanning source
+code before relinquishing control to other Emacs activities. The
+default value is 0.05. To disable the scanning mechanism, set this
+variable to @code{nil}.
+@end defvar
+
+@defvar c-type-finder-repeat-time
+@vindex type-finder-repeat-time (c-)
+The approximate frequency (in seconds) with which the scanning
+mechanism is triggered. This time must be greater than
+@code{c-type-finder-time-slot}. Its default value is 0.1. If a less
+powerful machine becomes sluggish due to the scanning, increase the
+value of @code{c-type-finder-repeat-time} to compensate.
+@end defvar
+
+@defvar c-type-finder-chunk-size
+@vindex type-finder-chunk-size (c-)
+The approximate size (in characters) of the buffer chunk processed as
+a unit before the scanning mechanism checks whether
+@code{c-type-finder-time-slot} seconds have passed. The default value
+is 1000. A too small value here will cause inefficiencies due to the
+initialization which happens for each chunk, whereas a too large value
+will cause the processing to consume an excessive proportion of the
+@code{c-type-finder-repeat-time}.
+@end defvar
+
+@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node Misc Font Locking
@comment node-name, next, previous, up
@section Miscellaneous Font Locking