aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorAlan Mackenzie2017-03-30 20:24:39 +0000
committerAlan Mackenzie2017-03-30 20:24:39 +0000
commitef7df187eb0b631a6909bdc02f82b3dfef0ad689 (patch)
treee37b293633b0d65f3ea2f21125021ae99bf0dc92 /doc/misc
parent6ff870218dd4bc015cc4115ceb2febd8d807e57c (diff)
downloademacs-ef7df187eb0b631a6909bdc02f82b3dfef0ad689.tar.gz
emacs-ef7df187eb0b631a6909bdc02f82b3dfef0ad689.zip
Fix C++ fontification problems 500 bytes after typing a space, and other bugs
Also implement the "asymmetric space" rule for fontifying otherwise ambiguous declarations/expressions. * lisp/progmodes/cc-engine.el (c-before-change-check-<>-operators): Don't set c-new-BEG or c-new-END when there is no need. (c-forward-decl-or-cast-1): Add "CASE 17.5" to implement the "asymmetric space" rule. * lisp/progmodes/cc-fonts.el (c-get-fontification-context): New function, extracted from c-font-lock-declarations. Add to this function processing to make `context' 'decl for lines contained within parens when these are also declarations. (c-font-lock-declarations): Call the newly extracted function above in place of inline code. * lisp/progmodes/cc-mode.el (c-fl-decl-start): Set point before calling c-literal-start. * lisp/progmodes/cc-vars.el (c-asymmetry-fontification-flag): New user option. * doc/misc/cc-mode.texi (Misc Font Locking): New node documenting the new "asymmetric fontification" rule, including the variable c-asymmetric-fontification-flag.
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/cc-mode.texi60
1 files changed, 58 insertions, 2 deletions
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi
index a29873b03b3..91e20fa7247 100644
--- a/doc/misc/cc-mode.texi
+++ b/doc/misc/cc-mode.texi
@@ -274,6 +274,7 @@ Font Locking
274* Font Locking Preliminaries:: 274* Font Locking Preliminaries::
275* Faces:: 275* Faces::
276* Doc Comments:: 276* Doc Comments::
277* Misc Font Locking::
277* AWK Mode Font Locking:: 278* AWK Mode Font Locking::
278 279
279Configuration Basics 280Configuration Basics
@@ -1821,6 +1822,7 @@ sections apply to the other languages.
1821* Font Locking Preliminaries:: 1822* Font Locking Preliminaries::
1822* Faces:: 1823* Faces::
1823* Doc Comments:: 1824* Doc Comments::
1825* Misc Font Locking::
1824* AWK Mode Font Locking:: 1826* AWK Mode Font Locking::
1825@end menu 1827@end menu
1826 1828
@@ -2023,7 +2025,7 @@ since those aren't syntactic errors in themselves.
2023 2025
2024 2026
2025@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2027@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2026@node Doc Comments, AWK Mode Font Locking, Faces, Font Locking 2028@node Doc Comments, Misc Font Locking, Faces, Font Locking
2027@comment node-name, next, previous, up 2029@comment node-name, next, previous, up
2028@section Documentation Comments 2030@section Documentation Comments
2029@cindex documentation comments 2031@cindex documentation comments
@@ -2099,9 +2101,63 @@ initialization and the result is prepended. For an example, see
2099If you add support for another doc comment style, please consider 2101If you add support for another doc comment style, please consider
2100contributing it: send a note to @email{bug-cc-mode@@gnu.org}. 2102contributing it: send a note to @email{bug-cc-mode@@gnu.org}.
2101 2103
2104@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2105@node Misc Font Locking, AWK Mode Font Locking, Doc Comments, Font Locking
2106@comment node-name, next, previous, up
2107@section Miscellaneous Font Locking
2108@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2109
2110In some languages, particularly in C++, there are constructs which are
2111syntactically ambiguous---they could be either declarations or
2112expressions, and @ccmode{} cannot tell for sure which. Often such a
2113construct is one of the operators @samp{*} or @samp{&} surrounded by
2114two identifiers.
2115
2116Experience shows that very often when such a construct is a
2117declaration it will be written with the operator touching exactly one
2118of the identifiers, like:
2119
2120@example
2121foo *bar
2122@end example
2123or
2124@example
2125foo& bar
2126@end example
2127
2128. Whether such code is fontified depends on the setting of
2129@code{c-asymmetry-fontification-flag}.
2130
2131@defvar c-asymmetry-fontification-flag
2132@vindex asymmetry-fontification-flag (c-)
2133When @code{c-asymmetry-fontification-flag} is non-nil (which it is by
2134default), code like the above, with white space either before or after
2135the operator, but not both, is fontified as a declaration. When the
2136variable is nil, such a construct gets the default face.
2137@end defvar
2138
2139When the construct is an expression there will often be white space
2140both before and after the operator or there will be no white space
2141around it at all, like:
2142
2143@example
2144foo * bar
2145@end example
2146or
2147@example
2148foo&bar
2149@end example
2150.
2151
2152Such code is not fontified as a declaration. (Typically, the
2153identifiers don't get a non-default face.)
2154
2155For clarity's sake, we emphasize that the ``asymmetry'' rule in this
2156section only applies when CC Mode cannot disambiguate a construct in
2157any other way.
2102 2158
2103@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2159@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2104@node AWK Mode Font Locking, , Doc Comments, Font Locking 2160@node AWK Mode Font Locking, , Misc Font Locking, Font Locking
2105@comment node-name, next, previous, up 2161@comment node-name, next, previous, up
2106@section AWK Mode Font Locking 2162@section AWK Mode Font Locking
2107@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2163@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!