Difference between revisions of "Emacs"

From GnuCash
Jump to: navigation, search
(First Structure (more questions than answers))
 
(Get rid of noise, add gnucash style code (moved from Development).)
Line 1: Line 1:
As most developers seem to have used Emacs as IDE, this page should explain the first steps for newbie devs.
+
The following style sets up Emacs to match the Gnucash Coding style:
  
== Requirements ==
+
Add this to ~/.emacs:
* Install Emacs from your disto.
+
  (c-add-style "gnucash"
* Are there useful extensions, special for Guile/Scheme?
+
                '("k&r"
== Configuration ==
+
                  (c-basic-offset . 4)
* Are there specific settings for gnucash developement?
+
                  (c-offsets-alist . ((case-label . +)) )
== First Steps ==
+
                  (c-hanging-braces-alist . ((substatement-open before after)
== Useful Links ==
+
                                              (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.