1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/7d5f3dc2941d/
Changeset: 7d5f3dc2941d
User: acm
Date: 2017-03-19 16:32:42+00:00
Summary: Fix chaotic indentation of C++ lambda. Enhance documentation thereof
cc-engine.el (c-looking-at-inexpr-block): qualify an invocation of
c-on-identifier with a check we're not at the _end_ of an identifier.
cc-mode.texi: (Tex title page): Remove @subtitlefont because the perl versions
of texi2dvi haven't implemented it.
(Syntactic Symbols): Note that `inlambda' is also used in C++ Mode, not just
in Pike Mode.
(Statement Block Symbols): Add a section illustrating a C++ lambda function.
(FAQ): Add a question about "excessive" indentation of the contents of a C++
lambda function, and how to get rid of it.
Affected #: 2 files
diff -r 3454a992dbd86b4a1fab1cf4867a02c5041e7966 -r
7d5f3dc2941d2151e91f530be5e2efddec0cad33 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -10661,7 +10661,8 @@
(progn
(c-backward-token-2 1 nil lim)
(and
- (not (c-on-identifier))
+ (not (and (c-on-identifier)
+ (looking-at c-symbol-chars)))
(not (looking-at c-opt-op-identifier-prefix)))))))
(cons 'inlambda bracket-pos))
((and c-recognize-paren-inexpr-blocks
diff -r 3454a992dbd86b4a1fab1cf4867a02c5041e7966 -r
7d5f3dc2941d2151e91f530be5e2efddec0cad33 cc-mode.texi
--- a/cc-mode.texi
+++ b/cc-mode.texi
@@ -194,7 +194,7 @@
@iftex
@center @titlefont{CC Mode 5.33}
@sp 2
-@center @subtitlefont{A GNU Emacs mode for editing C and C-like languages}
+@center A GNU Emacs mode for editing C and C-like languages
@sp 2
@center Barry A. Warsaw, Martin Stjernholm, Alan Mackenzie
@end iftex
@@ -4258,8 +4258,8 @@
C++ template argument list continuations. @ref{Class Symbols}.
@item inlambda
Analogous to @code{inclass} syntactic symbol, but used inside lambda
-(i.e. anonymous) functions. Only used in Pike mode. @ref{Statement
-Block Symbols}.
+(i.e. anonymous) functions. Used in C++ and Pike modes.
+@ref{Statement Block Symbols}.
@item lambda-intro-cont
Lines continuing the header of a lambda function, i.e. between the
@code{lambda} keyword and the function body. Only used in Pike mode.
@@ -4996,6 +4996,21 @@
indentation. An @code{inexpr-statement} syntactic element doesn't
contain an anchor position.
+C++11's lambda expressions involve a block inside a statement. For
+example:
+
+@example
+ 1: std::for_each(someList.begin(), someList.end(), [&total](int x) @{
+ 2: total += x;
+ 3: @});
+@end example
+
+Here a lambda expressions begins at the open bracket on line 1 and
+ends at the closing brace on line 3. Line 2, in addition to the
+familiar @code{defun-block-intro} syntactic element, is also prefixed
+by an @code{inlambda} element, which is typically used to indent the
+entire lambda expression to under the opening bracket.
+
In Pike code, there are a few other situations where blocks occur inside
statements, as illustrated here:
@@ -7169,6 +7184,22 @@
this to be the default behavior, don't lobby us, lobby RMS! @t{:-)}
@item
+@emph{How do I stop my C++ lambda expressions being indented way over
+to the right?}
+
+Change the offset associated with @code{inlambda} from its default,
+the function @code{c-lineup-inexpr-block}, to 0. For example, if you
+are setting offsets in a hook function you might include the following
+line:
+
+@example
+(c-set-offset 'inlambda 0)
+@end example
+
+For details of the different ways you can make this setting,
+@ref{Config Basics}.
+
+@item
@emph{How do I stop my code jumping all over the place when I type?}
Deactivate ``electric minor mode'' with @kbd{C-c C-l}. @xref{Getting
Repository URL:
https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.