diff options
| author | Alan Mackenzie | 2019-11-09 12:09:30 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2019-11-09 12:09:30 +0000 |
| commit | b293aa91bcc7f553ffbc6c67027f3c86d06ffbd7 (patch) | |
| tree | 39f019da4ce7a41d1367c01f590487b529bad2a3 /doc/misc | |
| parent | 6daa80d04e575a27f53f60f5fafd7fcba39b4b2a (diff) | |
| download | emacs-b293aa91bcc7f553ffbc6c67027f3c86d06ffbd7.tar.gz emacs-b293aa91bcc7f553ffbc6c67027f3c86d06ffbd7.zip | |
CC Mode. Allow fontification of "wrong" style comments with warning face.
This fixes bug #4192.
* etc/NEWS: Add a new entry.
* lisp/progmodes/cc-defs.el (c-font-lock-flush): New macro.
* lisp/progmodes/cc-cmds.el (c-toggle-comment-style): On toggling the comment
style, invoke c-font-lock-flush when c-mark-wrong-style-of-comment is non-nil,
to cause that marking to be done instead on the other style of comment.
* lisp/progmodes/cc-fonts.el (c-maybe-font-lock-wrong-style-comments): New
function.
(c-cpp-matchers): Call c-maybe-font-lock-wrong-style-comments when
appropriate.
* lisp/progmodes/cc-vars.el (c-mark-wrong-style-of-comment): New customizable
option.
* doc/misc/cc-mode.texi (top level, Indentation Commands, Guessing the Style,
Custom Macros): For some opening quote marks, correct '' to ``.
(Minor Modes): Add an xref to the new page "Wrong Comment Style" in a
footnote.
(Wrong Comment Style): New page.
Diffstat (limited to 'doc/misc')
| -rw-r--r-- | doc/misc/cc-mode.texi | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index 217261090bf..a802ca9886f 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi | |||
| @@ -669,7 +669,7 @@ expression, to some statements, or perhaps to whole functions, the | |||
| 669 | syntactic recognition can be wrong. @ccmode{} manages to figure it | 669 | syntactic recognition can be wrong. @ccmode{} manages to figure it |
| 670 | out correctly most of the time, though. | 670 | out correctly most of the time, though. |
| 671 | 671 | ||
| 672 | Some macros, when invoked, ''have their own semicolon''. To get the | 672 | Some macros, when invoked, ``have their own semicolon''. To get the |
| 673 | next line indented correctly, rather than as a continuation line, | 673 | next line indented correctly, rather than as a continuation line, |
| 674 | @xref{Macros with ;}. | 674 | @xref{Macros with ;}. |
| 675 | 675 | ||
| @@ -1149,7 +1149,9 @@ find useful while writing new code or editing old code: | |||
| 1149 | @table @asis | 1149 | @table @asis |
| 1150 | @item comment style | 1150 | @item comment style |
| 1151 | This specifies whether comment commands (such as @kbd{M-;}) insert | 1151 | This specifies whether comment commands (such as @kbd{M-;}) insert |
| 1152 | block comments or line comments. | 1152 | block comments or line comments@footnote{You can emphasize |
| 1153 | non-default style comments in your code by giving their delimiters | ||
| 1154 | @code{font-lock-warning-face}. @xref{Wrong Comment Style}.}. | ||
| 1153 | @item electric mode | 1155 | @item electric mode |
| 1154 | When this is enabled, certain visible characters cause reformatting as | 1156 | When this is enabled, certain visible characters cause reformatting as |
| 1155 | they are typed. This is normally helpful, but can be a nuisance when | 1157 | they are typed. This is normally helpful, but can be a nuisance when |
| @@ -1866,6 +1868,7 @@ sections apply to the other languages. | |||
| 1866 | * Font Locking Preliminaries:: | 1868 | * Font Locking Preliminaries:: |
| 1867 | * Faces:: | 1869 | * Faces:: |
| 1868 | * Doc Comments:: | 1870 | * Doc Comments:: |
| 1871 | * Wrong Comment Style:: | ||
| 1869 | * Misc Font Locking:: | 1872 | * Misc Font Locking:: |
| 1870 | * AWK Mode Font Locking:: | 1873 | * AWK Mode Font Locking:: |
| 1871 | @end menu | 1874 | @end menu |
| @@ -2069,7 +2072,7 @@ since those aren't syntactic errors in themselves. | |||
| 2069 | 2072 | ||
| 2070 | 2073 | ||
| 2071 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2074 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2072 | @node Doc Comments, Misc Font Locking, Faces, Font Locking | 2075 | @node Doc Comments, Wrong Comment Style, Faces, Font Locking |
| 2073 | @comment node-name, next, previous, up | 2076 | @comment node-name, next, previous, up |
| 2074 | @section Documentation Comments | 2077 | @section Documentation Comments |
| 2075 | @cindex documentation comments | 2078 | @cindex documentation comments |
| @@ -2149,7 +2152,29 @@ If you add support for another doc comment style, please consider | |||
| 2149 | contributing it: send a note to @email{bug-cc-mode@@gnu.org}. | 2152 | contributing it: send a note to @email{bug-cc-mode@@gnu.org}. |
| 2150 | 2153 | ||
| 2151 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2154 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2152 | @node Misc Font Locking, AWK Mode Font Locking, Doc Comments, Font Locking | 2155 | @node Wrong Comment Style, Misc Font Locking, Doc Comments, Font Locking |
| 2156 | @comment node-name, next, previous, up | ||
| 2157 | @section Marking ``Wrong'' style comments | ||
| 2158 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| 2159 | |||
| 2160 | Most languages supported by @ccmode{} have two styles of comments, | ||
| 2161 | namely block comments and line comments. Your project may have such a | ||
| 2162 | strong preference for one of them, that you wish ``wrong'' style | ||
| 2163 | comments to be clearly marked. | ||
| 2164 | |||
| 2165 | You can get @ccmode{} to do this by setting the default comment style, | ||
| 2166 | if necessary, (@pxref{Minor Modes}) and setting the customizable | ||
| 2167 | option @code{c-mark-wrong-style-of-comment} to non-@code{nil}. | ||
| 2168 | |||
| 2169 | @defvar c-mark-wrong-style-of-comment | ||
| 2170 | @vindex mark-wrong-style-of-comment (c-) | ||
| 2171 | When this customizable option is non-@code{nil}, comment delimiters | ||
| 2172 | which aren't of the default style will be fontified with | ||
| 2173 | @code{font-lock-warning-face}. | ||
| 2174 | @end defvar | ||
| 2175 | |||
| 2176 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| 2177 | @node Misc Font Locking, AWK Mode Font Locking, Wrong Comment Style, Font Locking | ||
| 2153 | @comment node-name, next, previous, up | 2178 | @comment node-name, next, previous, up |
| 2154 | @section Miscellaneous Font Locking | 2179 | @section Miscellaneous Font Locking |
| 2155 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2180 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| @@ -2885,11 +2910,11 @@ should not be changed directly; use @code{c-add-style} instead. | |||
| 2885 | 2910 | ||
| 2886 | Instead of specifying a style, you can get @ccmode{} to @dfn{guess} | 2911 | Instead of specifying a style, you can get @ccmode{} to @dfn{guess} |
| 2887 | your style by examining an already formatted code buffer. @ccmode{} | 2912 | your style by examining an already formatted code buffer. @ccmode{} |
| 2888 | then determines the ''most frequent'' offset (@pxref{c-offsets-alist}) | 2913 | then determines the ``most frequent'' offset (@pxref{c-offsets-alist}) |
| 2889 | for each of the syntactic symbols (@pxref{Indentation Engine Basics}) | 2914 | for each of the syntactic symbols (@pxref{Indentation Engine Basics}) |
| 2890 | encountered in the buffer, and the ''most frequent'' value of | 2915 | encountered in the buffer, and the ``most frequent'' value of |
| 2891 | c-basic-offset (@pxref{Customizing Indentation}), then merges the | 2916 | c-basic-offset (@pxref{Customizing Indentation}), then merges the |
| 2892 | current style with these ''guesses'' to form a new style. This | 2917 | current style with these ``guesses'' to form a new style. This |
| 2893 | combined style is known as the @dfn{guessed style}. | 2918 | combined style is known as the @dfn{guessed style}. |
| 2894 | 2919 | ||
| 2895 | To do this, call @code{c-guess} (or one of the other 5 guessing | 2920 | To do this, call @code{c-guess} (or one of the other 5 guessing |
| @@ -6927,7 +6952,7 @@ is @code{nil}, all lines inside macro definitions are analyzed as | |||
| 6927 | Because a macro can expand into anything at all, near where one is | 6952 | Because a macro can expand into anything at all, near where one is |
| 6928 | invoked @ccmode{} can only indent and fontify code heuristically. | 6953 | invoked @ccmode{} can only indent and fontify code heuristically. |
| 6929 | Sometimes it gets it wrong. Usually you should try to design your | 6954 | Sometimes it gets it wrong. Usually you should try to design your |
| 6930 | macros so that they ''look like ordinary code'' when you invoke them. | 6955 | macros so that they ``look like ordinary code'' when you invoke them. |
| 6931 | However, two situations are so common that @ccmode{} handles them | 6956 | However, two situations are so common that @ccmode{} handles them |
| 6932 | specially: that is when certain macros needn't (or mustn't) be | 6957 | specially: that is when certain macros needn't (or mustn't) be |
| 6933 | followed by a @samp{;}, and when certain macros (or compiler | 6958 | followed by a @samp{;}, and when certain macros (or compiler |