Babel: :post, and noweb references that run a block !456

merged merged by cmc on 2026-11-22 12:40 UTC · krz/orgstar:issue-114-babel-post-noweb into main

Discussion

cmc

Closes #114.

  • :post name(arg=*this*): the block runs, its result is bound to *this*, the reference is resolved and its value is inserted under the block's own :results. Scalars, tables and file links (:results file with and without :file) follow org-babel-execute-src-block. Works for src blocks, #+CALL:, inline calls and inline src blocks.
  • <<name()>> and <<name(arg=value)>> expand to the named block's result (a string as it is, anything else as %S prints it) wherever :noweb expands for running. Export still shows references as written. Tangling refuses them, as it refuses :var that would run a block.
  • Both reuse the :var reference path (Babel.resolve, needs/resume): one trust prompt covering every block reached, asked every time when any has :eval query; a referenced block with a current :cache yes result isn't run; :eval never and cycles stop the run. A :post reference is resolved once with an empty *this* before anything runs, so a reference that can't be resolved runs nothing.
  • Without a program runner (iOS, Mac App Store), a block whose references reach a language that doesn't run in-process is refused before anything runs.
  • A referenced block with :results file now gives its file name (or, without :file, its raw result) rather than a link, as Org does, and its :file is written when it runs as a reference.
  • org-sbe on a block with :post is Unsupported (Emacs fallback on the download version).

Tests: BabelPostTests (oracle against Emacs for 33 :post and noweb cases; interpreter run; refusals and cycles; approval; tangling), NativeProgramsTests.refusesReferencesToBlocksThatNeedARunner. swift test and both Xcode builds pass.

Manual: 11-code-blocks.org (Post-processing, References that run a block, refusals), 14-ios.org, 15-alongside-emacs.org.

No string catalog changes: the new messages are returned from OrgCore and DocumentSession.runBabel like the existing Babel messages, which are not in the catalog.