[Python-Dev] Making -tt the default

Barry A. Warsaw bwarsaw@beopen.com
Wed, 5 Jul 2000 07:56:02 -0400 (EDT)


>>>>> "GS" == Greg Stein <gstein@lyra.org> writes:

    GS> (add-hook 'python-mode-hook
    |     (lambda ()
    |       (setq indent-tabs-mode nil)
    |       (setq py-indent-offset 2)
    |       (setq py-smart-indentation nil)
    |       (define-key py-mode-map "\e\C-h" 'backward-kill-word)
    |       ))

    GS> The indent-tabs-mode is the key to disabling tab characters
    GS> and using just spaces.

Greg, can you explain why you turn off py-smart-indentation?  Its
purpose is to give you the correct settings when editing someone
else's existing code.  With this variable set to t, it tries to guess
the existing code's indentation level depth and then sets
py-indent-offset to that value, on the assumption that

1) the original author indented their code consistently

2) it is better to be consistent with the existing indentation than
   impose your own and have mixed indentation

Both of these are worthy goals, IMO, so py-smart-indentation should
generally remain true.

For brand new code, given the fact that pymode's default for
py-indent-offset is 4, and Emacs' default for tab-width is 8 (and
should not be changed), you'll generally find that indent-tabs-mode
will be nil when py-smart-indentation is t.

So I think pymode is doing the right thing, and I'm -1 on patch
#100729.  If the user wants indent-tabs-mode set to nil
unconditionally, then setting it in your python-mode-hook, as you've
done, is the Emacs way.

But if someone can give a good example where this approach is flawed,
please let me know.

-Barry