diff --git a/docs/specs/2026-06-24-org-file-env-var-design.md b/docs/specs/2026-06-24-org-file-env-var-design.md new file mode 100644 index 0000000..ab83fdf --- /dev/null +++ b/docs/specs/2026-06-24-org-file-env-var-design.md @@ -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 diff --git a/scripts/run b/scripts/run index 36408df..3ff6138 100755 --- a/scripts/run +++ b/scripts/run @@ -15,14 +15,13 @@ if [ $# -ge 1 ] && [ -n "$1" ]; then else PORT="$ARG" fi -fi - -# Stop any existing spine daemon -emacsclient --socket-name=spine --eval '(kill-emacs)' 2>/dev/null || true - -# Build emacs args EMACS_ARGS=(emacs --quick --daemon=spine) +# If SPINE_ORG env var is set, override the org file path +if [ -n "${SPINE_ORG:-}" ]; then + EMACS_ARGS+=(--eval "(setq spine-org-file \"$SPINE_ORG\")") +fi + if [ -n "$HOST" ]; then EMACS_ARGS+=(--eval "(setq spine-host \"$HOST\")") fi