Skip to content

feat(cli): --annotate --occurrence N marks the named occurrence of a quote - #93

Merged
backnotprop merged 1 commit into
plannotator:mainfrom
miadisabelle:annotate-occurrence
Sep 24, 2026
Merged

backnotprop merged 1 commit into
plannotator:mainfrom
miadisabelle:annotate-occurrence

Conversation

@miadisabelle

Copy link
Copy Markdown
Contributor

--annotate anchors a mark on the first occurrence of its quote (add_quote_annotation runs source.find(quote)). A phrase that appears more than once in a document can therefore not be marked anywhere later from the command line. The TUI can do it, because a drag selects an exact range. This PR adds --occurrence N to --annotate.

What changed

  • --annotate <file> <quote> <text> [kind] [--occurrence N]. N is 1-based and counts non-overlapping matches, the way str::match_indices does. Without the flag, the first occurrence is marked as today. The kind and the flag can come in either order.
  • --occurrence 0, a missing value and a value that is not a number are refused with a message. An occurrence that does not exist fails and says how many there are.
  • add_quote_annotation_at takes the occurrence. add_quote_annotation keeps its signature and delegates with 1. It is now #[cfg(test)], because only tests call it, the same way is_transient and first_file are marked.
  • The usage text, README.md and crates/plannotator-tui/README.md show the flag.

Validation

  • cargo test --workspace passes: 288 tests, zero failures. Three are new, in tests/annotate_occurrence.rs. They run the real binary with a private PLANNOTATOR_DATA_DIR. The second occurrence of a repeated phrase is exported with its own line number, no flag still marks the first occurrence, and a missing or zero occurrence fails.
  • cargo fmt --all is clean. cargo clippy --workspace --all-targets reports only the two existing warnings in app/compose.rs.
  • I checked the tests by breaking the code on purpose. Always taking the first match makes two of the three fail.

🤖 Generated with Claude Code

…quote

--annotate anchored on the first occurrence of the quote, so a phrase that
appears more than once could not be marked in a later place from the
command line. --occurrence N (1-based, non-overlapping matches, as
str::match_indices counts them) picks the match; without it the first is
marked as before. A missing occurrence fails and says how many there are.

add_quote_annotation_at carries the occurrence; add_quote_annotation keeps
its signature for the tests that call it.
@backnotprop
backnotprop added this pull request to the merge queue Sep 24, 2026
Merged via the queue into plannotator:main with commit 015ebcc Sep 24, 2026
2 checks passed
@backnotprop backnotprop mentioned this pull request Sep 24, 2026
jgwill added a commit to miadisabelle/mia-plannotator-tui that referenced this pull request Sep 25, 2026
The fork's only change, --annotate --occurrence N
(#1), landed upstream as
plannotator#93, so the two conflicts in app/mod.rs and
cli.rs take upstream's side and main now matches upstream/main.

Verified before pushing, against 0.6.0 from this fork: --blocks and
--export output identical, author/author_name survive a rewrite of the
store (jgwill/Miadi tide), and jgwill/gaia 11-plannotator-tmux-review.sh
delivers and resolves a Claude transcript with the 0.9.4 build.

jgwill/gaia#87
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.

2 participants