[Top][All Lists]

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

Re: c-mode indentation of parenthesized expressions

From: Teemu Likonen
Subject: Re: c-mode indentation of parenthesized expressions
Date: Thu, 05 Feb 2009 20:48:53 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

On 2009-02-05 19:14 (+0100), Thomas Christensen wrote:

> a = foo(1, 2, 3,
>         4)
> It aligns with the parenthesis.
> I want to change this to twice the default indent, which I have set to a
> tab in the example below, like this:
> a = (2 + 4 +
>               5)

You can change it temporarily by putting the cursor on the second line
and pressing "C-c C-o". Minibuffer dialog offers arglist-cont-nonempty:
just press Enter and then answer ++ (that is, two plus signs) to the
latter question.

You can also add your own styles. This example adds a style called
"my-style" which is based on "linux" style. We put the style definition
to c-mode-common-hook so that it gets defined when turning on a
programming mode that is managed by Emacs cc-mode package.

    (add-hook 'c-mode-common-hook
              '(lambda ()
                  '("linux" (c-offsets-alist
                             (arglist-cont-nonempty '++))))))

Then change to that style with "C-c ." or c-set-style function.

Another possibility to get the new style added is "(eval-after-load
'cc-mode '(c-add-style ...))".

reply via email to

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