aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorAlan Mackenzie2019-11-09 12:09:30 +0000
committerAlan Mackenzie2019-11-09 12:09:30 +0000
commitb293aa91bcc7f553ffbc6c67027f3c86d06ffbd7 (patch)
tree39f019da4ce7a41d1367c01f590487b529bad2a3 /doc/misc
parent6daa80d04e575a27f53f60f5fafd7fcba39b4b2a (diff)
downloademacs-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.texi41
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
669syntactic recognition can be wrong. @ccmode{} manages to figure it 669syntactic recognition can be wrong. @ccmode{} manages to figure it
670out correctly most of the time, though. 670out correctly most of the time, though.
671 671
672Some macros, when invoked, ''have their own semicolon''. To get the 672Some macros, when invoked, ``have their own semicolon''. To get the
673next line indented correctly, rather than as a continuation line, 673next 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
1151This specifies whether comment commands (such as @kbd{M-;}) insert 1151This specifies whether comment commands (such as @kbd{M-;}) insert
1152block comments or line comments. 1152block comments or line comments@footnote{You can emphasize
1153non-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
1154When this is enabled, certain visible characters cause reformatting as 1156When this is enabled, certain visible characters cause reformatting as
1155they are typed. This is normally helpful, but can be a nuisance when 1157they 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
2149contributing it: send a note to @email{bug-cc-mode@@gnu.org}. 2152contributing 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
2160Most languages supported by @ccmode{} have two styles of comments,
2161namely block comments and line comments. Your project may have such a
2162strong preference for one of them, that you wish ``wrong'' style
2163comments to be clearly marked.
2164
2165You can get @ccmode{} to do this by setting the default comment style,
2166if necessary, (@pxref{Minor Modes}) and setting the customizable
2167option @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-)
2171When this customizable option is non-@code{nil}, comment delimiters
2172which 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
2886Instead of specifying a style, you can get @ccmode{} to @dfn{guess} 2911Instead of specifying a style, you can get @ccmode{} to @dfn{guess}
2887your style by examining an already formatted code buffer. @ccmode{} 2912your style by examining an already formatted code buffer. @ccmode{}
2888then determines the ''most frequent'' offset (@pxref{c-offsets-alist}) 2913then determines the ``most frequent'' offset (@pxref{c-offsets-alist})
2889for each of the syntactic symbols (@pxref{Indentation Engine Basics}) 2914for each of the syntactic symbols (@pxref{Indentation Engine Basics})
2890encountered in the buffer, and the ''most frequent'' value of 2915encountered in the buffer, and the ``most frequent'' value of
2891c-basic-offset (@pxref{Customizing Indentation}), then merges the 2916c-basic-offset (@pxref{Customizing Indentation}), then merges the
2892current style with these ''guesses'' to form a new style. This 2917current style with these ``guesses'' to form a new style. This
2893combined style is known as the @dfn{guessed style}. 2918combined style is known as the @dfn{guessed style}.
2894 2919
2895To do this, call @code{c-guess} (or one of the other 5 guessing 2920To 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
6927Because a macro can expand into anything at all, near where one is 6952Because a macro can expand into anything at all, near where one is
6928invoked @ccmode{} can only indent and fontify code heuristically. 6953invoked @ccmode{} can only indent and fontify code heuristically.
6929Sometimes it gets it wrong. Usually you should try to design your 6954Sometimes it gets it wrong. Usually you should try to design your
6930macros so that they ''look like ordinary code'' when you invoke them. 6955macros so that they ``look like ordinary code'' when you invoke them.
6931However, two situations are so common that @ccmode{} handles them 6956However, two situations are so common that @ccmode{} handles them
6932specially: that is when certain macros needn't (or mustn't) be 6957specially: that is when certain macros needn't (or mustn't) be
6933followed by a @samp{;}, and when certain macros (or compiler 6958followed by a @samp{;}, and when certain macros (or compiler