From 08d06ed00c9d6e98f0f8a02d243a2eb36ee4bff1 Mon Sep 17 00:00:00 2001 From: Szymon Szukalski Date: Thu, 9 Apr 2026 11:22:48 +1000 Subject: Improve CRM and journal workflows --- ...-04-09-journal-open-narrowing-implementation.md | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 docs/plans/2026-04-09-journal-open-narrowing-implementation.md (limited to 'docs/plans/2026-04-09-journal-open-narrowing-implementation.md') diff --git a/docs/plans/2026-04-09-journal-open-narrowing-implementation.md b/docs/plans/2026-04-09-journal-open-narrowing-implementation.md new file mode 100644 index 0000000..59a80de --- /dev/null +++ b/docs/plans/2026-04-09-journal-open-narrowing-implementation.md @@ -0,0 +1,85 @@ +# Journal Open Narrowing Implementation Plan + +> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. + +**Goal:** Make `ss-open-journal` narrow to today's subtree when today's journal entry exists, while preserving the current fallback when it does not. + +**Architecture:** Add focused ERT coverage for the journal-open helper in `tests/`, then update `lisp/ss-org.el` so it widens first, reuses the existing `ss-journal-goto-date` lookup, and narrows only on the successful path. Keep the missing-entry case unchanged by leaving point at the end of the journal buffer without creating new headings. + +**Tech Stack:** Emacs Lisp, ERT, batch Emacs verification + +--- + +### Task 1: Add failing journal-open test + +**Files:** +- Modify: `tests/ss-capture-tests.el` +- Modify: `lisp/ss-org.el` + +**Step 1: Write the failing test** + +```elisp +(ert-deftest ss-open-journal-narrows-to-today-when-entry-exists () + ...) +``` + +**Step 2: Run test to verify it fails** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-capture-tests.el -f ert-run-tests-batch-and-exit` +Expected: FAIL because `ss-open-journal` currently widens and jumps, but does not narrow. + +**Step 3: Write minimal implementation** + +```elisp +(when (ss-journal-goto-date) + (org-narrow-to-subtree)) +``` + +**Step 4: Run test to verify it passes** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-capture-tests.el -f ert-run-tests-batch-and-exit` +Expected: PASS, with the fallback case still leaving the buffer widened at end of file. + +**Step 5: Commit** + +```bash +git add tests/ss-capture-tests.el lisp/ss-org.el +git commit -m "Narrow journal open to today" +``` + +### Task 2: Run regression verification + +**Files:** +- Review: `README.md` +- Verify: `lisp/ss-org.el` + +**Step 1: Write the failing test** + +```elisp +(ert-deftest ss-open-journal-falls-back-to-end-when-today-missing () + ...) +``` + +**Step 2: Run test to verify it fails** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-capture-tests.el -f ert-run-tests-batch-and-exit` +Expected: FAIL until the fallback remains explicitly covered. + +**Step 3: Write minimal implementation** + +```elisp +(unless (ss-journal-goto-date) + (goto-char (point-max))) +``` + +**Step 4: Run test to verify it passes** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-capture-tests.el -l tests/ss-crm-tests.el -f ert-run-tests-batch-and-exit` +Expected: PASS, then run `emacs --batch -Q --load ./init.el` to confirm startup remains healthy. + +**Step 5: Commit** + +```bash +git add tests/ss-capture-tests.el lisp/ss-org.el README.md +git commit -m "Preserve journal open fallback" +``` -- cgit v1.2.3