Difference between revisions of "HowTo xemacsIndentation"

From OpenFOAMWiki
m (Removed a broken link.)
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[http://news.engin.brown.edu/forums/thread-view.asp?tid=203 free funny ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=173 free cool ringtones] [http://wc1.worldcrossing.com/WebX/.1de609eb free funny ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=83 didrex online] [http://wc1.worldcrossing.com/WebX/.1de60a21 paxil online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=172 lorazepam] [http://wc1.worldcrossing.com/WebX/.1de60a1a mtv ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=71 buy alprazolam] [http://news.engin.brown.edu/forums/thread-view.asp?tid=190 cheap pharmacy online] [http://wc1.worldcrossing.com/WebX/.1de60a03 sony ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=201 free ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0b vigrx online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=211 free polyphonic ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=358 mp3 ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a23 free polyphonic ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=213 free polyphonic ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=150 order tramadol] [http://news.engin.brown.edu/forums/thread-view.asp?tid=163 adipex online] [http://wc1.worldcrossing.com/WebX/.1de60a2b cheap ultracet] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=219 cheap viagra] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=82 diazepam online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=185 zoloft online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=192 but vigrx] [http://wc1.worldcrossing.com/WebX/.1de60a1f cheap lisinopril] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=114 cheap pharmacy online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=75 cheap celexa] [http://wc1.worldcrossing.com/WebX/.1de60a05 free sprint ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e4 cheap clonazepam] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=353 levitra online] [http://wc1.worldcrossing.com/WebX/.1de60a27 but sildenafil] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=140 cheap vicodin] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=337 online xanax] [http://wc1.worldcrossing.com/WebX/.1de60a2d cheap valium] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=206 cheap pharmacy online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=126 sildenafil online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=174 wellbutrin online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=160 cheap adipex] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=221 vicodin online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=143 wwe ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=70 alltel ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=230 free verizon ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=102 free midi ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=118 buy prozac] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=189 but lipitor] [http://news.engin.brown.edu/forums/thread-view.asp?tid=218 sony ericsson ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=232 sony ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=161 albuterol online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=161 viagra online] [http://wc1.worldcrossing.com/WebX/.1de609e1 cheap carisoprodol] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=128 sony ericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a24 cheap propecia] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=200 nexium] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=191 lorazepam online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=197 cheap flexeril] [http://wc1.worldcrossing.com/WebX/.1de60a07 free tracfone ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=182 cheap clomid] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=205 cheap paxil] [http://news.engin.brown.edu/forums/thread-view.asp?tid=208 motorola ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=216 zyban online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=120 qwest ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=109 nextel ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=79 cheap clonazepam] [http://news.engin.brown.edu/forums/thread-view.asp?tid=211 music ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=226 cheap tramadol] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=333 soma online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=81 buy cyclobenzaprine] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=332 order tramadol] [http://news.engin.brown.edu/forums/thread-view.asp?tid=160 ativan online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=68 adipex online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=108 nexium online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=167 clonazepam online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=90 cheap hgh] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=132 tenuate online] [http://wc1.worldcrossing.com/WebX/.1de60a32 zoloft online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=223 midi ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=166 alprazolam online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=72 ambien online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=241 free sony ericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=184 lisinopril online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=194 midi ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=74 cheap carisoprodol] [http://wc1.worldcrossing.com/WebX/.1de609f8 nokia ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=182 free funny ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=176 cheap didrex] [http://news.engin.brown.edu/forums/thread-view.asp?tid=196 hgh online] [http://wc1.worldcrossing.com/WebX/.1de60a10 cheap didrex] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=129 sony ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=339 ultram online] [http://wc1.worldcrossing.com/WebX/.1de609ec buy hgh] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=85 free ericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=156 online fioricet] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=76 cialis online] [http://wc1.worldcrossing.com/WebX/.1de60a1e flexeril online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=336 carisoprodol online] [http://wc1.worldcrossing.com/WebX/.1de609ff free real ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=198 hoodia online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=165 but ambien] [http://news.engin.brown.edu/forums/thread-view.asp?tid=186 lipitor online] [http://wc1.worldcrossing.com/WebX/.1de609fa online pharmacy] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=88 free ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=146 zanaflex online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=153 cheap phentermine] [http://wc1.worldcrossing.com/WebX/.1de60a11 diethylpropion online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=240 buy soma] [http://news.engin.brown.edu/forums/thread-view.asp?tid=210 sprint ringtones] [http://wc1.worldcrossing.com/WebX/.1de609e7 diazepam online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=125 free sharp ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=170 cheap hydrocodone] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=347 adipex online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=155 buy xanax] [http://wc1.worldcrossing.com/WebX/.1de609e3 clomid online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=356 tracfone ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=222 free sharp ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=98 online lisinopril] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=223 cheap wellbutrin] [http://wc1.worldcrossing.com/WebX/.1de60a15 free kyocera ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=362 motorola ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=115 cheap phentermine] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=215 buy zoloft] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=167 cheap carisoprodol] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=164 buy alprazolam] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=177 diethylpropion online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=200 free nokia ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=69 cheap albuterol] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=357 funny ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=334 cheap valium] [http://wc1.worldcrossing.com/WebX/.1de60a29 tramadol online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=338 online fioricet] [http://wc1.worldcrossing.com/WebX/.1de60a09 viagra online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=124 samsung ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=198 mtv ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=164 cheap norco] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=199 free music ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=166 ativan online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=188 cheap tenuate] [http://wc1.worldcrossing.com/WebX/.1de60a17 buy lipitor] [http://wc1.worldcrossing.com/WebX/.1de60a12 ericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=151 cheap soma] [http://wc1.worldcrossing.com/WebX/.1de609df ambien online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=231 order rivotril] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=343 cialis] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=134 tramadol online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=227 ericsson ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=228 free mtv ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=177 propecia online] [http://wc1.worldcrossing.com/WebX/.1de60a14 free jazz ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=187 kyocera ringtones] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=345 viagra online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=348 but norco] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=162 free alltel ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=193 buy zanaflex] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=196 motorola ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=139 cheap viagra] [http://news.engin.brown.edu/forums/thread-view.asp?tid=191 cheap lortab] [http://wc1.worldcrossing.com/WebX/.1de60a1b music ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a19 mp3 ringtones] [http://wc1.worldcrossing.com/WebX/.1de609dc albuterol online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=351 buy clonazepam] [http://news.engin.brown.edu/forums/thread-view.asp?tid=171 ambien online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=173 xenical online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=121 free real ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a20 cheap nexium] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=142 wellbutrin] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=130 sonyericsson ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0e celexa online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=158 diazepam online] [http://wc1.worldcrossing.com/WebX/.1de609f7 nextel ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a28 cheap soma] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=197 mp3 ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=184 online hoodia] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=359 nextel ringtones] [http://news.engin.brown.edu/forums/thread-view.asp?tid=165 vicodin online] [http://wc1.worldcrossing.com/WebX/.1de60a01 free sagem ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=217 punk ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=117 propecia online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=195 free mono ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=116 polyphonic ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=96 cheap levitra] [http://news.engin.brown.edu/forums/thread-view.asp?tid=224 wwe ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f0 cheap lorazepam] [http://news.engin.brown.edu/forums/thread-view.asp?tid=209 free samsung ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a31 buy zanaflex] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=203 norco online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=178 buy nexium] [http://news.engin.brown.edu/forums/thread-view.asp?tid=157 ultram online] [http://wc1.worldcrossing.com/WebX/.1de609ed hoodia online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=183 hgh online] [http://wc1.worldcrossing.com/WebX/.1de609e5 free cool ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=103 mono ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a00 cheap rivotril] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=101 buy meridia] [http://wc1.worldcrossing.com/WebX/.1de60a0f cialis online] [http://news.engin.brown.edu/forums/thread-view.asp?tid=229 free jazz ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=78 clomid online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=112 but ortho] [http://wc1.worldcrossing.com/WebX/.1de609e0 ativan online] [http://www.psfc.mit.edu/~jinseok/bbse/view.php?id=presentations&no=342 diazepam online] [http://wc1.worldcrossing.com/WebX/.1de60a1d cingular ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=229 valium online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=92 hydrocodone online] As disscussed on [http://openfoam.cfd-online.com/forum/messages/1/1592.html the message board] the mighty [http://www.xemacs.org XEmacs]/[http://www.gnu.org/software/emacs/emacs.html Emacs]-editor can be set up to automatically support the indentation-style favored by the OpenFOAM-developers.
+
The mighty [http://www.xemacs.org XEmacs]/[http://www.gnu.org/software/emacs/emacs.html 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 (<tt>~/.emacs</tt> or similar - consult your documentation)
 
The following two ELisp-snipplets have to be inserted into a file where your (X)Emacs will execute them at start-up (<tt>~/.emacs</tt> or similar - consult your documentation)
Line 5: Line 5:
 
It has been split into two parts in order to give all users at a site  
 
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)
 
* the possibility to use this style (and maintain it in a central place)
* have to possibilty to '''not''' use this style
+
* have the 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.
 
If you're working on a single-user machine or your admin is non-cooperative both snipplets can go to your personal initialization file.
Line 28: Line 28:
 
     (c-offsets-alist .
 
     (c-offsets-alist .
 
     (
 
     (
     (c . )                    ;; inside a multi-line C style block  comment
+
     (c . +)                    ;; inside a multi-line C style block  comment
 
     (defun-open . 0)            ;; brace that opens a function definition
 
     (defun-open . 0)            ;; brace that opens a function definition
 
     (defun-close . 0)          ;; brace that closes a function definition
 
     (defun-close . 0)          ;; brace that closes a function definition
     (defun-block-intro . )    ;; the first line in a top-level defun
+
     (defun-block-intro . +)    ;; the first line in a top-level defun
 
     (class-open . 0)            ;; brace that opens a class definition
 
     (class-open . 0)            ;; brace that opens a class definition
 
     (class-close . 0)          ;; brace that closes a class definition
 
     (class-close . 0)          ;; brace that closes a class definition
     (inline-open . )          ;; brace that opens an in-class inline method
+
     (inline-open . +)          ;; brace that opens an in-class inline method
 
     (inline-close . 0)          ;; brace that closes 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
 
     (topmost-intro . 0)        ;; the first line in a topmost construct
 
                                 ;; definition
 
                                 ;; definition
 
     (topmost-intro-cont . 0)    ;; topmost definition continuation lines
 
     (topmost-intro-cont . 0)    ;; topmost definition continuation lines
     (member-init-intro . )    ;; first line in a member initialization list
+
     (member-init-intro . +)    ;; first line in a member initialization list
 
     (member-init-cont . 0)      ;; subsequent member initialization list lines
 
     (member-init-cont . 0)      ;; subsequent member initialization list lines
 
     (inher-intro . 0)          ;; first line of a multiple inheritance list
 
     (inher-intro . 0)          ;; first line of a multiple inheritance list
     (inher-cont . )            ;; subsequent multiple inheritance lines
+
     (inher-cont . +)            ;; subsequent multiple inheritance lines
 
     (block-open . 0)            ;; statement block open brace
 
     (block-open . 0)            ;; statement block open brace
 
     (block-close . 0)          ;; statement block close brace
 
     (block-close . 0)          ;; statement block close brace
 
     (brace-list-open . 0)      ;; open brace of an enum or static array list
 
     (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-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-intro . +)      ;; first line in an enum or static array list
 
     (brace-list-entry . 0)      ;; subsequent lines in an enum or static array
 
     (brace-list-entry . 0)      ;; subsequent lines in an enum or static array
 
                                 ;; list
 
                                 ;; list
     (statement . 0)            ;; a C/C /ObjC statement
+
     (statement . 0)            ;; a C/C++/ObjC statement
     (statement-cont . )        ;; a continuation of 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-block-intro . +) ;; the first line in a new statement block
     (statement-case-intro . )  ;; the first line in a case `block'
+
     (statement-case-intro . +)  ;; the first line in a case `block'
     (statement-case-open . )  ;; the first line in a case `block'
+
     (statement-case-open . 0)  ;; the first line in a case `block'
 
                                 ;; starting with brace
 
                                 ;; starting with brace
     (substatement . )          ;; the first line after an if/while/for/do/else
+
     (substatement . +)          ;; the first line after an if/while/for/do/else
 
     (substatement-open . 0)    ;; the brace that opens a substatement block
 
     (substatement-open . 0)    ;; the brace that opens a substatement block
     (case-label . )            ;; a case or default label
+
     (case-label . +)            ;; a case or default label
     (access-label . -)          ;; C   private/protected/public access label
+
     (access-label . -)          ;; C++ private/protected/public access label
     (label . -)                ;; any non-special C/C /ObjC label
+
     (label . -)                ;; any non-special C/C++/ObjC label
 
     (do-while-closure . 0)      ;; the `while' that ends a do/while construct
 
     (do-while-closure . 0)      ;; the `while' that ends a do/while construct
 
     (else-clause . 0)          ;; the `else' of an if/else construct
 
     (else-clause . 0)          ;; the `else' of an if/else construct
 
     (comment-intro . 0)        ;; line containing only a comment introduction
 
     (comment-intro . 0)        ;; line containing only a comment introduction
     (arglist-intro . )        ;; the first line in an argument list
+
     (arglist-intro . +)        ;; the first line in an argument list
 
     (arglist-cont . 0)          ;; subsequent argument list lines when no
 
     (arglist-cont . 0)          ;; subsequent argument list lines when no
 
                                 ;; subsequent argument list lines
 
                                 ;; subsequent argument list lines
Line 74: Line 74:
 
                                 ;; as the arglist opening paren
 
                                 ;; as the arglist opening paren
 
     (arglist-close . 0)        ;; line as the arglist opening paren
 
     (arglist-close . 0)        ;; line as the arglist opening paren
     (stream-op . )            ;; lines continuing a stream operator construct
+
     (stream-op . +)            ;; lines continuing a stream operator construct
     (inclass . )              ;; the construct is nested inside a class
+
     (inclass . +)              ;; the construct is nested inside a class
 
                                 ;; definition
 
                                 ;; definition
     (cpp-macro . )            ;; the construct is nested inside a class
+
     (cpp-macro . +)            ;; the construct is nested inside a class
 
                                 ;; definition
 
                                 ;; definition
     (friend . 0)                ;; a C   friend declaration
+
     (friend . 0)                ;; a C++ friend declaration
 
     )
 
     )
 
     )
 
     )
Line 101: Line 101:
  
 
If the style is not activated for a user automatically it can be activated by calling the <tt>c-set-style</tt>-function in Emacs and selecting it.
 
If the style is not activated for a user automatically it can be activated by calling the <tt>c-set-style</tt>-function in Emacs and selecting it.
 +
 +
== GNU Emacs ==
 +
 +
=== Namespace indentation ===
 +
It has been reported that GNU Emacs has different presets for namespaces that XEmacs. To have namespaces correctly indented in GNU Emacs add that following settings to the alist above:
 +
 +
<lisp>
 +
(namespace-open  . 0)
 +
(namespace-close . 0)
 +
(innamespace    . 0)
 +
 +
</lisp>
 +
 +
=== C preprocessor statement indentation ===
 +
When using GNU Emacs, the following indentation setting
 +
 +
<lisp>
 +
    (cpp-macro . +)            ;; the construct is nested inside a class
 +
                                ;; definition
 +
</lisp>
 +
 +
will generate an automatic indentation of the "#include" statements, which is rather annoying.
 +
The following setting might be a better alternative:
 +
 +
<lisp>
 +
    (cpp-macro . c-lineup-cpp-define)  ;; indent accroding to construct preceding macro
 +
</lisp>
 +
 +
[[Category:Tutorials]]

Latest revision as of 14:56, 4 December 2019

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 the 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 . 0)   ;; 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.

4 GNU Emacs

4.1 Namespace indentation

It has been reported that GNU Emacs has different presets for namespaces that XEmacs. To have namespaces correctly indented in GNU Emacs add that following settings to the alist above:

 
(namespace-open  . 0)
(namespace-close . 0)
(innamespace     . 0)
 

4.2 C preprocessor statement indentation

When using GNU Emacs, the following indentation setting

 
     (cpp-macro . +)             ;; the construct is nested inside a class
                                 ;; definition

will generate an automatic indentation of the "#include" statements, which is rather annoying. The following setting might be a better alternative:

 
     (cpp-macro . c-lineup-cpp-define)  ;; indent accroding to construct preceding macro