3 Getting Started

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

(require 'sweeprolog)

Sweep tries to find SWI-Prolog by looking for the swipl executable in the directories listed in the Emacs variable exec-path. When Emacs is started from a shell, it initializes exec-path from the shell’s PATH environment variable which normally includes the location of swipl in common SWI-Prolog installations. If Emacs doesn’t find the swipl executable via exec-path, you can tell Sweep where to find it by setting the variable sweeprolog-swipl-path to point to it:

(setq sweeprolog-swipl-path "/path/to/swipl")

All set! You can now use Sweep for Prolog development (see Editing Prolog code) and for integrating Prolog into your Emacs Lisp code (see Querying Prolog). In the next section (see Discovering Sweep) you’ll find some useful tips for learning to work with Sweep.

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 (see High-level Architecture). If you’re running Emacs 28 or earlier on Linux, you can workaround this issue by starting Emacs with libswipl loaded upfront via LD_PRELOAD, for example:

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