-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinit-linux-kernel.el
36 lines (33 loc) · 1.48 KB
/
init-linux-kernel.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
(defun c-lineup-arglist-tabs-only (ignored)
"Line up argument lists by tabs, not spaces"
(let* ((anchor (c-langelem-pos c-syntactic-element))
(column (c-langelem-2nd-pos c-syntactic-element))
(offset (- (1+ column) anchor))
(steps (floor offset c-basic-offset)))
(* (max steps 1)
c-basic-offset)))
(c-add-style "linux-tabs-only"
'("linux" (c-offsets-alist
(arglist-cont-nonempty
c-lineup-gcc-asm-reg
c-lineup-arglist-tabs-only))))
(defun m/kernel-source-hook ()
(let ((filename (buffer-file-name)))
;; Enable kernel mode for the appropriate files
(if (and filename
(or (string-match (expand-file-name "/local/mnt/workspace/mitchelh/.*/kernel")
filename)
(string-match "/local/mnt/workspace/mitchelh/msm-kvm"
filename)
(locate-dominating-file filename "Kbuild")
(locate-dominating-file filename "Kconfig")
(save-excursion (goto-char 0)
(search-forward-regexp "^#include <linux/\\(module\\|kernel\\)\\.h>$" nil t))))
(progn
(setq indent-tabs-mode t)
(setq tab-width 8)
(setq c-basic-offset 8)
(message "Setting up indentation for the linux kernel")
(c-set-style "linux"))
(c-set-style "k&r"))))
(add-hook 'c-mode-hook 'm/kernel-source-hook)