From: W. Trevor King Date: Tue, 17 Apr 2012 14:03:46 +0000 (-0400) Subject: Add wtk_linux.el based on suggestions in linux/Documentation/CodingStyle. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f392e8e79cc9b0b19dbd683262032970e7712802;p=dotfiles-public.git Add wtk_linux.el based on suggestions in linux/Documentation/CodingStyle. --- diff --git a/src/.emacs b/src/.emacs index 8f229b3..ad4d793 100644 --- a/src/.emacs +++ b/src/.emacs @@ -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 index 0000000..4648a27 --- /dev/null +++ b/src/.emacs.d/site-lisp/wtk_linux.el @@ -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")))))