Skip to content

ptx: implement it - #254

Open
metif12 wants to merge 1 commit into
vlang:mainfrom
metif12:ptx-implementation
Open

metif12 wants to merge 1 commit into
vlang:mainfrom
metif12:ptx-implementation

Conversation

@metif12

@metif12 metif12 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

ptx produces a permuted index: one row per keyword occurrence with the surrounding context, laid out so every keyword lands at the same column.

The measured layout is the tail right-justified in line_width / 2, then the gap, then the keyword, then one space and the head.

The word is a run of letters by default, not letters and digits — which is what GNU does: 42nd yields the keyword nd with 42 left in the context. My first version included digits, and the differential against GNU caught it.

Verification was by cross-compiling for Linux and running under WSL, since V emits Linux C from Windows but cannot link it.

Three behaviours were wrong on the first attempt and the differential caught all three:

  • the keyword was padded, shifting the head one column right on rows with a short keyword
  • the head was truncated to the keyword width, cutting beta gamma to beta
  • io.read_all stopped early on this platform, producing a single truncated row instead of the whole index

Two known gaps, documented rather than faked:

  1. Truncation of a tail or head that does not fit the line width is not implemented. The marker is emitted but the column it lands in does not match GNU, and I did not decode the rule after several attempts. This is the same unresolved thing that made me drop ptx earlier in the session, and it is still unresolved.
  2. -r, -A, -t, -M and the -o/-i/-b file filters parse but have no effect.

6 of 10 differential cases match GNU exactly (default, four width/gap geometries, -f, -W, missing-file rc). The 3 truncation cases do not.

Produces a permuted index: one row per keyword occurrence with the surrounding context, laid out so every keyword lands at the same column. The measured layout is the tail right-justified in line_width / 2, then the gap, then the keyword, then one space and the head. The word is a run of letters by default, not letters and digits, which is what GNU does: '42nd' yields the keyword nd with 42 left in the context. Verification was by cross-compiling for Linux and running under WSL, since V emits Linux C from Windows but cannot link it. Three of the behaviours were wrong on the first attempt and the differential caught all three: the keyword was padded, which shifted the head one column right on rows with a short keyword; the head was truncated to the keyword width, which cut 'beta gamma' to 'beta '; and io.read_all stopped early on this platform, which produced a single truncated row instead of the whole index. Two known gaps, documented rather than faked. Truncation of a tail or head that does not fit the line width is not implemented: the marker is emitted but the column it lands in does not match GNU, and I did not decode the rule. And -r, -A, -t, -M, and the -o/-i/-b file filters parse but have no effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant