3.11.3 Usage

A prolog process can be started by choosing Run Prolog from the Prolog menu, by typing C-c <RET>, or by typing M-x run-prolog. It is however not strictly necessary to start a prolog process manually since it is automatically done when consulting or compiling, if needed. The process can be restarted (i.e. the old one is killed and a new one is created) by typing C-u C-c <RET>.

Programs are run and debugged in the normal way, with terminal I/O via the *prolog* buffer. The most common debugging predicates are available from the menu or via key-bindings.

A particularly useful feature under the Emacs interface is source-linked debugging. This is enabled or disabled using the Prolog/Source level debugging menu entry. It can also be enabled by setting the Emacs variable prolog-use-sicstus-sd to t in ~/.emacs. Both these methods set the Prolog flag source_info to emacs. Its value should be emacs while loading the code to be debugged and while debugging. If so, the debugger will display the source code location of the current goal when it prompts for a debugger command, by overlaying the beginning of the current line of code with an arrow. If source_info was off when the code was loaded, or if it was asserted or loaded from user, the current goal will still be shown but out of context. Note that if the code has been modified since it was last loaded, Prolog's line number information may be invalid. If this happens, just reload the relevant buffer.

Consultation and compilation is either done via the menu or with the following key-bindings:

C-c C-f
Consult file.


C-c C-b
Consult buffer.


C-c C-r
Consult region.


C-c C-p
Consult predicate.


C-c C-c f
Compile file.


C-c C-c b
Compile buffer.


C-c C-c r
Compile region.


C-c C-c p
Compile predicate.

The boundaries used when consulting and compiling predicates are the first and last clauses of the predicate the cursor is currently in.

Other useful key-bindings are:

M-n
Go to the next clause.


M-p
Go to the previous clause.


M-a
Go to beginning of clause.


M-e
Go to end of clause.


M-C-c
Mark clause.


M-C-a
Go to beginning of predicate.


M-C-e
Go to end of predicate.


M-C-h
Mark predicate.


M-{
Go to the previous paragraph (i.e. empty line).


M-}
Go to the next paragraph (i.e. empty line).


M-h
Mark paragraph.


M-C-n
Go to matching right parenthesis.


M-C-p
Go to matching left parenthesis.
M-;
Creates a comment at comment-column. This comment will always stay at this position when the line is indented, regardless of changes in the text earlier on the line, provided that prolog-align-comments-flag is set to t.


C-c C-t
C-u C-c C-t
Enable and disable creeping, respectively.


C-c C-d
C-u C-c C-d
Enable and disable leaping, respectively.


C-c C-z
C-u C-c C-z
Enable and disable zipping, respectively.


C-x SPC
C-u C-x SPC
Set and remove a line breakpoint. This uses the advanced debugger features introduced in SICStus 3.8; see Advanced Debugging.


C-c C-s
Insert the PredSpec of the current predicate into the code.


C-c C-n
Insert the name of the current predicate into the code. This can be useful when writing recursive predicates or predicates with several clauses. See also the prolog-electric-dot-flag variable below.


C-c C-v a
Convert all variables in a region to anonymous variables. This can also be done using the Prolog/Transform/All variables to '_' menu entry. See also the prolog-electric-underscore-flag Emacs variable.


C-c ?
Help on predicate. This requires the SICStus info files to be installed. If the SICStus info files are installed in a nonstandard way, you may have to change the Emacs variable prolog-info-predicate-index.