Add wtk_linux.el based on suggestions in linux/Documentation/CodingStyle.
authorW. Trevor King <wking@drexel.edu>
Tue, 17 Apr 2012 14:03:46 +0000 (10:03 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 17 Apr 2012 14:04:59 +0000 (10:04 -0400)
src/.emacs
src/.emacs.d/site-lisp/wtk_linux.el [new file with mode: 0644]

index 8f229b3abf7220e44cbf1bd0fd1b7c02e66906cb..ad4d793c03c4cdf1009cc0ec3ecafabb9f0c1f31 100644 (file)
@@ -13,6 +13,7 @@
 (load "wtk_centralized_backups.el")
 (load "wtk_utf-8.el")
 (load "wtk_layout.el")
+(load "wtk_linux.el")
 (load "wtk_aspell.el")
 (load "wtk_epa.el")
 (load "wtk_org.el")
diff --git a/src/.emacs.d/site-lisp/wtk_linux.el b/src/.emacs.d/site-lisp/wtk_linux.el
new file mode 100644 (file)
index 0000000..4648a27
--- /dev/null
@@ -0,0 +1,29 @@
+(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)))
+
+(add-hook 'c-mode-common-hook
+          (lambda ()
+            ;; Add kernel style
+            (c-add-style
+             "linux-tabs-only"
+             '("linux" (c-offsets-alist
+                        (arglist-cont-nonempty
+                         c-lineup-gcc-asm-reg
+                         c-lineup-arglist-tabs-only))))))
+
+(add-hook 'c-mode-hook
+          (lambda ()
+            (let ((filename (buffer-file-name)))
+              ;; Enable kernel mode for the appropriate files
+              (when (and filename
+                         (string-match (expand-file-name "~/src/linux/")
+                                       filename))
+                (setq indent-tabs-mode t)
+                (setq default-tab-width 8)
+                (c-set-style "linux-tabs-only")))))