Sweep provides a facility for executing Prolog goals in separate threads and capturing their output in Emacs buffers as it is produced. You can use this for running queries without blocking Emacs.
Execute a Prolog goal asynchronously and display its output in a
dedicated buffer (
sweeprolog-async-goal, bound to C-c C-& in
Sweep Prolog mode buffers, prompts for a Prolog goal and executes it
in a new Prolog thread, redirecting its output and error streams to an
Emacs buffer that gets updated asynchronously.
This is similar in nature to running asynchronous shell commands with
the standard M-& (
async-shell-command) or M-x
compile commands, expect that
sweeprolog-async-goal runs a
Prolog goal instead of a shell command. For more information about
the aforementioned commands, see (emacs)Single Shell and
The output buffer that
sweeprolog-async-goal creates uses a
dedicated mode called Sweep Async Output mode. This mode is
derived from the standard Compilation mode, and it provides all of the
usual commands documented in (emacs)Compilation Mode.
Notably, you can run the same query again by typing g
sweeprolog-async-goal-restart) in the output buffer. To
interrupt the goal running in the current output buffer, press
C-c C-k (
Compatibility note: asynchronous queries use pipe processes that require Emacs 28 or later and SWI-Prolog 9.1.4 or later.