emacs-devel
[Top][All Lists]
Advanced

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

Re: the overloading of `tab-width'


From: Kai Großjohann
Subject: Re: the overloading of `tab-width'
Date: Sat, 15 Jun 2002 20:57:28 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (i686-pc-linux-gnu)

Colin Walters <address@hidden> writes:

> Unfortunately, believe it or not, Emacs gives me no way to deal with
> this.  You may say, "You can just change `tab-width'", but in fact I
> can't.  If I set `tab-width' to 2, then everything shrinks nicely to the
> left.  However, I can't just hit TAB anymore to do indentation, because
> CC mode decides it has to insert *four* tabs in order to make up to the
> `c-basic-offset' value of 8. 
>
> Now, your next response might be, "Why can't you just set *both*
> c-basic-offset and tab-width to 2"?  And the answer is because that can
> change the buffer's representation on disk.  For example, in the
> following code: 

It was my impression that the problem can only be solved by
introducing two kinds of indentation.  When going one brace level
deeper in the structure of the program, there is whitespace at the
beginning of the line to indicate this.  But then, there are
statements which are split over several lines and the second line
contains whitespace to line it up with the first.

For the "brace-level" indentation, it would work to use one tab for
each level and to then change the displayed width of a tab.

But for the "alignment" indentation, this does not work.  Consider
this piece of code:

if ( a == b ) {
    foo(a,
        b);
//  X   Y
}

Consider the third line.  The first part of whitespace comes (up to
the X indicated in fourth (comment) line) is of the "indentation"
kind.  The second part, from X to Y, is of the "alignment" kind.

I think it would be useful to teach modes about the two kinds of
alignment.  Then there could be a user option to use "one tab per
level" for the indentation and "spaces only" for the alignment.

So with a tab-width of 4, the third line in the example would start
with one tab (for the brace level), and four spaces.

What do people think?

This change is not easy, since every mode has to be changed
separately.

kai
-- 
~/.signature is: umop 3p!sdn    (Frank Nobis)



reply via email to

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