[Insight-developers] yet another suggestion

Brad King brad.king at kitware.com
Tue Aug 15 09:03:48 EDT 2000


The original problem had nothing to do with emacs, that was just an extra
bonus of the macro approach.  The problem was that a "}" by itself in the
leftmost column for the end of the namespace is not very clear when it is
2000 lines away from its corresponding "namespace itk {", with many other
"}" characters closing functions in the same column in between.


>
> I don't like this one at all. 'Course, I don't understand what the original problem was.  I just use
> emacs to match braces when I can't figure out what goes with what....
> 

Just add this code to .emacs to do Insight indenting style, including the
old non-indented namespaces:


(require 'cc-mode)

(setq c-basic-offset 2)
(setq c-default-style "user") 

(defun my-c-statement-block-intro (langelem)
  ;; indent code within block by c-basic-offset only if in column 0
  (save-excursion
    (back-to-indentation)
    (if (= 
         (save-excursion
           (re-search-backward "{" 1) (current-column)) 0)
        c-basic-offset
      ;; otherwise don't indent
      0)))
(c-set-offset 'statement-block-intro 'my-c-statement-block-intro)

(defun my-innamespace (langelem)
  ;; don't indent code inside a namespace
  (save-excursion
    (back-to-indentation)
    (if (= 
         (save-excursion
           (re-search-backward "{" 1) (current-column)) 0)
        0
      2)))
(c-set-offset 'innamespace 'my-innamespace)






More information about the Insight-developers mailing list