Did you know ... Search Documentation:
Using SWI-Prolog with GNU Emacs

There is an excellent Prolog mode for GNU Emacs and XEmacs. It is maintained by Stefan Bruda and available from https://bruda.ca/emacs/prolog_mode_for_emacs

The mode plays nicely with SWI-Prolog and other Prolog systems. It features syntax highlighting, automatic indentation, a predicate menu, and full interaction with a Prolog process.

The Prolog mode that is included in GNU Emacs ships with regressions that have been reported but not yet resolved. Therefore, we recommend to use Stefan Bruda's version of the mode as described in the following.

Installation Hints for GNU Emacs

  1. Download the file prolog.el from https://bruda.ca/emacs/prolog_mode_for_emacs and save it in your load-path so that Emacs can find it.
  2. Optionally, you can byte-compile prolog.el for better performance. Load prolog.el into Emacs and do M-x byte-compile-file RET.
  3. Add the following lines to ~/.emacs (~/_emacs on Windows):
    (autoload 'prolog-mode "prolog" "Major mode for editing Prolog programs." t)
    (add-to-list 'auto-mode-alist '("\\.pl\\'" . prolog-mode))

    Where is ~/_emacs?

    ~ is a shortcut for the home directory, on Windows it is system and language specific. It may be for example C:\ or C:\Dokumente. The best way to find "~" is: select "Files->Open.." and enter "~". Then Emacs prints the directory name and contents.

  4. Customize the Prolog mode. The following page explains how to enable electric indentation, syntax checking and PceEmacs-style comments: https://www.metalevel.at/pceprolog/

ediprolog: Run Prolog queries in Emacs

ediprolog allows you to interact with SWI-Prolog in all Emacs buffers. You can quickly consult buffers and regions, and run queries that are embedded in your source files. ediprolog is available from: https://github.com/triska/ediprolog

Ptags: create Prolog tags for Emacs

Djamé Seddah pointed to the existence of ptags, a program to make tag-files for finding definitions in Prolog programs. This is the original site. We have a local copy of the c-code: ptags.tgz

Debug Adapter Protocol (DAP) server for SWI-Prolog

DAP is a protocol that specifies a standard of communication between IDEs and programming language runtime systems for achieving interactive graphical debugging features. A Debug Adapter Protocol server is a program that adapts the native debugger of a programming language to expose the standard interface defined by the DAP specification, allowing any IDE that implements a DAP client to operate the debugger with minimal language-specific knowledge. For SWI-Prolog, a DAP server is available via the debug_adapter pack. To enable DAP debugging in GNU Emacs, follow the instructions from: https://emacs-lsp.github.io/dap-mode/page/configuration/#swi-prolog