aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorPaul Eggert2011-10-29 10:33:13 -0700
committerPaul Eggert2011-10-29 10:33:13 -0700
commit8d0eb4c275581847990b85dbb350caa3df9e653f (patch)
treec161f977d59ac3103b04dc0f4aea57c83436a456 /doc
parent929bb973dd3faf1655f03ac758942d5b009354ad (diff)
parent196e41e4aec1a44ec5b6e9bed485185ba872ae67 (diff)
downloademacs-8d0eb4c275581847990b85dbb350caa3df9e653f.tar.gz
emacs-8d0eb4c275581847990b85dbb350caa3df9e653f.zip
Merge from trunk.
Diffstat (limited to 'doc')
-rw-r--r--doc/misc/ChangeLog12
-rw-r--r--doc/misc/cc-mode.texi108
2 files changed, 120 insertions, 0 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 6b0ef9c5d8b..10a0d5e7a91 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,15 @@
12011-10-28 Alan Mackenzie <acm@muc.de>
2
3 * cc-mode.texi (Indentation Commands): Mention "macros with semicolons".
4 (Other Special Indentations): Add an xref to "Macros with ;".
5 (Customizing Macros): Add stuff about syntax in macros. Add an xref to
6 "Macros with ;".
7 (Macros with ;): New page.
8
9 * progmodes/cc-mode.texi (Movement Commands): Document
10 `c-defun-tactic'. Document the new handling of nested scopes for
11 movement by defuns.
12
12011-10-23 Michael Albinus <michael.albinus@gmx.de> 132011-10-23 Michael Albinus <michael.albinus@gmx.de>
2 14
3 Sync with Tramp 2.2.3. 15 Sync with Tramp 2.2.3.
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi
index a9339162666..887e3f3c808 100644
--- a/doc/misc/cc-mode.texi
+++ b/doc/misc/cc-mode.texi
@@ -341,6 +341,11 @@ Line-Up Functions
341* Comment Line-Up:: 341* Comment Line-Up::
342* Misc Line-Up:: 342* Misc Line-Up::
343 343
344Customizing Macros
345
346* Macro Backslashes::
347* Macros with ;::
348
344@end detailmenu 349@end detailmenu
345@end menu 350@end menu
346 351
@@ -655,6 +660,10 @@ expression, to some statements, or perhaps to whole functions, the
655syntactic recognition can be wrong. @ccmode{} manages to figure it 660syntactic recognition can be wrong. @ccmode{} manages to figure it
656out correctly most of the time, though. 661out correctly most of the time, though.
657 662
663Some macros, when invoked, ''have their own semicolon''. To get the
664next line indented correctly, rather than as a continuation line,
665@xref{Macros with ;}.
666
658Reindenting large sections of code can take a long time. When 667Reindenting large sections of code can take a long time. When
659@ccmode{} reindents a region of code, it is essentially equivalent to 668@ccmode{} reindents a region of code, it is essentially equivalent to
660hitting @key{TAB} on every line of the region. 669hitting @key{TAB} on every line of the region.
@@ -882,6 +891,8 @@ lines.
882@itemx @kbd{C-M-e} (@code{c-end-of-defun}) 891@itemx @kbd{C-M-e} (@code{c-end-of-defun})
883@findex c-beginning-of-defun 892@findex c-beginning-of-defun
884@findex c-end-of-defun 893@findex c-end-of-defun
894@vindex c-defun-tactic
895@vindex defun-tactic (c-)
885 896
886Move to the beginning or end of the current or next function. Other 897Move to the beginning or end of the current or next function. Other
887constructs (such as a structs or classes) which have a brace block 898constructs (such as a structs or classes) which have a brace block
@@ -895,6 +906,15 @@ commands try to leave point at the beginning of a line near the actual
895start or end of the function. This occasionally causes point not to 906start or end of the function. This occasionally causes point not to
896move at all. 907move at all.
897 908
909By default, these commands will recognize functions contained within a
910@dfn{declaration scope} such as a C++ @code{class} or @code{namespace}
911construct, should the point start inside it. If @ccmode fails to find
912function beginnings or ends inside the current declaration scope, it
913will search the enclosing scopes. If you want @ccmode to recognize
914functions only at the top level@footnote{this was @ccmode{}'s
915behaviour prior to version 5.32.}, set @code{c-defun-tatic} to
916@code{t}.
917
898These functions are analogous to the Emacs built-in commands 918These functions are analogous to the Emacs built-in commands
899@code{beginning-of-defun} and @code{end-of-defun}, except they 919@code{beginning-of-defun} and @code{end-of-defun}, except they
900eliminate the constraint that the top-level opening brace of the defun 920eliminate the constraint that the top-level opening brace of the defun
@@ -6550,6 +6570,9 @@ custom line-up function associated with it.
6550@section Other Special Indentations 6570@section Other Special Indentations
6551@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6571@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6552 6572
6573To configure macros which you invoke without a terminating @samp{;},
6574see @xref{Macros with ;}.
6575
6553Here are the remaining odds and ends regarding indentation: 6576Here are the remaining odds and ends regarding indentation:
6554 6577
6555@defopt c-label-minimum-indentation 6578@defopt c-label-minimum-indentation
@@ -6601,6 +6624,13 @@ functions to this hook, not remove them. @xref{Style Variables}.
6601@cindex preprocessor directives 6624@cindex preprocessor directives
6602@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6625@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6603 6626
6627Preprocessor macros in C, C++, and Objective C (introduced by
6628@code{#define}) have a syntax different from the main language---for
6629example, a macro declaration is not terminated by a semicolon, and if
6630it is more than a line long, line breaks in it must be escaped with
6631backslashes. @ccmode{} has some commands to manipulate these, see
6632@ref{Macro Backslashes}.
6633
6604Normally, the lines in a multi-line macro are indented relative to 6634Normally, the lines in a multi-line macro are indented relative to
6605each other as though they were code. You can suppress this behavior 6635each other as though they were code. You can suppress this behavior
6606by setting the following user option: 6636by setting the following user option:
@@ -6612,6 +6642,28 @@ is @code{nil}, all lines inside macro definitions are analyzed as
6612@code{cpp-macro-cont}. 6642@code{cpp-macro-cont}.
6613@end defopt 6643@end defopt
6614 6644
6645Because a macro can expand into anything at all, near where one is
6646invoked @ccmode{} can only indent and fontify code heuristically.
6647Sometimes it gets it wrong. Usually you should try to design your
6648macros so that they ''look like ordinary code'' when you invoke them.
6649However, one situation is so common that @ccmode{} handles it
6650specially: that is when certain macros needn't (or mustn't) be
6651followed by a @samp{;}. You need to configure @ccmode{} to handle
6652these macros properly, see @ref{Macros with ;}.
6653
6654@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6655@menu
6656* Macro Backslashes::
6657* Macros with ;::
6658@end menu
6659
6660@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6661@node Macro Backslashes, Macros with ;, Custom Macros, Custom Macros
6662@comment node-name, next, previous, up
6663@section Customizing Macro Backslashes
6664@cindex #define
6665@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6666
6615@ccmode{} provides some tools to help keep the line continuation 6667@ccmode{} provides some tools to help keep the line continuation
6616backslashes in macros neat and tidy. Their precise action is 6668backslashes in macros neat and tidy. Their precise action is
6617customized with these variables: 6669customized with these variables:
@@ -6654,6 +6706,62 @@ get aligned only when you explicitly invoke the command
6654@end defopt 6706@end defopt
6655 6707
6656@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6708@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6709@node Macros with ;, , Macro Backslashes, Custom Macros
6710@comment node-name, next, previous, up
6711@section Macros with semicolons
6712@cindex macros with semicolons
6713@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6714Macros which needn't (or mustn't) be followed by a semicolon when you
6715invoke them, @dfn{macros with semicolons}, are very common. These can
6716cause @ccmode{} to parse the next line wrongly as a
6717@code{statement-cont} (@pxref{Function Symbols}) and thus mis-indent
6718it.
6719
6720You can prevent this by specifying which macros have semicolons. It
6721doesn't matter whether or not such a macro has a parameter list:
6722
6723@defopt c-macro-names-with-semicolon
6724@vindex macro-names-with-semicolon (c-)
6725This buffer-local variable specifies which macros have semicolons.
6726After setting its value, you need to call
6727@code{c-make-macro-with-semi-re} for it to take effect. It should be
6728set to one of these values:
6729
6730@table @asis
6731@item nil
6732There are no macros with semicolons.
6733@item a list of strings
6734Each string is the name of a macro with a semicolon. Only valid
6735@code{#define} names are allowed here. For example, to set the
6736default value, you could write the following into your @file{.emacs}:
6737
6738@example
6739(setq c-macro-names-with-semicolon
6740 '("Q_OBJECT" "Q_PROPERTY" "Q_DECLARE" "Q_ENUMS"))
6741@end example
6742
6743@item a regular expression
6744This matches each symbol which is a macro with a semicolon. It must
6745not match any string which isn't a valid @code{#define} name. For
6746example:
6747
6748@example
6749(setq c-macro-names-with-semicolon
6750 "\\<\\(CLEAN_UP_AND_RETURN\\|Q_[[:upper:]]+\\)\\>")
6751@end example
6752@end table
6753@end defopt
6754
6755@defun c-make-macro-with-semi-re
6756@findex make-macro-with-semi-re (c-)
6757Call this (non-interactive) function, which sets internal variables,
6758each time you change the value of
6759@code{c-macro-names-with-semicolon}. It takes no arguments, and its
6760return value has no meaning. This function is called by @ccmode{}'s
6761initialization code.
6762@end defun
6763
6764@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6657@node Odds and Ends, Sample .emacs File, Custom Macros, Top 6765@node Odds and Ends, Sample .emacs File, Custom Macros, Top
6658@comment node-name, next, previous, up 6766@comment node-name, next, previous, up
6659@chapter Odds and Ends 6767@chapter Odds and Ends