Difference between revisions of "Emacs C style for Apertium hacking"
Jump to navigation
Jump to search
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Apertium's coding style does not match any of the Emacs built-in C styles. You can place the following code in your Emacs |
Apertium's coding style does not match any of the Emacs built-in C styles. You can place the following code in your Emacs customisation file (normally found under <code>~/.emacs</code> in Unix systems). |
||
<pre> |
<pre> |
||
Line 17: | Line 17: | ||
"Apertium C++ Programming Style") |
"Apertium C++ Programming Style") |
||
;; |
;; Customisations for all modes in CC Mode. |
||
(defun my-c-mode-common-hook () |
(defun my-c-mode-common-hook () |
||
;; add |
;; add apertium to the list of C/C++ styles: |
||
(c-add-style "apertium" apertium-c-style t |
(c-add-style "apertium" apertium-c-style t) |
||
;; use the apertium style if the path of the opened file contains the substring "/apertium/": |
|||
(if (and (buffer-file-name) |
|||
(string-match "/matxin/\\|/apertium/\\|/lttoolbox/" |
|||
(buffer-file-name))) |
|||
(c-set-style "apertium")) |
|||
;; Some function names are camelCase, so make keys like M-f and M-b treat "camelCase" as two words: |
|||
(subword-mode)) |
|||
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook) |
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook) |
||
</pre> |
</pre> |
||
The above should enable the Apertium style to the correct C++ files. If it's not enabled automatically, just execute |
|||
<pre> |
<pre> |
||
M-x c-set-style |
M-x c-set-style |
||
</pre> |
</pre> |
||
and simply type |
(or use the default keyboard shortcut <code>C-c .</code>) and simply type |
||
<pre> |
<pre> |
||
apertium |
apertium |
||
</pre> |
</pre> |
||
at the prompt. |
at the prompt. |
||
==See also== |
|||
* [[Emacs]] |
|||
[[Category:Development]] |
[[Category:Development]] |
||
[[Category:Documentation in English]] |
Latest revision as of 19:03, 4 April 2016
Apertium's coding style does not match any of the Emacs built-in C styles. You can place the following code in your Emacs customisation 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") ;; Customisations for all modes in CC Mode. (defun my-c-mode-common-hook () ;; add apertium to the list of C/C++ styles: (c-add-style "apertium" apertium-c-style t) ;; use the apertium style if the path of the opened file contains the substring "/apertium/": (if (and (buffer-file-name) (string-match "/matxin/\\|/apertium/\\|/lttoolbox/" (buffer-file-name))) (c-set-style "apertium")) ;; Some function names are camelCase, so make keys like M-f and M-b treat "camelCase" as two words: (subword-mode)) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
The above should enable the Apertium style to the correct C++ files. If it's not enabled automatically, just execute
M-x c-set-style
(or use the default keyboard shortcut C-c .
) and simply type
apertium
at the prompt.