From fab23328512e47a50caced8d074e86e583cc8a9f Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Sun, 3 May 2020 16:32:47 +0100 Subject: cc-mode: add ‘c-lineup-ternary-bodies’ (bug#41061) Introduce ‘c-lineup-ternary-bodies’ function which, when used as a c lineup function, aligns question mark and colon of a ternary operator. For example: return arg % 2 == 0 ? arg / 2 : (3 * arg + 1); * lisp/progmodes/cc-align.el (c-lineup-ternary-bodies): New function. * doc/misc/cc-mode.texi (Operator Line-Up Functions): Document the new function. * test/lisp/progmodes/cc-mode-tests.el (c-lineup-ternary-bodies): New test case. --- doc/misc/cc-mode.texi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'doc') diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index f9c9f5e1830..16eac4828c7 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi @@ -6395,6 +6395,26 @@ function is the same as specifying a list @code{(c-lineup-assignments @comment ------------------------------------------------------------ +@defun c-lineup-ternary-bodies +@findex lineup-ternary-bodies @r{(c-)} +Line up true and false branches of a ternary operator +(i.e. @code{?:}). More precisely, if the line starts with a colon +which is a part of a said operator it with corresponding question +mark. For example: + +@example +@group +return arg % 2 == 0 ? arg / 2 + : (3 * arg + 1); @hereFn{c-lineup-ternary-bodies} +@end group +@end example + +@workswith @code{arglist-cont}, @code{arglist-cont-nonempty} and +@code{statement-cont}. +@end defun + +@comment ------------------------------------------------------------ + @defun c-lineup-cascaded-calls @findex lineup-cascaded-calls @r{(c-)} Line up ``cascaded calls'' under each other. If the line begins with -- cgit v1.2.1