Discussion:
Emulated Tabs
Aaron W. Hsu
2010-07-18 20:06:26 UTC
Permalink
Hey Everyone,

I've been playing a bit with my emulated tabs, simply because I do that
sort of thing.

I notice a strange behavior in a recent CVS version of NEdit. When I
have hard tabs set to 8, and emulated tabs set to 4, and then I also
have checked the box to use hard tabs in emulation and blocks, I get
some strange behavior. If I type two emulated tabs in a row, I expect
that a single hard tab should be inserted for that line. However, this
isn't the case. The spaces inserted by the first emulated tab stick
around. This results in something like:

____<tab>

Obviously, that's not cool. Is this a bug? It seems like it should be.

Aaron W. Hsu
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Tony Balinski
2010-07-19 05:09:59 UTC
Permalink
Post by Aaron W. Hsu
Hey Everyone,
I've been playing a bit with my emulated tabs, simply because I do that
sort of thing.
I notice a strange behavior in a recent CVS version of NEdit. When I
have hard tabs set to 8, and emulated tabs set to 4, and then I also
have checked the box to use hard tabs in emulation and blocks, I get
some strange behavior. If I type two emulated tabs in a row, I expect
that a single hard tab should be inserted for that line. However, this
isn't the case. The spaces inserted by the first emulated tab stick
____<tab>
Obviously, that's not cool. Is this a bug? It seems like it should be.
It's been like that for years! Much of NEdit's source has this pattern of
spaces and tabs. I don't like tabs much because of their variable width
(people seem to assume they should tab to 4 character width columns, not 8)
which is why I have backlighting turned on all the time, so I can see them.

Tony
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Aaron W. Hsu
2010-07-19 05:13:40 UTC
Permalink
Hey Tony,
Post by Tony Balinski
It's been like that for years! Much of NEdit's source has this pattern of
spaces and tabs. I don't like tabs much because of their variable width
(people seem to assume they should tab to 4 character width columns, not 8)
which is why I have backlighting turned on all the time, so I can see them.
Well, all the style guides I work with usually require either 8-space
tabs with no leading spaces or all spaces. I'm considering altering two
things in NEdit, but I don't think I would do them if other people
wouldn't like to see the patches:

1) Deleting the leading spaces when using emulated tabs.
2) Adding the ability to change the emulated tabs/hard tabs
setting on a per language basis. Right now, I can't change
whether I use hard tabs or not in emulated tabs on a per
language basis.

Are this things that others would like to see?

Aaron W. Hsu
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Thomas Orgis
2010-07-19 06:52:12 UTC
Permalink
Am Mon, 19 Jul 2010 01:13:40 -0400 (EDT)
Post by Aaron W. Hsu
Are this things that others would like to see?
Actually, I don't quite grok the hardware-tabs-for-emulated-tabs
scheme, so point 1 is a bit irrelevant to me. but point 2 makes sense:
There should be a default tab style and an optional style per
language ... well, and temporary override.
Generally, I prefer using tabs for indendation and spaces for
alignment, the tabs especially because they aren't of defined width --
so other people can choose a width they prefer and happily edit the
same code. But on certain types of files, I want all-spaces (like shell
scripts, which I might like to paste into a terminal piece-wise, a tab
wrecks havoc in an interactive shell).

When you are going to work on the indendation handling of nedit, it
would be super-cool to fix the following. I have a line that I'm going
to break into aligned pieces... let's suppose some massive ugly
function call (notation: TAB is a tab, _ is a space character):

TABbig_bad_function(a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,_n,_o,_p)

I want to arrange the argument list a bit, for some definition of
prettyness (or since the coding style demands lines shorter than 40
chars), so I start breaking it up and shift the second line using
spaces to line up with the opening parenthesis:

TABbig_bad_function(a,_b,_c,_d,_e,
TAB_________________f,_g,_h,_i,_j,_k,_l,_m,_n,_o,_p)

Now I want to break it again, press enter... and nedit does that (my
tab width is actually 3 chars):

TABbig_bad_function(a,_b,_c,_d,_e,
TAB_________________f,_g,_h,_i,_j,
TABTABTABTABTABTAB__k,_l,_m,_n,_o,_p)

Nedit is filling up whatever amount of space it determined for indent
from the previous line with tabs and then the rest with spaces. I
cannot fathom why one would want to do that. What I consider useful is
that result:

TABbig_bad_function(a,_b,_c,_d,_e,
TAB_________________f,_g,_h,_i,_j,
TAB_________________k,_l,_m,_n,_o,_p)

The editor should just keep the indent from the line I am breaking...
plain copy. The pattern of tab and then some spaces is crucial to keep
alignment (as long there's nothing like elastic tabs in sight) while
still offering flexible indentation width to please people who like 8
or 4 (or 3) tab width without changing the file.


Alrighty then,

Thomas.
Tony Balinski
2010-07-20 21:50:38 UTC
Permalink
Post by Aaron W. Hsu
Well, all the style guides I work with usually require either 8-space
tabs with no leading spaces or all spaces. I'm considering altering two
things in NEdit, but I don't think I would do them if other people
1) Deleting the leading spaces when using emulated tabs.
2) Adding the ability to change the emulated tabs/hard tabs
setting on a per language basis. Right now, I can't change
whether I use hard tabs or not in emulated tabs on a per
language basis.
Are this things that others would like to see?
re (1):
There's already code in there for knowing when backspace after hitting tab
should delete spaces from emulated tabs. Conceivably, pressing tab could use
something similar to tidy up previously inserted tab-emulation spaces.

Ideally, tab key presses should be handled like enter key presses: use tab
settings or "smart"; I've always thought tabs should be managed in a way
similar to newlines, and that there should be a macro area for them in the
smart-indent macro area. This, I believe, would be the best way of handling
Thomas' suggestion regarding programming indents, using tabs for structure and
spaces for continuation-line indents.

re (2):
Definitely agree: tab settings should be language-specific. "Smart tabs"
suggested above, would naturally fit into this scheme.

Tony
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Offer Kaye
2010-07-19 08:24:14 UTC
Permalink
Post by Aaron W. Hsu
I notice a strange behavior in a recent CVS version of NEdit. When I
have hard tabs set to 8, and emulated tabs set to 4, and then I also
have checked the box to use hard tabs in emulation and blocks, I get
some strange behavior.
Personally I've never used the checkbox "Use tab characters in..."
simply because I don't understand it. If I'm using "Emulated tabs",
doesn't an option to use hard tab characters exactly contradict that?

My feeling here is that 1 of 3 things is going on:
1. This dialog box is perfectly clear and I'm just a dense user.
2. The dialog box is not clear but in reality (in the code) what
happens is perfectly okay. This post by Aaron I think contradicts this
option.
3. The dialog box is clear - but the specification behind it isn't,
leading to buggy (unclear) implementation, since pretty much by
definition when the spec is blurry the implementation probably won't
do what everyone expects all of the time. IMHO this is what is going
on here, and Aaron's email (and further replies) seem to indicate this
is the case.

Personally, except for Make files, I never use tabs for indentation,
only emulated tabs. But I understand some users do use tab stops.
However even for them, I don't understand why the single checkbox
"Emulated tabs" is not enough. Either you turn on Emulated tabs or you
turn them off. Why isn't it as simple as that?

Regards.
--
Offer Kaye
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Aaron W. Hsu
2010-07-19 08:51:50 UTC
Permalink
This post might be inappropriate. Click to display it.
Tony Balinski
2010-07-20 22:12:54 UTC
Permalink
Post by Offer Kaye
Personally, except for Make files, I never use tabs for indentation,
only emulated tabs. But I understand some users do use tab stops.
However even for them, I don't understand why the single checkbox
"Emulated tabs" is not enough. Either you turn on Emulated tabs or you
turn them off. Why isn't it as simple as that?
Different things here:

Tab spacing: if a tab-char is inserted into a document, how far to the right
does it advance the cursor? Upto the next tab column, where these occur every
tab spacing character columns. For current column pos and tab spacing
tab_dist, that's pos + tab_dist - ((pos + tab_dist) % tab_dist). So far, so
good.

Emulate tabs: when you hit tab, how many columns should your cursor be moved
to the right? The emulated tab spacing value is used in the same way as the
"physical" tab spacing in column-adding calculations.

Use tab characters in padding and emulated tabs: when you hit tab, what gets
added to the document to achieve the effect described above? If set, NEdit
adds as many tab-chars as it can, followed by spaces upto the desired emulated
tab column. Padding applies to automatic newline indents and column drag or
paste, but its logic is very similar. If the option is not set, only spaces
are used for these effects.

So "Emulate tabs" answers "what visual effect on my document should be
achieved by pressing tab?"; "Use tab characters in padding and emulated tabs"
answers "how should that effect be achieved?"

Hope that helps.

Tony
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Continue reading on narkive:
Loading...