Re: On Tabs and Spaces
- From
- Adam Piatyszek <ediap@users.sourceforge.net>
- Date
- Oct 16, 2007, 10:16 UTC
- Message-ID
- <47148F72.1090602@users.sourceforge.net>
- In-Reply-To
- <8c5c35580710160204s5a4f9fb3j68c0a86c4d080cb7@mail.gmail.com>
* Lars Hjemli [16 X 2007 11:04]:
Show 16 quoted lines
>>From http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/CodingStyle;h=7f1730f1a1ae2e9a6f368bdb10ff65f4568863d5;hb=HEAD
>
> (defun linux-c-mode ()
> "C mode with adjusted defaults for use with the Linux kernel."
> (interactive)
> (c-mode)
> (c-set-style "K&R")
> (setq tab-width 8)
> (setq indent-tabs-mode t)
> (setq c-basic-offset 8))
>
>
> And to use this only in a specific directory:
>
> (setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode)
> auto-mode-alist))Thanks!
But it seems that the above settings are still imperfect, since they mixes tabs and spaces when aligning. For instance:
int some_function(int some_variable) { <T> int result; <T> result = execute_another_function(some_variable, <T> <T> <T> <T> <T> ..other_variable); <T> return result; }
<T> - represents tab here, `.' - space
And if one change the tab size, it will result in a messy alignment in line 5. I guess there is no ideal solution for this in Emacs.
BR, /Adam
-- .:. Adam Piatyszek - "ediap" .:. JID: ediap(at)jabber.org .:. .:. ediap(at)users.sourceforge.net .:. PGP key ID: 0x1F115CCB .:.