llvm style for C/C++ by default
This commit is contained in:
parent
696ae785b3
commit
0b830fb6ef
1 changed files with 36 additions and 2 deletions
38
init.el
38
init.el
|
@ -75,10 +75,44 @@
|
|||
(setq-local fill-column 100))
|
||||
|
||||
(require 'cc-mode)
|
||||
|
||||
;;; Copypasta of llvm/utils/emacs/emacs.el
|
||||
;; LLVM coding style guidelines in emacs
|
||||
;; Maintainer: LLVM Team, http://llvm.org/
|
||||
(defun llvm-lineup-statement (langelem)
|
||||
(let ((in-assign (c-lineup-assignments langelem)))
|
||||
(if (not in-assign)
|
||||
'++
|
||||
(aset in-assign 0
|
||||
(+ (aref in-assign 0)
|
||||
(* 2 c-basic-offset)))
|
||||
in-assign)))
|
||||
|
||||
;; Add a cc-mode style for editing LLVM C and C++ code
|
||||
(c-add-style "llvm.org"
|
||||
'("gnu"
|
||||
(fill-column . 80)
|
||||
(c++-indent-level . 2)
|
||||
(c-basic-offset . 2)
|
||||
(indent-tabs-mode . nil)
|
||||
(c-offsets-alist . ((arglist-intro . ++)
|
||||
(innamespace . 0)
|
||||
(member-init-intro . ++)
|
||||
(statement-cont . llvm-lineup-statement)))))
|
||||
|
||||
;; Files with "llvm" in their names will automatically be set to the
|
||||
;; llvm.org coding style.
|
||||
(add-hook 'c-mode-common-hook
|
||||
(function
|
||||
(lambda nil
|
||||
(if (string-match "llvm" buffer-file-name)
|
||||
(progn
|
||||
(c-set-style "llvm.org"))))))
|
||||
|
||||
(setq c-default-style '((java-mode . "java")
|
||||
(awk-mode . "awk")
|
||||
(c-mode . "linux")
|
||||
(c++-mode . "stroustrup")
|
||||
(c-mode . "llvm.org")
|
||||
(c++-mode . "llvm.org")
|
||||
(other . "stroustrup")))
|
||||
|
||||
;; completion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue