From GnuCash
Jump to: navigation, search

The following style sets up Emacs to match the Gnucash Coding style:

Add this to ~/.emacs:

 (c-add-style "gnucash"
                 (c-basic-offset . 4)
                 (c-offsets-alist . ((case-label . +)) )
                 (c-hanging-braces-alist . ((substatement-open before after)
                                             (block-close before after)) )

Users with Emacs version 23 and later can add this as well:

 (dir-locals-set-class-variables 'gnucash-project
                               '((indent-tabs-mode . nil)
                                 (fill-column . 80)
                                 (c-mode . ((c-file-style . "gnucash")))
                                 (c++-mode . ((c-file-style . "gnucash")))))
 (dir-locals-set-directory-class "/path/to/gnucash-svn" 'gnucash-project)

Which will automatically apply the style (and ensure that indentation is done with spaces) to all C files in the given path. Users with earlier versions should at least add

 (setq indent-tabs-mode nil)

and should consider adding

 (c-default-style ('((c-mode . "gnucash"))))

Otherwise, you'll have to apply the gnucash style (Ctrl-c . Ret gnucash) to every file when you open it.