Sweep provides a classic Prolog top-level interface for interacting with the embedded Prolog runtime. To start the top-level, use M-x sweeprolog-top-level RET. This command opens a buffer with an interactive Prolog top-level.
Run an interactive Prolog top-level in a buffer.
sweeprolog-top-level creates a buffer named
*sweeprolog-top-level*, and connects it to a Prolog top-level.
If the *sweeprolog-top-level* buffer already exists, this
command simply displays the existing buffer. See Multiple Top-levels to learn about using multiple top-level buffers at the
The top-level buffer uses the Sweep Top-level major mode
sweeprolog-top-level-mode). This mode derives from
comint-mode, which is the common mode used in Emacs
REPL (Read Evaluate Print Loop) interfaces. As a result, the
top-level buffer inherits the features present in other
comint-mode derivatives, most of which are described in
Top-level buffers are backed by Prolog threads that run in the same
process as Emacs and the main Prolog runtime. On Unix systems,
top-levels communicate with their corresponding threads via a
pseudo-terminal device (pty). Alternatively, Sweep top-level
buffers can communicate with their threads via a local TCP connection.
You can force Sweep to use TCP instead of a pty on Unix systems by
customizing the user option
Whether to use pty for top-level communication. If this is
nil, Sweep top-level buffers communicate with their
top-level threads via a pty, otherwise they use a local TCP
sweeprolog-top-level-use-pty is on by default on systems where
Emacs can use a pty. On other systems, such as MS Windows, or when
sweeprolog-top-level-use-pty is set to
Sweep creates a TCP server socket bound to a random port to accept
incoming connections from top-level buffers. Sweep only starts this
TCP server socket when you first invoke of
sweeprolog-top-level, so there are no listening sockets before
you actually use the top-level. The TCP server only accepts
connections from the local machine, but note that other users on the
same host might be able to connect to the TCP server socket and get a
Prolog top-level. This may be a security concern if you are sharing a
host with untrusted users, so you should be careful about using
nil on shared machines.