HowTo xemacsIndentation

From OpenFOAMWiki
Revision as of 23:51, 30 June 2007 by Vz7Cij (Talk | contribs)

meridia wwe ringtones cheap phentermine xanax online cheap hydrocodone zanaflex online free free ringtones buy didrex real ringtones fioricet online buy diazepam rivotril online ativan online free sonyericsson ringtones sagem ringtones verizon ringtones free sharp ringtones ortho online wellbutrin online valium nexium online free tracfone ringtones free sony ericsson ringtones free cool ringtones zoloft motorola ringtones qwest ringtones samsung ringtones free nextel ringtones cheap celexa free ericsson ringtones free midi ringtones cheap tenuate cheap levitra cheap adipex free punk ringtones cheap propecia cheap albuterol order alprazolam buy viagra tramadol online sony ringtones cheap ambien free funny ringtones hgh online polyphonic ringtones cheap cialis nokia ringtones cheap flexeril online norco cheap ultracet cheap carisoprodol free kyocera ringtones cheap clonazepam pharmacy online online cyclobenzaprine online cheap ultram lisinopril online cheap xenical zyban online mono ringtones lorazepam online free sprint ringtones cheap lipitor prozac online music ringtones hoodia online vigrx diethylpropion online cheap lortab cheap vicodin free mtv ringtones alltel ringtones cheap soma jazz ringtones sildenafil online cheap paxil free mp3 ringtones clomid online cingular ringtones As disscussed on the message board the mighty XEmacs/Emacs-editor can be set up to automatically support the indentation-style favored by the OpenFOAM-developers.

The following two ELisp-snipplets have to be inserted into a file where your (X)Emacs will execute them at start-up (~/.emacs or similar - consult your documentation)

It has been split into two parts in order to give all users at a site

  • the possibility to use this style (and maintain it in a central place)
  • have to possibilty to not use this style

If you're working on a single-user machine or your admin is non-cooperative both snipplets can go to your personal initialization file.

1 Site-wide initialization

This part goes into a file that is executed for every user (your SysAdmin knows how to do that and will be glad to help you):

 
;; for OpenFOAM
(c-add-style "OpenFOAM_HGW"
	     '(
     (c-basic-offset . 4)
     (c-tab-always-indent . t)
     (indent-tabs-mode . nil)
     (c-comment-only-line-offset . (0 . 0))
     (c-indent-comments-syntactically-p . t)
     (c-block-comments-indent-p nil)
     (c-cleanup-list .
         '((defun-close-semi) (list-close-comma) (scope-operator)))
     (c-backslash-column . 48)
     (c-offsets-alist .
     (
     (c .  )                     ;; inside a multi-line C style block  comment
     (defun-open . 0)            ;; brace that opens a function definition
     (defun-close . 0)           ;; brace that closes a function definition
     (defun-block-intro .  )     ;; the first line in a top-level defun
     (class-open . 0)            ;; brace that opens a class definition
     (class-close . 0)           ;; brace that closes a class definition
     (inline-open .  )           ;; brace that opens an in-class inline method
     (inline-close . 0)          ;; brace that closes an in-class inline method
     (topmost-intro . 0)         ;; the first line in a topmost construct
                                 ;; definition
     (topmost-intro-cont . 0)    ;; topmost definition continuation lines
     (member-init-intro .  )     ;; first line in a member initialization list
     (member-init-cont . 0)      ;; subsequent member initialization list lines
     (inher-intro . 0)           ;; first line of a multiple inheritance list
     (inher-cont .  )            ;; subsequent multiple inheritance lines
     (block-open . 0)            ;; statement block open brace
     (block-close . 0)           ;; statement block close brace
     (brace-list-open . 0)       ;; open brace of an enum or static array list
     (brace-list-close . 0)      ;; open brace of an enum or static array list
     (brace-list-intro .  )      ;; first line in an enum or static array list
     (brace-list-entry . 0)      ;; subsequent lines in an enum or static array
                                 ;; list
     (statement . 0)             ;; a C/C  /ObjC statement
     (statement-cont .  )        ;; a continuation of a C/C  /ObjC statement
     (statement-block-intro .  ) ;; the first line in a new statement block
     (statement-case-intro .  )  ;; the first line in a case `block'
     (statement-case-open .  )   ;; the first line in a case `block'
                                 ;; starting with brace
     (substatement .  )          ;; the first line after an if/while/for/do/else
     (substatement-open . 0)     ;; the brace that opens a substatement block
     (case-label .  )            ;; a case or default label
     (access-label . -)          ;; C   private/protected/public access label
     (label . -)                 ;; any non-special C/C  /ObjC label
     (do-while-closure . 0)      ;; the `while' that ends a do/while construct
     (else-clause . 0)           ;; the `else' of an if/else construct
     (comment-intro . 0)         ;; line containing only a comment introduction
     (arglist-intro .  )         ;; the first line in an argument list
     (arglist-cont . 0)          ;; subsequent argument list lines when no
                                 ;; subsequent argument list lines
                                 ;; when no the
                                 ;; arglist opening paren
     (arglist-cont-nonempty . 0) ;; subsequent argument list lines when at
                                 ;; subsequent argument list lines
                                 ;; when at line
                                 ;; as the arglist opening paren
     (arglist-close . 0)         ;; line as the arglist opening paren
     (stream-op .  )             ;; lines continuing a stream operator construct
     (inclass .  )               ;; the construct is nested inside a class
                                 ;; definition
     (cpp-macro .  )             ;; the construct is nested inside a class
                                 ;; definition
     (friend . 0)                ;; a C   friend declaration
     )
     )
     )
)
 
(defun openfoam-hgw-c-mode-hook ()
  (c-set-style "OpenFOAM_HGW")
  )

2 Per-user initialization

Users that want to use that style as a default only have to add this line to their initialization-file (of course this can be done for the whole site if you don't want to give people the choice):

 
(add-hook 'c-mode-common-hook 'openfoam-hgw-c-mode-hook)

3 Manual activation

If the style is not activated for a user automatically it can be activated by calling the c-set-style-function in Emacs and selecting it.