Add emacs CC mode style for OpenSSL
[openssl.git] / doc / openssl-c-indent.el
1 ;;; This Emacs Lisp file defines a C indentation style for OpenSSL.
2 ;;;
3 ;;; This definition is for the "CC mode" package, which is the default
4 ;;; mode for editing C source files in Emacs 20, not for the older
5 ;;; c-mode.el (which was the default in less recent releaes of Emacs 19).
6 ;;;
7 ;;; Recommended use is to add this line in your .emacs:
8 ;;;
9 ;;;   (load (expand-file-name "~/PATH/TO/openssl-c-indent.el"))
10 ;;;
11 ;;; To activate this indentation style, visit a C file, type
12 ;;; M-x c-set-style <RET> (or C-c . for short), and enter "eay".
13 ;;; To toggle the auto-newline feature of CC mode, type C-c C-a.
14 ;;;
15 ;;; If you're a OpenSSL developer, you might find it more comfortable
16 ;;; to have this style be permanent in your OpenSSL development
17 ;;; directory.  To have that, please perform this:
18 ;;;
19 ;;;    M-x add-dir-local-variable <RET> c-mode <RET> c-file-style <RET>
20 ;;;    "OpenSSL-II" <RET>
21 ;;;
22 ;;; A new buffer with .dir-locals.el will appear.  Save it (C-x C-s).
23 ;;;
24 ;;; For suggesting improvements, please send e-mail to levitte@openssl.org.
25
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;; Note, it could be easy to inherit from the "gnu" style...  however,
28 ;; one never knows if that style will change somewhere in the future,
29 ;; so I've chosen to copy the "gnu" style values explicitely instead
30 ;; and mark them with a comment.                // RLevitte 2015-08-31
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32
33 (c-add-style "OpenSSL-II"
34              '((c-basic-offset . 4)
35                (indent-tabs-mode . nil)
36                (fill-column . 78)
37                (comment-column . 33)
38                (c-comment-only-line-offset 0 . 0)            ; From "gnu" style
39                (c-hanging-braces-alist                       ; From "gnu" style
40                 (substatement-open before after)             ; From "gnu" style
41                 (arglist-cont-nonempty))                     ; From "gnu" style
42                (c-offsets-alist
43                 (statement-block-intro . +)                  ; From "gnu" style
44                 (knr-argdecl-intro . 0)
45                 (knr-argdecl . 0)
46                 (substatement-open . +)                      ; From "gnu" style
47                 (substatement-label . 0)                     ; From "gnu" style
48                 (label . 1)
49                 (statement-case-open . +)                    ; From "gnu" style
50                 (statement-cont . +)                         ; From "gnu" style
51                 (arglist-intro . c-lineup-arglist-intro-after-paren) ; From "gnu" style
52                 (arglist-close . c-lineup-arglist)           ; From "gnu" style
53                 (inline-open . 0)                            ; From "gnu" style
54                 (brace-list-open . +)                        ; From "gnu" style
55                 (topmost-intro-cont first c-lineup-topmost-intro-cont
56                                     c-lineup-gnu-DEFUN-intro-cont) ; From "gnu" style
57                 )
58                (c-special-indent-hook . c-gnu-impose-minimum) ; From "gnu" style
59                (c-block-comment-prefix . "* ")
60                ))