help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: death to tabs


From: Kai Großjohann
Subject: Re: death to tabs
Date: Sat, 05 Apr 2003 22:24:58 +0200
User-agent: Gnus/5.090018 (Oort Gnus v0.18) Emacs/21.3.50 (gnu/linux)

tom.horsley@att.net (Thomas A. Horsley) writes:

> Of course, the true villian in the whole TAB story is the unknown (to me,
> anyway) Prince of Evil who designed the first editor which allowed you to
> change the tab width to be something other than 8, thus removing text
> formatting information from the file, and placing it only in the brain of
> the author (where it is unlikely to be recoverable by those who follow
> after).

Actually, if used right, tabs in source code can be useful.  You
know, some people prefer an indentation offset of 2, some prefer 4,
and still others prefer still other numbers.  If each indentation
level was indicated by a tab char, all those people could have their
preferred viewing experience without changing the file.  If you use
spaces, you impose your preference on the others.

There is a problem of alignment, though.  This needs to be done in a
smart way.  Here's my idea on it.  Look at this code:

if ( a == b ) {
    //-1
    if ( some_long_variable ==
         another_long_variable ) {
        //-2
        do_something();
        do_something_else();
    }
}

I use an offset of 4, as you can see.  The comments mark the
indentation levels.  So the second if statement should be preceded by
one tab.  The "another_long_variable" line should also start with one
tab, then it should have 5 spaces for alignment.  The do_something
lines should start with two tabs each.

If this was the case, then others could take the code and view it
with a different tab-width setting and everything would still look
right.  In particular, some_long_variable and another_long_variable
would still be aligned!

I would really like if this were to happen.  But it's not going to
happen anytime soon, I'm afraid.
-- 
A preposition is not a good thing to end a sentence with.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]