Emacs C style for Apertium hacking

From Apertium
Revision as of 11:54, 9 February 2008 by Wynand.winterbach (talk | contribs) (New page: Apertium's coding style does not match any of the Emacs built-in C styles. You can place the following code in your Emacs customization file (normally found under <code>~/.emacs</code> in ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Apertium's coding style does not match any of the Emacs built-in C styles. You can place the following code in your Emacs customization file (normally found under ~/.emacs in Unix systems).

(defconst apertium-c-style
  '((c-basic-offset . 2)
    (c-comment-only-line-offset . 0)
    (c-hanging-braces-alist
     (substatement-open before after))
    (c-offsets-alist
     (topmost-intro . 0)
     (substatement . +)
     (substatement-open . 0)
     (case-label . +)
     (access-label . -)
     (inclass . ++)
     (inline-open . 0)))
  "Apertium C++ Programming Style")

;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
  ;; add my personal style and set it for the current buffer
  (c-add-style "apertium" apertium-c-style t))

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

To enable the Apertium style, execute

M-x c-set-style

and simply type

apertium

at the prompt.