aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorAlan Mackenzie2016-02-29 21:51:32 +0000
committerAlan Mackenzie2016-02-29 21:51:32 +0000
commit71dc8213b18d4baa5802cf6b7181d81f1f76cbdb (patch)
tree54831c443e29609d57d02ab4916b4d34a921350d /doc/misc
parent93bf7d52841c60ffc10e0c9c789a7987812ce55e (diff)
downloademacs-71dc8213b18d4baa5802cf6b7181d81f1f76cbdb.tar.gz
emacs-71dc8213b18d4baa5802cf6b7181d81f1f76cbdb.zip
Handle "noise" macros and compiler directives.
* lisp/progmodes/cc-langs.el (c-symbol-char-key): New language variable. * lisp/progmodes/cc-vars.el (c-noise-macro-names) (c-noise-macro-with-parens-names): New customizable variables. (c-noise-macro-name-re, c-noise-macro-with-parens-name-re): New variables. (c-make-noise-macro-regexps): New function. * lisp/progmodes/cc-engine.el (c-forward-sws, c-backward-sws): Adapt to treat members of c-noise-macro-names as whitespace. (c-forward-noise-clause): New function. (c-forward-keyword-prefixed-id, c-forward-type, c-forward-declarator) (c-forward-decl-or-cast-1, c-backward-over-enum-header) (c-guess-basic-syntax CASE 5A.3, CASE 5A.5, CASE 9A): Handle "noise clauses" in parallel with, e.g., "hangon key clauses". * lisp/progmodes/cc-fonts.el (c-complex-decl-matchers): Handle "noise clauses" in parallel with "prefix-spec keywords". * lisp/progmodes/cc-mode.el (c-mode, c++-mode, objc-mode): call c-make-noise-macro-regexps to initialize the internal variables. * doc/misc/cc-mode.texi ("Noise Macros"): New section documenting the new facilities.
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/cc-mode.texi68
1 files changed, 63 insertions, 5 deletions
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi
index bc8d24fd992..cdc659ab358 100644
--- a/doc/misc/cc-mode.texi
+++ b/doc/misc/cc-mode.texi
@@ -338,14 +338,15 @@ Line-Up Functions
338* Comment Line-Up:: 338* Comment Line-Up::
339* Misc Line-Up:: 339* Misc Line-Up::
340 340
341
341Customizing Macros 342Customizing Macros
342 343
343* Macro Backslashes:: 344* Macro Backslashes::
344* Macros with ;:: 345* Macros with ;::
346* Noise Macros::
345 347
346@end detailmenu 348@end detailmenu
347@end menu 349@end menu
348
349@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 350@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
350@node Introduction, Overview, Top, Top 351@node Introduction, Overview, Top, Top
351@comment node-name, next, previous, up 352@comment node-name, next, previous, up
@@ -6639,15 +6640,18 @@ Because a macro can expand into anything at all, near where one is
6639invoked @ccmode{} can only indent and fontify code heuristically. 6640invoked @ccmode{} can only indent and fontify code heuristically.
6640Sometimes it gets it wrong. Usually you should try to design your 6641Sometimes it gets it wrong. Usually you should try to design your
6641macros so that they ''look like ordinary code'' when you invoke them. 6642macros so that they ''look like ordinary code'' when you invoke them.
6642However, one situation is so common that @ccmode{} handles it 6643However, two situations are so common that @ccmode{} handles them
6643specially: that is when certain macros needn't (or mustn't) be 6644specially: that is when certain macros needn't (or mustn't) be
6644followed by a @samp{;}. You need to configure @ccmode{} to handle 6645followed by a @samp{;}, and when certain macros (or compiler
6645these macros properly, see @ref{Macros with ;}. 6646directives) expand to nothing. You need to configure @ccmode{} to
6647handle these macros properly, see @ref{Macros with ;} and @ref{Noise
6648Macros}.
6646 6649
6647@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6650@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6648@menu 6651@menu
6649* Macro Backslashes:: 6652* Macro Backslashes::
6650* Macros with ;:: 6653* Macros with ;::
6654* Noise Macros::
6651@end menu 6655@end menu
6652 6656
6653@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6657@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -6699,7 +6703,7 @@ get aligned only when you explicitly invoke the command
6699@end defopt 6703@end defopt
6700 6704
6701@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6705@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6702@node Macros with ;, , Macro Backslashes, Custom Macros 6706@node Macros with ;, Noise Macros, Macro Backslashes, Custom Macros
6703@comment node-name, next, previous, up 6707@comment node-name, next, previous, up
6704@section Macros with semicolons 6708@section Macros with semicolons
6705@cindex macros with semicolons 6709@cindex macros with semicolons
@@ -6755,6 +6759,60 @@ initialization code.
6755@end defun 6759@end defun
6756 6760
6757@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6761@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6762@node Noise Macros, , Macros with ;, Custom Macros
6763@comment node-name, next, previous, up
6764@section Noise Macros
6765@cindex noise macros
6766@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6767
6768In @ccmode{}, @dfn{noise macros} are macros which expand to nothing,
6769or compiler directives (such as GCC's @code{__attribute__}) which play
6770no part in the syntax of the C (etc.) language. Some noise macros are
6771followed by arguments in parentheses (possibly optionally), others
6772are not.
6773
6774Noise macros can easily confuse @ccmode{}'s analysis of function
6775headers, causing them to be mis-fontified, or even mis-indented. You
6776can prevent this confusion by specifying the identifiers which
6777constitute noise macros.
6778
6779@defopt c-noise-macro-names
6780@vindex noise-macro-names (c-)
6781This variable is a list of names of noise macros which never have
6782parenthesized arguments. Each element is a string, and must be a
6783valid identifier. An element in @code{c-noise-macro-names} must not
6784also be in @code{c-noise-macro-with-parens-names}. Such an element is
6785treated as whitespace by @ccmode{}.
6786@end defopt
6787
6788@defopt c-noise-macro-with-parens-names
6789@vindex noise-macro-with-parens-names (c-)
6790This variable is a list of names of noise macros which optionally have
6791arguments in parentheses. Each element of the list is a string, and
6792must be a valid identifier. An element in
6793@code{c-noise-macro-with-parens-names} must not also be in
6794@code{c-noise-macro-names}. For performance reasons, such an element,
6795together with the optional parenthesized arguments, is specially
6796handled, but it is only handled when used in declaration
6797contexts@footnote{If this restriction causes your project
6798difficulties, please get in touch with @email{bug-cc-mode@@gnu.org}.}.
6799
6800The two compiler directives @code{__attribute__} and @code{__declspec}
6801have traditionally been handled specially in @ccmode{}; for example
6802they are fontified with font-lock-keyword-face. You don't need to
6803include these directives in @code{c-noise-macro-with-parens-names},
6804but doing so is OK.
6805@end defopt
6806
6807@defun c-make-noise-macro-regexps
6808@findex make-noise-macro-regexps (c-)
6809Call this (non-interactive) function, which sets internal variables,
6810after changing the value of @code{c-noise-macro-names} or
6811@code{c-noise-macro-with-parens-names} (e.g. in a hook (@pxref{CC
6812Hooks})). This function is called by @ccmode{}'s initialization code.
6813@end defun
6814
6815@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6758@node Odds and Ends, Sample Init File, Custom Macros, Top 6816@node Odds and Ends, Sample Init File, Custom Macros, Top
6759@comment node-name, next, previous, up 6817@comment node-name, next, previous, up
6760@chapter Odds and Ends 6818@chapter Odds and Ends