Refactor coding style definition

Old definition is still there, commented out. This is bad practice for
version control, but makes it easier for later modifications
This commit is contained in:
Gergely Polonkai 2014-10-07 22:17:48 +02:00
parent adf5f39439
commit cc4a3e8a62

189
init.el
View File

@ -92,83 +92,118 @@
(defvaralias 'c-basic-offset 'tab-width) (defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width) (defvaralias 'cperl-indent-level 'tab-width)
(c-add-style "my" ;(c-add-style "my"
'( ; '(
(c-basic-offset . 4) ; (c-basic-offset . 4)
(c-offsets-alist ; (c-offsets-alist
(arglist-cont . 0) ; (arglist-cont . 0)
(arglist-intro . ++) ; (arglist-intro . ++)
(block-close . 0) ; (block-close . 0)
(brace-entry-open . 0) ; (brace-entry-open . 0)
(brace-list-close . 0) ; (brace-list-close . 0)
(brace-list-intro . +) ; (brace-list-intro . +)
(case-label . +) ; (case-label . +)
(class-close . 0) ; (class-close . 0)
(defun-block-intro . +) ; (defun-block-intro . +)
(defun-close . 0) ; (defun-close . 0)
(defun-open . 0) ; (defun-open . 0)
(inclass . +) ; (inclass . +)
(statement . 0) ; (statement . 0)
(statement-block-intro . +) ; (statement-block-intro . +)
(statement-case-intro . +) ; (statement-case-intro . +)
(statement-cont . 4) ; (statement-cont . 4)
(substatement-open . 0) ; (substatement-open . 0)
(topmost-intro . 0) ; (topmost-intro . 0)
(topmost-intro-cont . 0) ; (topmost-intro-cont . 0)
(access-label . -) ; (access-label . -)
(annotation-top-cont . 0) ; (annotation-top-cont . 0)
(annotation-var-cont . +) ; (annotation-var-cont . +)
(arglist-close . c-lineup-close-paren) ; (arglist-close . c-lineup-close-paren)
(arglist-cont-nonempty . c-lineup-arglist) ; (arglist-cont-nonempty . c-lineup-arglist)
(block-open . 0) ; (block-open . 0)
(brace-list-entry . 0) ; (brace-list-entry . 0)
(brace-list-open . 0) ; (brace-list-open . 0)
(c . c-lineup-C-comments) ; (c . c-lineup-C-comments)
(catch-clause . 0) ; (catch-clause . 0)
(class-open . 0) ; (class-open . 0)
(comment-intro . c-lineup-comment) ; (comment-intro . c-lineup-comment)
(composition-close . 0) ; (composition-close . 0)
(composition-open . 0) ; (composition-open . 0)
(cpp-define-intro c-lineup-cpp-define +) ; (cpp-define-intro c-lineup-cpp-define +)
(cpp-macro . -1000) ; (cpp-macro . -1000)
(cpp-macro-cont . +) ; (cpp-macro-cont . +)
(do-while-closure . 0) ; (do-while-closure . 0)
(else-clause . 0) ; (else-clause . 0)
(extern-lang-close . 0) ; (extern-lang-close . 0)
(extern-lang-open . 0) ; (extern-lang-open . 0)
(friend . 0) ; (friend . 0)
(func-decl-cont . +) ; (func-decl-cont . +)
(incomposition . +) ; (incomposition . +)
(inexpr-class . +) ; (inexpr-class . +)
(inexpr-statement . +) ; (inexpr-statement . +)
(inextern-lang . +) ; (inextern-lang . +)
(inher-cont . c-lineup-multi-inher) ; (inher-cont . c-lineup-multi-inher)
(inher-intro . +) ; (inher-intro . +)
(inlambda . c-lineup-inexpr-block) ; (inlambda . c-lineup-inexpr-block)
(inline-close . 0) ; (inline-close . 0)
(inline-open . +) ; (inline-open . +)
(inmodule . +) ; (inmodule . +)
(innamespace . +) ; (innamespace . +)
(knr-argdecl . 0) ; (knr-argdecl . 0)
(knr-argdecl-intro . +) ; (knr-argdecl-intro . +)
(label . 2) ; (label . 2)
(lambda-intro-cont . +) ; (lambda-intro-cont . +)
(member-init-cont . c-lineup-multi-inher) ; (member-init-cont . c-lineup-multi-inher)
(member-init-intro . +) ; (member-init-intro . +)
(module-close . 0) ; (module-close . 0)
(module-open . 0) ; (module-open . 0)
(namespace-close . 0) ; (namespace-close . 0)
(namespace-open . 0) ; (namespace-open . 0)
(objc-method-args-cont . c-lineup-ObjC-method-args) ; (objc-method-args-cont . c-lineup-ObjC-method-args)
(objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +) ; (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +)
(objc-method-intro . ; (objc-method-intro .
[0]) ; [0])
(statement-case-open . 0) ; (statement-case-open . 0)
(stream-op . c-lineup-streamop) ; (stream-op . c-lineup-streamop)
(string . -1000) ; (string . -1000)
(substatement . +) ; (substatement . +)
(substatement-label . 2) ; (substatement-label . 2)
(template-args-cont c-lineup-template-args +)))) ; (template-args-cont c-lineup-template-args +))))
(defun my-c-initialization-hook ()
(define-key c-mode-base-map (kbd "C-m") 'c-context-line-break))
(add-hook 'c-initialization-hook 'my-c-initialization-hook)
(setq c-offset-alist '((member-init-intro . ++)))
(defconst my-c-style
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 4)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . +)
(arglist-intro . ++)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t))
"My C Programming Style")
(c-add-style "PERSONAL" my-c-style)
(defun my-c-mode-common-hook ()
(c-set-style "PERSONAL")
(setq tab-width 4
indent-tabs-mode nil)
(c-toggle-auto-newline 1))
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'after-init-hook 'global-company-mode) (add-hook 'after-init-hook 'global-company-mode)
(setq rcirc-default-nick "GergelyPolonkai") (setq rcirc-default-nick "GergelyPolonkai")
(setq rcirc-default-user-name "polesz") (setq rcirc-default-user-name "polesz")