SWI-Prolog offers an extensible interface which allows the user to edit objects of the program: predicates, modules, files, etc. The editor interface is implemented by edit/1 and consists of three parts: locating, selecting and starting the editor.
Any of these parts may be extended or redefined by adding clauses to
various multi-file (see multifile/1)
predicates defined in the module
The built-in edit specifications for edit/1 (see prolog_edit:locate/3) are described below.
|Fully specified objects|
|<Module>:<Name>/<Arity>||Refers a predicate|
|module(<Module>)||Refers to a module|
|file(<Path>)||Refers to a file|
|source_file(<Path>)||Refers to a loaded source-file|
|<Name>/<Arity>||Refers this predicate in any module|
|<Name>||Refers to (1) named predicate in any module with any arity, (2) a (source) file or (3) a module.|
Location is a list of attributes of the location.
Normally, this list will contain the term
---if available--- the term
If it fails, edit/1
uses its internal defaults, which are defined by the Prolog flag editor
and/or the environment variable
EDITOR. The following rules apply. If the Prolog flag editor
is of the format
$<name>, the editor is
determined by the environment variable <name>. Else, if
this flag is
and XPCE is loaded or can be loaded, the built-in Emacs clone
is used. Else, if the environment
EDITOR is set, this
editor is used. Finally,
vi is used as default on Unix systems and notepad on
See the default user preferences file
%fis replaced by the full file-name of the location, and
%dby the line number. If the editor can deal with starting at a specified line, two clauses should be provided, one holding only the
%fpattern, and one holding both patterns.
The default contains definitions for vi, emacs, emacsclient, vim and notepad (latter without line-number version).
Please contribute your specifications to email@example.com.
library(swi_edit), containing definitions to locate classes and methods as well as to bind this package to the PceEmacs built-in editor.
:- multifile prolog_edit:load/0. prolog_edit:load :- ensure_loaded(library(swi_edit)).
<Head> :- <Body>'. Facts are represented as `
<Head> :- true' or simply
<Head>. Variables in the clause are written as A, B, ... . Singleton variables are written as
_. See also portray_clause/2.