Skip to content

Commit 0acbc6c

Browse files
tlikonentorvalds
authored andcommitted
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>
1 parent 5872fb9 commit 0acbc6c

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎Documentation/CodingStyle‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,17 +483,24 @@ values. To do the latter, you can stick the following in your .emacs file:
483483
(* (max steps 1)
484484
c-basic-offset)))
485485

486+
(add-hook 'c-mode-common-hook
487+
(lambda ()
488+
;; Add kernel style
489+
(c-add-style
490+
"linux-tabs-only"
491+
'("linux" (c-offsets-alist
492+
(arglist-cont-nonempty
493+
c-lineup-gcc-asm-reg
494+
c-lineup-arglist-tabs-only))))))
495+
486496
(add-hook 'c-mode-hook
487497
(lambda ()
488498
(let ((filename (buffer-file-name)))
489499
;; Enable kernel mode for the appropriate files
490500
(when (and filename
491501
(string-match "~/src/linux-trees" filename))
492502
(setq indent-tabs-mode t)
493-
(c-set-style "linux")
494-
(c-set-offset 'arglist-cont-nonempty
495-
'(c-lineup-gcc-asm-reg
496-
c-lineup-arglist-tabs-only))))))
503+
(c-set-style "linux-tabs-only")))))
497504

498505
This will make emacs go better with the kernel coding style for C
499506
files below ~/src/linux-trees.

0 commit comments

Comments
 (0)