Table alignment for Emacs and Sublime Text (from dev 66442bdd4d5d)
This commit is contained in:
@@ -13,12 +13,14 @@ and load the mode. Add to `~/.emacs.d/init.el`:
|
||||
(add-to-list 'load-path "full-pathname-of-the-emacs-directory")
|
||||
(require 'klammertext-mode)
|
||||
(require 'klammertext-indent) ; optional, experimental: TAB indentation
|
||||
(require 'klammertext-align) ; optional, experimental: table alignment
|
||||
```
|
||||
|
||||
Replace `full-pathname-of-the-emacs-directory` with the full path to the
|
||||
directory that contains `klammertext-mode.el`. The second require loads the
|
||||
experimental indentation support (see "Indentation" below); it is a separate
|
||||
unit — comment the line out to disable indentation entirely.
|
||||
directory that contains `klammertext-mode.el`. The last two requires load
|
||||
the experimental indentation and table-alignment support (see their sections
|
||||
below); each is a separate unit — comment its line out to disable it
|
||||
entirely.
|
||||
|
||||
The mode auto-activates for `.kt` and `.k` files. (The `.k` / `.kt` distinction
|
||||
is a filing convention, not a lexical one — the same mode serves both.) You can
|
||||
@@ -196,6 +198,35 @@ indentation happens only when you ask for it (TAB, `indent-region`). The
|
||||
offset is `klammertext-indent-offset` (default 2); all three variables are
|
||||
customizable in the `klammertext-indent` group.
|
||||
|
||||
## Table alignment (experimental)
|
||||
|
||||
With `klammertext-align.el` loaded (the optional require above), **`C-c C-a`**
|
||||
with point anywhere inside a `@table` span pads the cells of its rows so the
|
||||
`|` separators line up:
|
||||
|
||||
```
|
||||
@table
|
||||
First item | Second | A third item that's longer ||
|
||||
Row 2 | Text | Not as long ||
|
||||
@
|
||||
```
|
||||
|
||||
A row is one line ending with the row delimiter `||` (the customary trailing
|
||||
delimiter — the parser strips one trailing delimiter, and it keeps every row
|
||||
uniform, which also suits program-generated tables); the last row may omit
|
||||
it. Alignment is for small data items, so a row is left untouched — and
|
||||
contributes nothing to the column widths — when any of its cells is longer
|
||||
than `klammertext-align-cell-max` (30) characters or the row spans lines.
|
||||
If the aligned rows would exceed `klammertext-align-row-max` (100) columns,
|
||||
nothing changes and the reason is reported.
|
||||
|
||||
The padding is semantically free: the SKS strips cell content, and no
|
||||
whitespace is ever inserted inside a bar run (which would turn a `||` row
|
||||
separator into an empty `| |` cell). Bars inside a nested klammer in a cell
|
||||
(`@frac 1 | 2 @`) belong to that klammer, not the table, and are left alone.
|
||||
Aligned rows adopt the leading whitespace of the first aligned row — run TAB
|
||||
first if the rows disagree.
|
||||
|
||||
## Literal klammers
|
||||
|
||||
Inside a `literal` argument — for example the body of `@code ... code@` — `#`
|
||||
|
||||
Reference in New Issue
Block a user