diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-09-22 07:08:57 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-09-22 07:08:57 -0400 |
| commit | 0b88641f1bafdbd087d5e63987a30cc0eadd63b9 (patch) | |
| tree | 81dcf756db373444140bb2623584710c628e3048 /Documentation/CodingStyle | |
| parent | fbdbf709938d155c719c76b9894d28342632c797 (diff) | |
| parent | 72d31053f62c4bc464c2783974926969614a8649 (diff) | |
Merge commit 'v2.6.27-rc7' into x86/debug
Diffstat (limited to 'Documentation/CodingStyle')
| -rw-r--r-- | Documentation/CodingStyle | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 6caa14615578..1875e502f872 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle | |||
| @@ -474,25 +474,29 @@ make a good program). | |||
| 474 | So, you can either get rid of GNU emacs, or change it to use saner | 474 | So, you can either get rid of GNU emacs, or change it to use saner |
| 475 | values. To do the latter, you can stick the following in your .emacs file: | 475 | values. To do the latter, you can stick the following in your .emacs file: |
| 476 | 476 | ||
| 477 | (defun linux-c-mode () | 477 | (defun c-lineup-arglist-tabs-only (ignored) |
| 478 | "C mode with adjusted defaults for use with the Linux kernel." | 478 | "Line up argument lists by tabs, not spaces" |
| 479 | (interactive) | 479 | (let* ((anchor (c-langelem-pos c-syntactic-element)) |
| 480 | (c-mode) | 480 | (column (c-langelem-2nd-pos c-syntactic-element)) |
| 481 | (c-set-style "K&R") | 481 | (offset (- (1+ column) anchor)) |
| 482 | (setq tab-width 8) | 482 | (steps (floor offset c-basic-offset))) |
| 483 | (setq indent-tabs-mode t) | 483 | (* (max steps 1) |
| 484 | (setq c-basic-offset 8)) | 484 | c-basic-offset))) |
| 485 | 485 | ||
| 486 | This will define the M-x linux-c-mode command. When hacking on a | 486 | (add-hook 'c-mode-hook |
| 487 | module, if you put the string -*- linux-c -*- somewhere on the first | 487 | (lambda () |
| 488 | two lines, this mode will be automatically invoked. Also, you may want | 488 | (let ((filename (buffer-file-name))) |
| 489 | to add | 489 | ;; Enable kernel mode for the appropriate files |
| 490 | 490 | (when (and filename | |
| 491 | (setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode) | 491 | (string-match "~/src/linux-trees" filename)) |
| 492 | auto-mode-alist)) | 492 | (setq indent-tabs-mode t) |
| 493 | 493 | (c-set-style "linux") | |
| 494 | to your .emacs file if you want to have linux-c-mode switched on | 494 | (c-set-offset 'arglist-cont-nonempty |
| 495 | automagically when you edit source files under /usr/src/linux. | 495 | '(c-lineup-gcc-asm-reg |
| 496 | c-lineup-arglist-tabs-only)))))) | ||
| 497 | |||
| 498 | This will make emacs go better with the kernel coding style for C | ||
| 499 | files below ~/src/linux-trees. | ||
| 496 | 500 | ||
| 497 | But even if you fail in getting emacs to do sane formatting, not | 501 | But even if you fail in getting emacs to do sane formatting, not |
| 498 | everything is lost: use "indent". | 502 | everything is lost: use "indent". |
