TABs (was: Waffling between Python and Ruby)

David Bolen db3l at fitlinxx.com
Fri Jun 16 17:16:50 EDT 2000


hzhu at knowledgetrack.com (Huaiyu Zhu) writes:

> Oops!  You're right, as several people also pointed out to me in email.
> Actually I had this in .emacs and didn't realize it for years:
> 
> (setq-default tab-width 4)
> 
> I am not aware of serious adverse effect, though.

Eeek - that's evil.  Don't do that :-)

A TAB character has a perfectly good definition, and artifically
mucking with that definition just within the environment of your
editor is going to pretty much ensure that any other application that
expects the normal behavior will present or parse your files
differently.  Besides, Emacs makes it so easy to maintain indentation
at any level without changing the basic tab size.

>                                                    The good thing is that
> changing indentation is really easy.  You can use one keystroke backspace or
> C-d, for example.

Well, for a single line that's true, although of course if you set up
your language mode to your preferred indentation style, then just
hitting TAB anywhere on the line will re-indent that line according to
your preferences.

But for multiple lines you won't want to be explicitly deleting the
characters on each line, and once you have a region, adjusting the
indentation of the region (C-X TAB) is simple.

But to keep this posting slightly on topic for the group, I suppose
this is as good an indication as any that depending on at least the
presentation of TABs in code - perhaps except that used only locally -
is not the best choice.

> C-d, for example.  Presumably the evil will manifest itself when dealing
> with other programs, but I also set 'less -x4' so I don't even see it.

But as you say, you had to explicitly "reprogram" less for that behavior.

> Wondering what other people will see when reading my programs ...

They'll see a TAB character expand to get to the nearest 8-character
boundary.  At a minimum, if you must use a TAB this way within files
you work on, you should untabify them (or re-tabify them to standard
TAB widths) before any external distribution because assuming the raw
TAB character indents at multiples of 4 is definitely not going to be
the default assumption just about anywhere else, and if nothing else
it'll look different than you wrote it and perhaps not as nice (line
wrapping and all).

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list