summaryrefslogtreecommitdiff
path: root/docs/plans/2026-04-09-journal-open-narrowing-implementation.md
blob: 59a80de58fccd83b25012470672d3ee1450312e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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"
```