Expand description
table-mode: the shared minor that edits pipe tables (TB.1).
Design: table-mode.md.
Slice plan: table-mode.md.
§Why this is native and shared, not org’s
Pipe tables are markdown’s and org’s alike, so by “shared behaviour is a
minor mode, never a copied keymap” the chords belong in ONE mode spanning
both majors. The question that decides where is which owner can serve
both, and only the host can: markdown-mode is a native major, so a table
mode living in the org plugin would make markdown table editing require
the org plugin installed and enabled — silently absent otherwise, since a
chord nobody bound simply does nothing.
The host was already the owner in fact. super::layout has been here
since HP.1, its module doc naming “a table-mode in this directory” as
its next consumer, and it measures cells by display width where the
plugin’s copy counted chars — a difference its own doc called “honestly
wrong for CJK”. Two engines existed; this slice keeps the better one.
org-table-mode stays, and is not redundant: it is where behaviour that
is genuinely org’s goes — #+TBLFM: formulas above all. What it no longer
carries is the generic surface every pipe table shares.
§Layering: these chords decline, they do not swallow
<Tab> in a table advances a cell; anywhere else it must still mean what
it meant. So the bodies return [Effect::Declined] when the caret is not
in a table, and the dispatcher re-resolves the chord against the layers
below — org-mode’s headline cycle, then the builtin jump-forward. Two
hops, and the chain is a tested property rather than an assumed one.
Declined is right only for a chord shared with a lower layer. A
decline re-runs a multi-key chord’s TRAILING key alone, so declining
<leader>tK outside a table would fire a bare K. The <leader>t…
family returns [Effect::None] instead: nothing below binds them, and
consuming the chord is the honest no-op. See decline-only-shared-chords.
Structs§
- Table
Mode table-mode— pipe-table editing, on every major that has pipe tables.
Constants§
- ALIGN
- Action name: Align the table at the cursor (
<leader>t|). Consumes the chord (no-op) outside a table. - BLANK_
CELL - Action name: Empty the cell at the cursor (
<leader>tb); TB.3. - COLUMN_
LEFT - Action name: Move the column left (
<leader>tH). - COLUMN_
RIGHT - Action name: Move the column right (
<leader>tL). - COPY_
DOWN - Action name: Copy the cell into the row below, incrementing a trailing number (
<leader>ty); TB.3. - DELETE_
COLUMN - Action name: Delete the column at the cursor (
<leader>tdc). - DELETE_
ROW - Action name: Delete the row at the cursor (
<leader>tdr). - INSERT_
COLUMN - Action name: Insert an empty column to the right (
<leader>tc). - INSERT_
ROW - Action name: Insert an empty row below (
<leader>tr). - INSERT_
RULE - Action name: Insert a horizontal rule below the row (
<leader>t-); TB.3. - NEXT_
CELL - Action name: Next cell, realigning; adds a row past the last cell (
<Tab>, Normal and Insert). Declines outside a table. - NEXT_
ROW - Action name: Same column, next row, adding a row at the end (Insert
<CR>); TB.4. Declines outside a table. - PREV_
CELL - Action name: Previous cell, realigning (
<S-Tab>, Normal and Insert). Declines outside a table. - REALIGN
- Action name: Realign, declining outside a table so the chord falls to the layer below (
<C-c><C-c>, and Insert<Esc>with fall-through); TB.4. - ROW_
DOWN - Action name: Move the row down (
<leader>tJ). - ROW_UP
- Action name: Move the row up (
<leader>tK). - SORT
- Action name: Sort the section by the cursor’s column (
<leader>ts); TB.3. - SORT_
DESC - Action name: Sort the section descending (
<leader>tS); TB.3. - TRANSPOSE
- Action name: Swap rows and columns (
<leader>tT); TB.3.
Functions§
- register_
table_ actions - Register every
table-modeaction. - register_
table_ mode - Register
TableModeinregistry. Called byregister_foundation_modes; the chords’ bodies are registered separately byregister_table_actionsinto the command registry, which must happen before the host translates mode keymaps or the entries’ command names will not resolve.