Using tabs instead of spaces in IDLE?
Tom Bryan
tbryan at python.net
Thu Feb 14 08:13:50 EST 2002
Tim Peters wrote:
> [Tom Bryan]
>> Is there a way to use tabs exclusively for indentation in IDLE?
>
> Yes, provided you're happy with indentwidth==8.
:-P
>> Basically, I'd like tabwidth to equal identwidth while permitting
>> developers to adjust the indentwidth.
>
> You're out of luck there, if they want anything other than 8 for both.
That's what I was afraid of. I think that Jython could do good things for
my group at work, but I really don't look forward to the stupid whitespace
discussions. It's bad enough on c.l.py. I can't wait to hear it in person.
>> I see that AutoIndent.py says
[...snip...]
>> But I don't quite understand that explanation.
>
> Don't be so timid <wink>: change the code and see what happens.
I did. I changed it to 4 and 4. I toggled tabs on in Idle. It seemed to
work on my Linux box.
> meaning of the comment will soon become painfully clear. Have you ever
> used a word processor (as opposed to a text editor)? Tk switches to "word
> processor" tabs when you change its default tab setting.
Ick. So the tabs will depend on the font, etc.?
>> ...
>> It doesn't look like IDLE is friendly to that type of customization.
>
> Not exactly: the Tk text widget is the hangup here. IDLE's autoindent
> code is shared by PythonWin, which latter, being based on the Scintilla
> text widget, doesn't suffer the same tab surprises.
Hm. PythonWin might be a good option. The UNIX heads will probably just
use vi and Emacs, which I think we can handle. The current "approved"
coding style for all languages in the group is supposed to be "always
indent with leading tabs; for alignment purposes, tabs should be viewed as
4 spaces; set your visual display of tabs to whatever you prefer."
>> I know that emacs is. I'm currently investigating the other editors
>> that my team uses, such as CodeWright.
>
> CodeWright won't be a problem. But stick to IDLE's default (== the Emacs
> python-mode default), and no editor anywhere will be a real problem.
I would, but then we've got spaces in some languages and tabs in others.
And I dread the discussion of how many spaces one level of indentation
should be even more than I dread the whitespace-delimited-blocks whining.
I've already been coding some samples with
(defun my-python-mode-hook ()
(setq tab-width 4)
(setq indent-tabs-mode t)
)
(add-hook 'python-mode-hook 'my-python-mode-hook)
It's stupid, but the whitespace issue is probably going to be one of the
biggest obtacles to introducing Jython to my co-workers. I'll be back to
tell everyone how it goes.
I-just-hope-no-one-mentions-the-alien-whitespace-eating-nanovirus-ly y'rs,
---Tom
More information about the Python-list
mailing list