public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Documentation: update CodingStyle tips for Emacs users
@ 2009-01-18 17:18 Teemu Likonen
  2009-01-26 15:20 ` Teemu Likonen
  0 siblings, 1 reply; 8+ messages in thread
From: Teemu Likonen @ 2009-01-18 17:18 UTC (permalink / raw)
  To: linux-doc; +Cc: linux-kernel, hannes

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
separate cc-mode indent style; it makes the kernel style easily
available for any filetype mode that is managed by the Emacs cc-mode.

We also fix the filename regexp in the example: Elisp function
buffer-file-name returns full pathname, not a path relative to user's
home directory. Hence a tilde (~) can't be used to refer to home
directory (as the previous code did).

Signed-off-by: Teemu Likonen <tlikonen@iki.fi>
---
 Documentation/CodingStyle |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index 1875e50..2cda242 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -483,20 +483,27 @@ 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)))
               ;; Enable kernel mode for the appropriate files
               (when (and filename
-                         (string-match "~/src/linux-trees" 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.
+files which pathname matches src/linux-trees.
 
 But even if you fail in getting emacs to do sane formatting, not
 everything is lost: use "indent".
-- 
1.6.1.156.gb648d


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-01-26 17:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-18 17:18 [PATCH] Documentation: update CodingStyle tips for Emacs users Teemu Likonen
2009-01-26 15:20 ` Teemu Likonen
2009-01-26 16:38   ` Randy Dunlap
2009-01-26 16:56     ` Teemu Likonen
2009-01-26 17:01       ` [PATCH v2] " Teemu Likonen
2009-01-26 17:13         ` Randy Dunlap
2009-01-26 17:21           ` Teemu Likonen
2009-01-26 17:23             ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox