all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* c-mode indentation of parenthesized expressions
@ 2009-02-05 18:14 Thomas Christensen
  2009-02-05 18:48 ` Thomas Christensen
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Christensen @ 2009-02-05 18:14 UTC (permalink / raw
  To: help-gnu-emacs

Hi,

Emacs per default indents like this in all c-styles I have tried:

a = (2 + 4 +
     5)

and

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)

and

a = foo(1, 2, 3,
		4)

Can someone tell me how to do this?

I have messed around with `c-style-alist'; but without any luck.

		Thomas





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c-mode indentation of parenthesized expressions
  2009-02-05 18:14 Thomas Christensen
@ 2009-02-05 18:48 ` Thomas Christensen
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Christensen @ 2009-02-05 18:48 UTC (permalink / raw
  To: help-gnu-emacs

Sorry for the noise, I just found out.

		Thomas





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c-mode indentation of parenthesized expressions
       [not found] <mailman.66.1233857713.17492.help-gnu-emacs@gnu.org>
@ 2009-02-05 18:48 ` Teemu Likonen
  2009-02-05 19:19   ` Thomas Christensen
  0 siblings, 1 reply; 4+ messages in thread
From: Teemu Likonen @ 2009-02-05 18:48 UTC (permalink / raw
  To: Thomas Christensen; +Cc: help-gnu-emacs

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 ()
                 (c-add-style
                  "my-style"
                  '("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 ...))".




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c-mode indentation of parenthesized expressions
  2009-02-05 18:48 ` c-mode indentation of parenthesized expressions Teemu Likonen
@ 2009-02-05 19:19   ` Thomas Christensen
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Christensen @ 2009-02-05 19:19 UTC (permalink / raw
  To: help-gnu-emacs

Teemu Likonen <tlikonen@iki.fi> writes:

> 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.

Good tip, thanks.

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

Yup, I found out that `arglist-cont-nonempty' was the key.

Thanks

		Thomas





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-05 19:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.66.1233857713.17492.help-gnu-emacs@gnu.org>
2009-02-05 18:48 ` c-mode indentation of parenthesized expressions Teemu Likonen
2009-02-05 19:19   ` Thomas Christensen
2009-02-05 18:14 Thomas Christensen
2009-02-05 18:48 ` Thomas Christensen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.