sweep: SWI-Prolog Embedded in Emacs
Eshel Yaronme@eshelyaron.com
Abstract
`sweep` is an embedding of SWI-Prolog in GNU Emacs. It provides an interface for executing Prolog queries and consuming their results from Emacs Lisp. `sweep` further builds on top of this interface and on top of the standard Emacs facilities to provide advanced features for developing SWI-Prolog programs in Emacs.

# Table of Contents

## 1 Installation

The `sweeprolog` Elisp package is available on NonGNU ELPA, to install `sweeprolog` simply open Emacs and type `M-x package-install RET sweeprolog RET`.

An alternative to installing from ELPA is to get the Elisp library from the `sweep` Git repository:

1. Clone the `sweep` repository:

           git clone https://git.sr.ht/~eshel/sweep

   Or:

           git clone https://github.com/SWI-Prolog/packages-sweep sweep

2. Add `sweep` to Emacs' `load-path`:

           (add-to-list 'load-path "/path/to/sweep")

## 2 Getting started

After installing the `sweeprolog` Elisp library, load it into Emacs:

      (require 'sweeprolog)

All set! `sweeprolog` automatically loads `sweep-module` and initializes the embedded SWI-Prolog runtime. For a full description of the different features of `sweep`, see the `sweep` manual.

Important note for Linux users: prior to version 29, Emacs would load dynamic modules in a way that is not fully compatible with the way the SWI-Prolog native library, `libswipl`, loads its own native extensions. This may lead to `sweep` failing after loading `sweep-module`. To work around this issue, users running Emacs 28 or earlier on Linux can start Emacs with `libswipl` loaded upfront via `LD_PRELOAD`, for example:

      LD_PRELOAD=/usr/local/lib/libswipl.so emacs