diff options
| author | Alan Mackenzie | 2017-03-30 20:24:39 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2017-03-30 20:24:39 +0000 |
| commit | ef7df187eb0b631a6909bdc02f82b3dfef0ad689 (patch) | |
| tree | e37b293633b0d65f3ea2f21125021ae99bf0dc92 /doc/misc | |
| parent | 6ff870218dd4bc015cc4115ceb2febd8d807e57c (diff) | |
| download | emacs-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.texi | 60 |
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 | ||
| 279 | Configuration Basics | 280 | Configuration 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 | |||
| 2099 | If you add support for another doc comment style, please consider | 2101 | If you add support for another doc comment style, please consider |
| 2100 | contributing it: send a note to @email{bug-cc-mode@@gnu.org}. | 2102 | contributing 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 | |||
| 2110 | In some languages, particularly in C++, there are constructs which are | ||
| 2111 | syntactically ambiguous---they could be either declarations or | ||
| 2112 | expressions, and @ccmode{} cannot tell for sure which. Often such a | ||
| 2113 | construct is one of the operators @samp{*} or @samp{&} surrounded by | ||
| 2114 | two identifiers. | ||
| 2115 | |||
| 2116 | Experience shows that very often when such a construct is a | ||
| 2117 | declaration it will be written with the operator touching exactly one | ||
| 2118 | of the identifiers, like: | ||
| 2119 | |||
| 2120 | @example | ||
| 2121 | foo *bar | ||
| 2122 | @end example | ||
| 2123 | or | ||
| 2124 | @example | ||
| 2125 | foo& 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-) | ||
| 2133 | When @code{c-asymmetry-fontification-flag} is non-nil (which it is by | ||
| 2134 | default), code like the above, with white space either before or after | ||
| 2135 | the operator, but not both, is fontified as a declaration. When the | ||
| 2136 | variable is nil, such a construct gets the default face. | ||
| 2137 | @end defvar | ||
| 2138 | |||
| 2139 | When the construct is an expression there will often be white space | ||
| 2140 | both before and after the operator or there will be no white space | ||
| 2141 | around it at all, like: | ||
| 2142 | |||
| 2143 | @example | ||
| 2144 | foo * bar | ||
| 2145 | @end example | ||
| 2146 | or | ||
| 2147 | @example | ||
| 2148 | foo&bar | ||
| 2149 | @end example | ||
| 2150 | . | ||
| 2151 | |||
| 2152 | Such code is not fontified as a declaration. (Typically, the | ||
| 2153 | identifiers don't get a non-default face.) | ||
| 2154 | |||
| 2155 | For clarity's sake, we emphasize that the ``asymmetry'' rule in this | ||
| 2156 | section only applies when CC Mode cannot disambiguate a construct in | ||
| 2157 | any 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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |