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 /etc | |
| 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 'etc')
| -rw-r--r-- | etc/NEWS | 17 |
1 files changed, 17 insertions, 0 deletions
| @@ -305,6 +305,23 @@ use ‘doxygen’ by default one might evaluate: | |||
| 305 | 305 | ||
| 306 | or use it in a custom ‘c-style’. | 306 | or use it in a custom ‘c-style’. |
| 307 | 307 | ||
| 308 | *** Added support to line up ‘?’ and ‘:’ of a ternary operator. | ||
| 309 | The new ‘c-lineup-ternary-bodies’ function can be used as a lineup | ||
| 310 | function to align question mark and colon which are part of a ternary | ||
| 311 | operator (‘?:’). For example: | ||
| 312 | |||
| 313 | return arg % 2 == 0 ? arg / 2 | ||
| 314 | : (3 * arg + 1); | ||
| 315 | |||
| 316 | To enable, add it to appropriate entries in ‘c-offsets-alist’, e.g.: | ||
| 317 | |||
| 318 | (c-set-offset 'arglist-cont '(c-lineup-ternary-bodies | ||
| 319 | c-lineup-gcc-asm-reg)) | ||
| 320 | (c-set-offset 'arglist-cont-nonempty '(c-lineup-ternary-bodies | ||
| 321 | c-lineup-gcc-asm-reg | ||
| 322 | c-lineup-arglist)) | ||
| 323 | (c-set-offset 'statement-cont '(c-lineup-ternary-bodies +)) | ||
| 324 | |||
| 308 | ** browse-url | 325 | ** browse-url |
| 309 | 326 | ||
| 310 | *** Added support for custom URL handlers | 327 | *** Added support for custom URL handlers |