bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Alan Mackenzie
Subject: bug#41061: [PATCH] cc-mode: add ‘c-lineup-ternary-bodies’
Date: 1 Jun 2020 17:27:11 -0000
User-agent: tin/2.4.4-20191224 ("Millburn") (FreeBSD/11.3-RELEASE-p9 (amd64))

Hello, Michal.

In article <mailman.1983.1588537924.3066.bug-gnu-emacs@gnu.org> 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).






reply via email to

[Prev in Thread] Current Thread [Next in Thread]