diff options
| author | Michal Nazarewicz | 2020-05-03 16:32:47 +0100 |
|---|---|---|
| committer | Michal Nazarewicz | 2020-05-09 11:30:32 +0100 |
| commit | fab23328512e47a50caced8d074e86e583cc8a9f (patch) | |
| tree | cff2b8a73606da98e98cd74e0ccabc70b281a847 /doc | |
| parent | 0bd6ae773a1ade1bdec2c233df4f260d028fd6c5 (diff) | |
| download | emacs-fab23328512e47a50caced8d074e86e583cc8a9f.tar.gz emacs-fab23328512e47a50caced8d074e86e583cc8a9f.zip | |
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.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/misc/cc-mode.texi | 20 |
1 files changed, 20 insertions, 0 deletions
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 | |||
| 6395 | 6395 | ||
| 6396 | @comment ------------------------------------------------------------ | 6396 | @comment ------------------------------------------------------------ |
| 6397 | 6397 | ||
| 6398 | @defun c-lineup-ternary-bodies | ||
| 6399 | @findex lineup-ternary-bodies @r{(c-)} | ||
| 6400 | Line up true and false branches of a ternary operator | ||
| 6401 | (i.e. @code{?:}). More precisely, if the line starts with a colon | ||
| 6402 | which is a part of a said operator it with corresponding question | ||
| 6403 | mark. For example: | ||
| 6404 | |||
| 6405 | @example | ||
| 6406 | @group | ||
| 6407 | return arg % 2 == 0 ? arg / 2 | ||
| 6408 | : (3 * arg + 1); @hereFn{c-lineup-ternary-bodies} | ||
| 6409 | @end group | ||
| 6410 | @end example | ||
| 6411 | |||
| 6412 | @workswith @code{arglist-cont}, @code{arglist-cont-nonempty} and | ||
| 6413 | @code{statement-cont}. | ||
| 6414 | @end defun | ||
| 6415 | |||
| 6416 | @comment ------------------------------------------------------------ | ||
| 6417 | |||
| 6398 | @defun c-lineup-cascaded-calls | 6418 | @defun c-lineup-cascaded-calls |
| 6399 | @findex lineup-cascaded-calls @r{(c-)} | 6419 | @findex lineup-cascaded-calls @r{(c-)} |
| 6400 | Line up ``cascaded calls'' under each other. If the line begins with | 6420 | Line up ``cascaded calls'' under each other. If the line begins with |