aboutsummaryrefslogtreecommitdiff
path: root/gloss.el
Commit message (Collapse)AuthorAgeFilesLines
* refactor: rework gloss-add UX to single side-window bufferCraig Jennings2026-04-301-21/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous shape opened a regular (non-side) buffer for body input and showed the saved entry in the side window after C-c C-c. That left an extra window split during the typing phase and a side popup the user didn't ask for. New shape, modeled on `org-capture': - `gloss-add' renders the term and underline as a read-only header in *gloss-add: TERM*, leaves the body region beneath it editable, and pops the buffer in the side-window slot. Point lands at the body start so the user can type immediately. - `gloss-add-finish' reads the body via the `gloss-add--body-start' marker, saves with source `manual', kills the buffer, closes the side window, and echoes `gloss-add: saved TERM' for confirmation. - `gloss-add-abort' kills the buffer and closes the side window. - The shared `gloss--add-cleanup' helper handles kill + window-close for both finish and abort. Read-only header uses text properties (`read-only', `front-sticky', `rear-nonsticky') rather than narrowing, so the user can't escape the restriction with `C-x n w'. `gloss--add-finish-internal' no longer calls show-entry — the save is its only responsibility. The display decision (show or not) is the caller's, which lets `gloss-add-finish' choose "save and close" while `gloss-lookup' still chooses "save and show." The previous saved-window-config approach is dropped — the side-slot takeover means there's nothing to restore. Layout returns to its pre-add state on either C-c C-c or C-c C-k. Adds `tests/test-gloss--add-flow-smoke.el' covering the four interactive moments (open, finish, abort, empty-term guard) plus the read-only-header invariant. Updates the `gloss--add-finish-internal' tests to drop the show-entry assertion. 129 tests pass in 0.27s.
* feat: implement gloss secondary commandsCraig Jennings2026-04-301-13/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Five interactive commands plus the supporting major mode and pure helpers for `gloss-add'. `gloss-add' opens a `*gloss-add: TERM*' buffer in `gloss-add-mode', a `text-mode' derivative with C-c C-c to save and C-c C-k to abort. The pure save side, `gloss--add-finish-internal', validates term and body, trims trailing whitespace, and delegates to `gloss-core-save' with source `manual' before showing the new entry. `gloss-edit' resolves a term to its source-buffer marker, jumps point there, unfolds the entry under both the legacy `org-show-entry' and the post-9.6 `org-fold-show-entry' (with-no-warnings on the fallback), and installs `gloss--after-save-refresh-cache' as a buffer-local after-save hook so manual edits keep the cache honest. `gloss-list-terms' prompts via `completing-read' over `gloss-core-list' and dispatches the chosen term to `gloss--lookup-flow'. Empty glossary raises a user-error. `gloss-stats' formats a multi-line report (total / by-source / drill-tagged / file size / cache mtime) via the pure helper `gloss--stats-text' and shows it in `*gloss-stats*' under `special-mode'. Drill counting walks the file via `org-map-entries' to be safe against tag-substring false positives. `gloss-reload' is a thin wrapper that resets the in-memory cache and re-ensures it from disk. `gloss-drill-export' is a thin wrapper around `gloss-drill-export-all'. Audit fold-in: renamed the stats-text missing-file test from `-reports-zero-and-never' to `-reports-zero' to match what the assertion actually checks (the file is auto-created on first call, so mtime is set, not "never"). Filed as a v1.1 follow-up: `gloss.el' reaches into `gloss-core--cache-reset' and `gloss-core--cache-ensure' double-dash-private functions. Decide whether to treat double-dash as "package-private" idiom or to expose public aliases. 125 tests pass in 0.25s — 111 prior plus 14 new across the six new files. No byte-compile warnings.
* feat: implement gloss orchestration core (lookup + fetch-online)Craig Jennings2026-04-301-5/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Two pure-ish helpers and two interactive entry points. `gloss--orchestrate-fetch-result' is a pure pattern-matcher that classifies a fetch result into one of five decision symbols. The ordering matters: definition count gates first, then the error taxonomy. All-empty falls through to `:error-no-defs' so the user never sees a silent no-op. `gloss--lookup-flow' is the orchestration. Cache hit dispatches straight to display. Cache miss runs a fetch, classifies via the helper, and either auto-saves the lone definition, prompts the user to pick, or messages the right error. The `force-fetch' arg lets `gloss-fetch-online' reuse the same flow without duplicating logic. `gloss-core-save' is called with the `replace' collision action so force-fetch over an existing entry replaces it cleanly. On a real cache miss the entry is fresh, so `replace' is moot — the action only matters when the term is already there. `gloss-lookup' and `gloss-fetch-online' are now thin interactive wrappers around `gloss--lookup-flow'. The remaining stubs (add, edit, list-terms, stats, reload, drill-export) still raise user-error. 111 tests pass in 0.23s — 98 prior plus 13 new across the two new files.
* feat: implement gloss-core data layerCraig Jennings2026-04-281-16/+3
| | | | | | | | | | Public API: gloss-core-lookup, gloss-core-save, gloss-core-list, gloss-core-find-buffer-position. Save inserts entries at the alphabetical position (case-insensitive compare), creates the file and parent directory on first call, prompts on collision via completing-read over Replace/Append/Cancel, and updates the in-memory cache directly. Lookup checks gloss-file's mtime against the cached load time. If disk is newer than the buffer, it reverts the buffer first. Out-of-band edits land on the next read. Parser failures during reload preserve the existing cache and surface a one-line message. Tested by the 32-test suite from the previous commit. All 32 pass in 0.16 seconds. The defgroup and defcustoms (gloss-file, gloss-debug) live here rather than in gloss.el. That keeps the data layer self-contained when tests load it directly without the orchestration layer.
* chore: scaffold gloss packageCraig Jennings2026-04-281-0/+155
Five layered files per the design at docs/design/gloss.org. gloss-core for the data layer, gloss-fetch for the network layer, gloss-display for the UI, gloss-drill for the spaced-repetition export, and gloss.el as the entry point. All five are skeletons. Implementation comes next. The Makefile delegates to ert with the usual unit, integration, and per-file targets. It also runs paren and lint passes. The package is licensed GPL-3.0-or-later. README is a placeholder pointing at the design doc.