From 08cd3a12730d26cfc2eae8510da132747643da9e Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 28 Apr 2026 14:30:41 -0500 Subject: feat: implement gloss-core data layer 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. --- gloss.el | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'gloss.el') diff --git a/gloss.el b/gloss.el index 20aacb1..baf4712 100644 --- a/gloss.el +++ b/gloss.el @@ -56,22 +56,9 @@ (require 'gloss-display) (require 'gloss-drill) -(defgroup gloss nil - "Personal glossary with online-sourced definitions." - :group 'tools - :prefix "gloss-") - -(defcustom gloss-file - (expand-file-name "gloss.org" (or (bound-and-true-p org-directory) - user-emacs-directory)) - "Path to the glossary org file." - :type 'file - :group 'gloss) - -(defcustom gloss-debug nil - "When non-nil, write diagnostic events to *gloss-debug*." - :type 'boolean - :group 'gloss) +;; The `gloss' defgroup, `gloss-file', and `gloss-debug' defcustoms live in +;; `gloss-core' so they are defined whenever the data layer is required — +;; tests load `gloss-core' directly without pulling in the orchestration here. (defvar gloss-prefix-map (make-sparse-keymap) "Keymap for `gloss' commands. Default prefix: C-h g.") -- cgit v1.2.3