Discussion:
Elastic tabstops?
e***@gmail.com
2009-02-26 11:21:55 UTC
Permalink
Hello,

is there an Emacs mode which implements elastic tabstops (tabstops
that expand or shrink to fit their contents)? I've searched the
Internet and it seems there isn't.

Explanation of elastic tabstops with a Java applet demo:

http://nickgravgaard.com/elastictabstops/


Thanks
Tassilo Horn
2009-02-26 11:57:28 UTC
Permalink
***@gmail.com writes:

Hi!
Post by e***@gmail.com
is there an Emacs mode which implements elastic tabstops (tabstops
that expand or shrink to fit their contents)?
Isn't that basically the same which `indent-relative' does?

,----[ C-h f indent-relative RET ]
| indent-relative is an interactive compiled Lisp function in `indent.el'.
|
| (indent-relative &optional unindented-ok)
|
| Space out to under next indent point in previous nonblank line.
| An indent point is a non-whitespace character following whitespace.
| The following line shows the indentation points in this line.
| ^ ^ ^ ^ ^ ^ ^ ^ ^
| If the previous nonblank line has no indent points beyond the
| column point starts at, `tab-to-tab-stop' is done instead, unless
| this command is invoked with a numeric argument, in which case it
| does nothing.
|
| See also `indent-relative-maybe'.
`----

Bye,
Tassilo
Alan Mackenzie
2009-02-26 15:41:46 UTC
Permalink
Hi,
Post by e***@gmail.com
Hello,
is there an Emacs mode which implements elastic tabstops (tabstops
that expand or shrink to fit their contents)? I've searched the
Internet and it seems there isn't.
http://nickgravgaard.com/elastictabstops/
I can't fully understand what you're saying in that webpage:

we should say that a tab character is a delimiter between table
cells in a manner more reminiscent of how they're used in tab
separated value (TSV) files.

is rather abstract. It says how we can think of a tab rather than its
effect on displaying the text on the screen. What is meant, exactly, by
a "table cell"? Is it a block of text 1cm wide, or something like that?

The picture on the webpage looks as though it's using tabs to do the
syntactical indentation from column 0, but spaces otherwise (e.g. for
the space between a statement and a line comment). This isn't difficult
to achieve for CC Mode's languages (e.g. C), being a ~25 line hack. If
that's what you want, say so, and I'll hunt out the hack.
Post by e***@gmail.com
Thanks
--
Alan Mackenzie (Nuremberg, Germany).
e***@gmail.com
2009-02-26 19:13:39 UTC
Permalink
Thank you very much for your offer, Alan :-)

Basically, he's saying that tab's width should not be based on
counting character, which is a low level concept. Instead, hitting Tab
should create a table cell of a kind, which spans multiple lines. Then
the editor will always keep aligned any text on adjacent lines which
is entered after the nth tab, no matter how long the "cell"'s text
length is and even if the font is not monospaced. Think about what
align-regexp does, but done live and working with proportional fonts
as well. Indeed, the demo Java applet uses a proportional font, and if
you move any end of line comment belonging to a block of lines, all
other comments move to keep perfectly aligned.

I think that is quite tricky to implement, more so if you try to
retrofit an already existing mode. BTW I'm not asking for such an high-
tech solution. I'd be quite happy if indentation would work as I'm
entering lines when I'm using a proportional font, which I find easier
to read.
e***@gmail.com
2009-02-26 20:04:10 UTC
Permalink
This video shows that Org Mode offers a similar capability to create
tables, albeit using a monospaced font:


e***@gmail.com
2009-02-26 19:28:26 UTC
Permalink
Basically yes, but elastic tabstops are more advanced since they
affect previous lines too and are independent from character width
(they work with proportional fonts, too). The example provided by the
indent-relative documentation looks OK only with a monospaced font.
Elena
2009-03-06 16:55:58 UTC
Permalink
I found out that Emacs can't do it, because it's tied to character
width. Aligning text which uses a proportional font is out of reach
for our beloved editor :-(

Loading...