xref: /freebsd/crypto/openssl/doc/openssl-c-indent.el (revision 2008043f386721d58158e37e0d7e50df8095942d)
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 releases 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 an 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;;; Alternatively, have a look at dir-locals.example.el
25
26;;; For suggesting improvements, please send e-mail to levitte@openssl.org.
27
28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29;; Note, it could be easy to inherit from the "gnu" style...  however,
30;; one never knows if that style will change somewhere in the future,
31;; so I've chosen to copy the "gnu" style values explicitly instead
32;; and mark them with a comment.                // RLevitte 2015-08-31
33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34
35(c-add-style "OpenSSL-II"
36             '((c-basic-offset . 4)
37               (indent-tabs-mode . nil)
38               (fill-column . 78)
39               (comment-column . 33)
40               (c-comment-only-line-offset 0 . 0)            ; From "gnu" style
41               (c-hanging-braces-alist                       ; From "gnu" style
42                (substatement-open before after)             ; From "gnu" style
43                (arglist-cont-nonempty))                     ; From "gnu" style
44               (c-offsets-alist
45                (statement-block-intro . +)                  ; From "gnu" style
46                (knr-argdecl-intro . 0)
47                (knr-argdecl . 0)
48                (substatement-open . +)                      ; From "gnu" style
49                (substatement-label . 0)                     ; From "gnu" style
50                (label . 1)
51                (statement-case-open . +)                    ; From "gnu" style
52                (statement-cont . +)                         ; From "gnu" style
53                (arglist-intro . c-lineup-arglist-intro-after-paren) ; From "gnu" style
54                (arglist-close . c-lineup-arglist)           ; From "gnu" style
55                (inline-open . 0)                            ; From "gnu" style
56                (brace-list-open . +)                        ; From "gnu" style
57                (inextern-lang . 0)     ; Don't indent inside extern block
58                (topmost-intro-cont first c-lineup-topmost-intro-cont
59                                    c-lineup-gnu-DEFUN-intro-cont) ; From "gnu" style
60                )
61               (c-special-indent-hook . c-gnu-impose-minimum) ; From "gnu" style
62               (c-block-comment-prefix . "* ")
63               ))
64