all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* cc-mode indentation puzzle
@ 2011-01-31 21:33 blue
  2011-02-01 14:13 ` Andy Moreton
       [not found] ` <mailman.1.1296570019.10637.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: blue @ 2011-01-31 21:33 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I have been using cc-mode for years to help me adhere
to our corporate C coding style guidelines.  However,
there is one corner case that I still haven't got working.

Our standard dictates that if a statement is continued to
another line, the continuation lines (or lines) must each be
indented four spaces from the column where the original
statement started.  I have c-basic-offset = 8, and
statement-cont = '*' (which computes to 4).  Most of the time
this works fine.  But, if the continuation includes a
function call, I get an additional indentation of four
spaces for the next line.  The relevant offsets are
arglist-intro, arglist-cont, and arglist-cont-nonempty,
which are all '*' as well.  (Setting these all to 0 doesn't
produce the correct result either).

Example:

Indentation I want:

a = b + c +
    d + e + f(1,
    2, 3);

Indentation I get:

a = b + c +
    d + e + f(1,
        2, 3);

Here is the c-offsets-alist I use:

(c-add-style "personal"
       '((c-basic-offset . 8)
	 (c-tab-always-indent . nil)
	 (c-comment-only-line-offset . (0 . 0))
	 (c-offsets-alist . ((statement-block-intro . +)
			     (inextern-lang . 0)
			     (knr-argdecl-intro . +)
			     (substatement-open . +)
			     (label . 0)
			     (statement-case-open . +)
			     (statement-cont . *)
			     (statement . 0)
			     (arglist-intro . *)
			     (arglist-cont . *)
			     (arglist-cont-nonempty . *)
			     (arglist-close . *)))))

I'm trying to find a "legitimate" way to do this, i.e.,
not hacking to cc-*.el files.


Any help is much appreciated -- thanks,

John





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

end of thread, other threads:[~2011-02-01 16:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-31 21:33 cc-mode indentation puzzle blue
2011-02-01 14:13 ` Andy Moreton
     [not found] ` <mailman.1.1296570019.10637.help-gnu-emacs@gnu.org>
2011-02-01 14:54   ` Pascal J. Bourguignon
2011-02-01 16:46     ` Stefan Monnier

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.