Skip to content

Add session (Notebook Mode) support for Common Lisp via SBCL#450

Open
nelsonlove wants to merge 4 commits into
twibiral:masterfrom
nelsonlove:lisp-session
Open

Add session (Notebook Mode) support for Common Lisp via SBCL#450
nelsonlove wants to merge 4 commits into
twibiral:masterfrom
nelsonlove:lisp-session

Conversation

@nelsonlove

Copy link
Copy Markdown

Summary

Builds on #446 (Common Lisp via SBCL) — adds interactive/Notebook Mode support, so consecutive lisp blocks in a note share a persistent SBCL image: definitions and state carry over between blocks, like the existing js/python/R notebook modes (or org-babel's :session).

Implementation

LispExecutor extends ReplExecutor. Instead of SBCL's own REPL (which prints * prompts to stdout and drops into the interactive debugger on error, hanging a piped session), a minimal read-eval-print loop is passed via --eval:

  • no prompts; values print one per line (~&~s~%)
  • errors print to stderr and return to the loop (handler-case around both read and eval), so one bad block doesn't kill the session
  • a *debugger-hook* fallback exits rather than hangs if anything escapes
  • the finish sigil form ends in (values) so the loop prints nothing for it

The non-interactive lispArgs setting (default --script) is intentionally not reused — it would prevent the session loop from running. A "Run Common Lisp blocks in Notebook Mode" toggle is added to the Lisp settings panel, wired to the existing lispInteractive setting.

Testing

  • npm run build passes
  • Verified in a live vault (macOS, SBCL 2.x): (defun square (x) (* x x)) in one block, (square 7) in the next → 49; an (error "boom") block prints the condition and subsequent blocks still run in the same image
  • Verified the loop's behavior standalone: piped forms produce clean per-line values, no prompts, error recovery works

🤖 Generated with Claude Code

nelsonlove and others added 4 commits July 10, 2026 22:12
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A ReplExecutor for lisp: a minimal prompt-less read-eval-print loop is
passed via --eval, printing values one per line and returning to the loop
on errors instead of invoking the interactive debugger.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…sions

Threads the running block's parsed args through executor.run so the
session eval loop can select what a block reports: transcript (default,
REPL-style), output (stdout only), or value (the last form's values,
stdout discarded).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nelsonlove

Copy link
Copy Markdown
Author

Pushed a follow-up commit adding org-babel-style result modes for session blocks: {results="output"} (stdout only) and {results="value"} (last form's values, stdout discarded); the default remains the REPL-style transcript. The block's parsed args are threaded through executor.run as an optional trailing parameter, so other executors are unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant