[Insight-developers] Anyone got Emacs config for ITK-standard
indentation?
Mark Foskey
mark_foskey@unc.edu
Wed, 30 Apr 2003 10:38:09 -0400
Here's what I have. I'm just pasting it in -- notice that it sets up
two styles. The t after "my-c-style" means that's my default. If you
want to keep it simple, it should be easy to see how to modify the
my-c-style block with the entries from itk-c-style.
(setq my-c-style
'((c-basic-offset . 4)
(vip-autoindent . t)
(c-electric-pound-behavior . 'alignleft)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(substatement-open . 0)
(inline-open . 0)
(innamespace . 0)
; (brace-list-entry . +)
; (brace-entry-open . 0)
; (brace-list-close . 0)
(knr-argdecl-intro . 0)
(label . 0)
(statement-cont . c-lineup-math)
(innamespace . 0)))))
(setq itk-c-style
'("myk&r"
(c-basic-offset . 2)
(c-offsets-alist . ((statement-block-intro . 0)
(substatement-open . +)))))
(add-hook 'c-mode-common-hook
(function (lambda ()
(c-add-style "myk&r" my-c-style t)
(c-add-style "itk" itk-c-style)
)))
The following code I find handy when editing people's code that uses
different indentation widths than I do. When I hit f9 I get a prompt
to input a new value for the spacing.
(global-set-key [f9] 'my-set-c-space)
(defun my-set-c-space (n)
(interactive "nSpacing: ")
(setq c-basic-offset n))
Kent Williams wrote:
> So my latest checkins were criticized for indentation style; sorry! My
> problem is that I either have to turn off auto-indent in Emacs, or trick it
> into enforcing the ITK coding standards -- in particular, Emacs wants to do
> this:
>
> if ( this )
> {
> Do That;
> }
>
> And ITK wants:
>
> if ( this )
> {
> Do That;
> }
>
> I also gather from Bill's reformatting that there's no indent inside a
> namespace. Emacs doesn't want to do that either.
>
> I know that C++-mode in Emacs is configurable, and I'm willing to slog into it
> and figure it out, but if someone else has already done this, please share!
> Thanks!
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
--
Mark Foskey (919) 843-5436 Computer-Aided Diagnosis and Display Lab
mark_foskey@unc.edu Department of Radiology, CB 7515, UNC
http://www.cs.unc.edu/~foskey Chapel Hill, NC 27599-7515