From 0acbc6c651911dc9ffb4f59b34306bc1ccb751e5 Mon Sep 17 00:00:00 2001 From: Teemu Likonen Date: Thu, 29 Jan 2009 16:28:16 -0800 Subject: Documentation: update CodingStyle tips for Emacs users With the previous Emacs tips example the kernel style was made available for files in the kernel-tree only. This patch updates the tip to add a separate cc-mode indent style ("linux-tabs-only"). This makes it easy to switch between different indent styles and also makes the kernel style easily available for any filetype mode (c++, awk, ...) that is managed by the Emacs cc-mode. Signed-off-by: Teemu Likonen Signed-off-by: Randy Dunlap Signed-off-by: Linus Torvalds --- Documentation/CodingStyle | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Documentation/CodingStyle') diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 1875e502f87..7b5762eded2 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle @@ -483,6 +483,16 @@ values. To do the latter, you can stick the following in your .emacs file: (* (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))) @@ -490,10 +500,7 @@ values. To do the latter, you can stick the following in your .emacs file: (when (and filename (string-match "~/src/linux-trees" filename)) (setq indent-tabs-mode t) - (c-set-style "linux") - (c-set-offset 'arglist-cont-nonempty - '(c-lineup-gcc-asm-reg - c-lineup-arglist-tabs-only)))))) + (c-set-style "linux-tabs-only"))))) This will make emacs go better with the kernel coding style for C files below ~/src/linux-trees. -- cgit v1.2.3 From 70221395ba980392ba98c1d78f6c9f77be03df9e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 29 Jan 2009 16:28:28 -0800 Subject: fix emacs indenting howto filename expansion I don't think emacs understands tilde expansion, so use "expand-file-name" to do that. Signed-off-by: Dan Carpenter Signed-off-by: Randy Dunlap Signed-off-by: Linus Torvalds --- Documentation/CodingStyle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Documentation/CodingStyle') diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 7b5762eded2..72968cd5eaf 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle @@ -498,7 +498,8 @@ values. To do the latter, you can stick the following in your .emacs file: (let ((filename (buffer-file-name))) ;; Enable kernel mode for the appropriate files (when (and filename - (string-match "~/src/linux-trees" filename)) + (string-match (expand-file-name "~/src/linux-trees") + filename)) (setq indent-tabs-mode t) (c-set-style "linux-tabs-only"))))) -- cgit v1.2.3