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 <tlikonen@iki.fi> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
5872fb94f8
commit
0acbc6c651
|
@ -483,6 +483,16 @@ values. To do the latter, you can stick the following in your .emacs file:
|
||||||
(* (max steps 1)
|
(* (max steps 1)
|
||||||
c-basic-offset)))
|
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
|
(add-hook 'c-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let ((filename (buffer-file-name)))
|
(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
|
(when (and filename
|
||||||
(string-match "~/src/linux-trees" filename))
|
(string-match "~/src/linux-trees" filename))
|
||||||
(setq indent-tabs-mode t)
|
(setq indent-tabs-mode t)
|
||||||
(c-set-style "linux")
|
(c-set-style "linux-tabs-only")))))
|
||||||
(c-set-offset 'arglist-cont-nonempty
|
|
||||||
'(c-lineup-gcc-asm-reg
|
|
||||||
c-lineup-arglist-tabs-only))))))
|
|
||||||
|
|
||||||
This will make emacs go better with the kernel coding style for C
|
This will make emacs go better with the kernel coding style for C
|
||||||
files below ~/src/linux-trees.
|
files below ~/src/linux-trees.
|
||||||
|
|
Loading…
Reference in New Issue