* c-mode indentation of parenthesized expressions
@ 2009-02-05 18:14 Thomas Christensen
2009-02-05 18:48 ` Thomas Christensen
0 siblings, 1 reply; 5+ 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] 5+ messages in thread
* Re: c-mode indentation of parenthesized expressions
2009-02-05 18:14 c-mode indentation of parenthesized expressions Thomas Christensen
@ 2009-02-05 18:48 ` Thomas Christensen
2009-02-06 10:24 ` [Emacs] " Juanma Bellón
0 siblings, 1 reply; 5+ 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] 5+ 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; 5+ 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] 5+ messages in thread
* Re: c-mode indentation of parenthesized expressions
2009-02-05 18:48 ` Teemu Likonen
@ 2009-02-05 19:19 ` Thomas Christensen
0 siblings, 0 replies; 5+ 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] 5+ messages in thread
* Re: [Emacs] Re: c-mode indentation of parenthesized expressions
2009-02-05 18:48 ` Thomas Christensen
@ 2009-02-06 10:24 ` Juanma Bellón
0 siblings, 0 replies; 5+ messages in thread
From: Juanma Bellón @ 2009-02-06 10:24 UTC (permalink / raw)
To: help-gnu-emacs
On Thursday, 05 February 2009 19:48:12 Thomas wrote:
> Sorry for the noise, I just found out.
IMO, not the right thing to say. :-) No reason for sorry and no noise.
Instead, please tell us how you solved it. It's not obvious so, although a
good bunch of people in the list will know how to do it, many others don't,
and anyway the mails to this list are archived and are a good reference to
check, and it shows up in Internet searches.
Best regards.
--
Juanma
"Having a smoking section in a restaurant is like
having a peeing section in a swimming pool."
-- Edward Burr
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-06 10:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-05 18:14 c-mode indentation of parenthesized expressions Thomas Christensen
2009-02-05 18:48 ` Thomas Christensen
2009-02-06 10:24 ` [Emacs] " Juanma Bellón
[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
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.