Subject: bug#41061: [PATCH] cc-mode: add ‘c-lineup-ternary-bodies’

From: Alan Mackenzie <[email-masked]>
Date: 1 Jun 2020 17:27:11 -0000

Hello, Michal.

In article <[email-masked]> you wrote:
> 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.
> ---

> It’s not perfectly clear to me whether there is a better
> implementation of this.  Some sort of function that cc-mode provides
> which parses an expression into a syntax tree of some kind perhaps.
> The approach I’ve taken does seem to work well enough though.

> If there isn’t any opposition to this, I’m gonna push it in a week or
> so.

Which you did.

This afternoon I tidied up one or two typos, and made a trivial
amendment to the code.

Just one thing: please keep curly quotes right out of the CC Mode
sources.  They make working with the code more difficult (these
characters don't exist on many keyboard layouts) and add nothing of
value.  The same applies to other awkward non-keyboard characters
unless, of course, there's a good reason for using them, such as their
being part of somebody's name.

Thanks!

-- 
Alan Mackenzie (Nuremberg, Germany).