krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

docs/plans/2026-10-05-fill.md

c1295824f55c7bba681fca8338bf08167e110105
orgstar/docs/plans/2026-10-05-fill.md rendered · source · history · blame · raw

33 lines · 2016 bytes

 1# Fill Paragraph Implementation Plan
 2
 3> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
 4
 5**Goal:** M-q as `org-fill-paragraph`: paragraphs (also in items and greater blocks), comments and comment blocks, byte- and caret-exact against Emacs.
 6
 7**Architecture:** `Fill.swift` ports `org-fill-element` and Emacs's `fill-region-as-paragraph` (fill.el): adaptive prefixes (`fill-context-prefix`, `fill-match-adaptive-prefix`, `org-adaptive-fill-function`, `org-adaptive-fill-paragraph-function`), `fill-delete-prefix`, `fill-delete-newlines`, `canonically-space-region`, `fill-move-to-break-point`, `fill-nobreak-p` with org's `paragraph-start` and its three no-break predicates, `fill-newline`. Elements come from the parser; quote, center and special blocks are parsed into their elements on demand, since the tree keeps blocks opaque.
 8
 9**Tech Stack:** Swift 6.2 tools, Swift Testing, Emacs 31.1 / Org 9.8.7 oracle.
10
11**Spec:** `docs/design.md`, "Goals" (`M-q` fill).
12
13## Global Constraints
14
15- `sentence-end-double-space` nil (the user's Doom setting), `colon-double-space` nil, `left-margin` 0, left justification, `adaptive-fill-mode` t.
16- `fill-column` is an option: Emacs's 70 in the oracle's first pass, Doom's 80 in the second and as the app default.
17- Src blocks are left alone: Emacs fills them through the language's mode and re-indents them on the way.
18
19## Defaults chosen (user may change)
20
21- Fill column 80 (Doom). Mac preset: ⌃⌘P.
22- No CJK line breaking rules (kinsoku), no justification with C-u.
23
24---
25
26### Task 1: Fill
27
28- [ ] Port; oracle over 16 variants (items, comments, quotes, line breaks, timestamps, links, captions, markup at line start, extra spaces) at both fill columns, and over corpus paragraphs (src blocks excluded).
29- [ ] Commit "Port fill paragraph".
30
31### Task 2: App
32
33- [ ] M-q / ⌃⌘P; Settings fill column.