xref: /freebsd/crypto/openssl/doc/openssl-c-indent.el (revision c6879c6c14eedbd060ba588a3129a6c60ebbe783)
180815a77SJung-uk Kim;;; This Emacs Lisp file defines a C indentation style for OpenSSL.
280815a77SJung-uk Kim;;;
380815a77SJung-uk Kim;;; This definition is for the "CC mode" package, which is the default
480815a77SJung-uk Kim;;; mode for editing C source files in Emacs 20, not for the older
5*e71b7053SJung-uk Kim;;; c-mode.el (which was the default in less recent releases of Emacs 19).
680815a77SJung-uk Kim;;;
780815a77SJung-uk Kim;;; Recommended use is to add this line in your .emacs:
880815a77SJung-uk Kim;;;
980815a77SJung-uk Kim;;;   (load (expand-file-name "~/PATH/TO/openssl-c-indent.el"))
1080815a77SJung-uk Kim;;;
1180815a77SJung-uk Kim;;; To activate this indentation style, visit a C file, type
1280815a77SJung-uk Kim;;; M-x c-set-style <RET> (or C-c . for short), and enter "eay".
1380815a77SJung-uk Kim;;; To toggle the auto-newline feature of CC mode, type C-c C-a.
1480815a77SJung-uk Kim;;;
15*e71b7053SJung-uk Kim;;; If you're an OpenSSL developer, you might find it more comfortable
1680815a77SJung-uk Kim;;; to have this style be permanent in your OpenSSL development
1780815a77SJung-uk Kim;;; directory.  To have that, please perform this:
1880815a77SJung-uk Kim;;;
1980815a77SJung-uk Kim;;;    M-x add-dir-local-variable <RET> c-mode <RET> c-file-style <RET>
2080815a77SJung-uk Kim;;;    "OpenSSL-II" <RET>
2180815a77SJung-uk Kim;;;
2280815a77SJung-uk Kim;;; A new buffer with .dir-locals.el will appear.  Save it (C-x C-s).
2380815a77SJung-uk Kim;;;
2480815a77SJung-uk Kim;;; Alternatively, have a look at dir-locals.example.el
2580815a77SJung-uk Kim
2680815a77SJung-uk Kim;;; For suggesting improvements, please send e-mail to levitte@openssl.org.
2780815a77SJung-uk Kim
2880815a77SJung-uk Kim;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2980815a77SJung-uk Kim;; Note, it could be easy to inherit from the "gnu" style...  however,
3080815a77SJung-uk Kim;; one never knows if that style will change somewhere in the future,
31*e71b7053SJung-uk Kim;; so I've chosen to copy the "gnu" style values explicitly instead
3280815a77SJung-uk Kim;; and mark them with a comment.                // RLevitte 2015-08-31
3380815a77SJung-uk Kim;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3480815a77SJung-uk Kim
3580815a77SJung-uk Kim(c-add-style "OpenSSL-II"
3680815a77SJung-uk Kim             '((c-basic-offset . 4)
3780815a77SJung-uk Kim               (indent-tabs-mode . nil)
3880815a77SJung-uk Kim               (fill-column . 78)
3980815a77SJung-uk Kim               (comment-column . 33)
4080815a77SJung-uk Kim               (c-comment-only-line-offset 0 . 0)            ; From "gnu" style
4180815a77SJung-uk Kim               (c-hanging-braces-alist                       ; From "gnu" style
4280815a77SJung-uk Kim                (substatement-open before after)             ; From "gnu" style
4380815a77SJung-uk Kim                (arglist-cont-nonempty))                     ; From "gnu" style
4480815a77SJung-uk Kim               (c-offsets-alist
4580815a77SJung-uk Kim                (statement-block-intro . +)                  ; From "gnu" style
4680815a77SJung-uk Kim                (knr-argdecl-intro . 0)
4780815a77SJung-uk Kim                (knr-argdecl . 0)
4880815a77SJung-uk Kim                (substatement-open . +)                      ; From "gnu" style
4980815a77SJung-uk Kim                (substatement-label . 0)                     ; From "gnu" style
5080815a77SJung-uk Kim                (label . 1)
5180815a77SJung-uk Kim                (statement-case-open . +)                    ; From "gnu" style
5280815a77SJung-uk Kim                (statement-cont . +)                         ; From "gnu" style
5380815a77SJung-uk Kim                (arglist-intro . c-lineup-arglist-intro-after-paren) ; From "gnu" style
5480815a77SJung-uk Kim                (arglist-close . c-lineup-arglist)           ; From "gnu" style
5580815a77SJung-uk Kim                (inline-open . 0)                            ; From "gnu" style
5680815a77SJung-uk Kim                (brace-list-open . +)                        ; From "gnu" style
57*e71b7053SJung-uk Kim                (inextern-lang . 0)     ; Don't indent inside extern block
5880815a77SJung-uk Kim                (topmost-intro-cont first c-lineup-topmost-intro-cont
5980815a77SJung-uk Kim                                    c-lineup-gnu-DEFUN-intro-cont) ; From "gnu" style
6080815a77SJung-uk Kim                )
6180815a77SJung-uk Kim               (c-special-indent-hook . c-gnu-impose-minimum) ; From "gnu" style
6280815a77SJung-uk Kim               (c-block-comment-prefix . "* ")
6380815a77SJung-uk Kim               ))
64