-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc-mode-setup.el
42 lines (40 loc) · 1.3 KB
/
c-mode-setup.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(defconst linux-c-style
'((c-basic-offset . 8)
(indent-tabs-mode . t)
(c-offsets-alist
(arglist-cont-nonempty
c-lineup-gcc-asm-reg
c-lineup-arglist-tabs-only)))
"Linux C Style for CC-MODE")
(add-hook 'c-mode-common-hook
(lambda ()
;; Add kernel style
(c-add-style "linux-tabs-only" linux-c-style)
;; Enable whitespace butler
(require 'ws-butler)
(ws-butler-mode)
(cond ((equal company "senient")
(message "Senient c-mode")
(c-add-style "Senient" senient-c-style))
((equal company "arista")
(setq fill-column 85)
(arastra-c-mode-common-hook)))))
(add-hook 'c-mode-hook
(lambda ()
(let ((filename (buffer-file-name)))
;; Enable kernel mode for the appropriate files
(if (and filename
(or
(string-match "/kernel" filename)
(locate-dominating-file filename "Kbuild")))
(progn
(message "Kernel mode: %s" filename)
(c-set-style "linux-tabs-only"))
(cond ((equal company "senient")
(message "Senient mode: %s" filename)
(c-set-style "Senient")
(setq indent-tabs-mode nil))
((equal company "arista")
(message "Arista mode: %s" filename)
(c-set-style "Arastra")))
))))