On Sun, Dec 14, 2008 at 12:57 PM, Alexandre Vassalotti
<[email protected]> wrote:
> On Sun, Dec 14, 2008 at 12:43 PM, Jeffrey Yasskin <[email protected]> wrote:
>> I've never figured out how to configure emacs to deduce whether the
>> current file uses spaces or tabs and has a 4 or 8 space indent. I
>> always try to get it right anyway, but it'd be a lot more convenient
>> if my editor did it for me. If there are such instructions, perhaps
>> they should be added to PEPs 7 and 8?
>>
>
> I know python-mode is able to detect indent configuration of python
> code automatically, but I don't know if c-mode is able to. Personally,
>
[sorry, <tab><space> in gmail made it send my unfinished email]
Personally, I use auto-mode-alist to make Emacs choose the indent
configuration to use automatically.
Here's how it looks like for me:
(defmacro def-styled-c-mode (name style &rest body)
"Define styled C modes."
`(defun ,name ()
(interactive)
(c-mode)
(c-set-style ,style)
,@body))
(def-styled-c-mode python-c-mode "python"
(setq indent-tabs-mode t
tab-width 8
c-basic-offset 8))
(def-styled-c-mode py3k-c-mode "python"
(setq indent-tabs-mode nil
tab-width 4
c-basic-offset 4))
(setq auto-mode-alist
(append '(("/python.org/python/.*\\.[ch]\\'" . python-c-mode)
("/python.org/.*/.*\\.[ch]\\'" . py3k-c-mode)) auto-mode-alist))
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com