feat: add SPINE_ORG env var to override org file path

Add SPINE_ORG environment variable support to scripts/run. When set,
the value is passed as spine-org-file via --eval before loading spine.el.

Usage:
  SPINE_ORG=~/my-books.org ./scripts/run
  SPINE_ORG=/work/personal-local/spine/sample-books.org ./scripts/run localhost:9090

When unset, defaults to ~/spine/books.org (existing behavior).
This commit is contained in:
2026-06-23 22:19:51 -04:00
parent bbd9a455cd
commit 7f3769fcd8
2 changed files with 54 additions and 6 deletions
@@ -0,0 +1,49 @@
# Parameterize spine.org Path via Environment Variable
## Problem
The org data file path (`spine-org-file`) is hardcoded to `~/spine/books.org` in
`spine.el`. Users who want to point the app at a different org file must manually
construct the full `emacs --eval` command line instead of using the `scripts/run`
convenience script.
## Design
Add `SPINE_ORG` environment variable support to `scripts/run`. When set, the
script passes the path to Emacs via `--eval` before loading `spine.el`, matching
the existing pattern for `spine-host` and `spine-port`.
### Interface
```bash
# Default (same as today): ~/spine/books.org
./scripts/run
# Custom path, default port 8080
SPINE_ORG=~/my-books.org ./scripts/run
# Custom path with host and port
SPINE_ORG=$(pwd)/sample-books.org ./scripts/run localhost:9090
```
### Affected files
- **`scripts/run`** — add SPINE_ORG env var check before launching Emacs
- **`spine.el`** — no changes needed (already uses `spine-org-file` defvar)
- **Tests** — no changes needed (already set their own `spine-org-file`)
### Implementation
In `scripts/run`, after the HOST/PORT argument parsing block (line 18), add:
```bash
if [ -n "${SPINE_ORG:-}" ]; then
EMACS_ARGS+=(--eval "(setq spine-org-file \"$SPINE_ORG\")")
fi
```
### Edge cases
- `SPINE_ORG` unset or empty → ignored, default in `spine.el` applies
- Path with spaces → quoted inside the Emacs string, handled correctly
- Relative vs absolute paths → user's responsibility; Emacs resolves relative to default-directory