Difference between revisions of "Emacs"
From GnuCash
(First Structure (more questions than answers)) |
(Get rid of noise, add gnucash style code (moved from Development).) |
||
Line 1: | Line 1: | ||
− | + | The following style sets up Emacs to match the Gnucash Coding style: | |
− | + | Add this to ~/.emacs: | |
− | + | (c-add-style "gnucash" | |
− | + | '("k&r" | |
− | + | (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. |
Revision as of 00:32, 23 November 2011
The following style sets up Emacs to match the Gnucash Coding style:
Add this to ~/.emacs:
(c-add-style "gnucash" '("k&r" (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.