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, in this case Emacs will also prompt for a Lisp list of
extra parameters to pass on the command line.
Programs are run and debugged in the normal way, with terminal I/O
*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-linked debugging menu entry. It can also be enabled
by setting the Emacs variable
in ~/.emacs. Both these methods set the Prolog flag
emacs. Its value should be
while loading the code to be debugged and while debugging. If so, then the
debugger will display the source code location of the current goal when
it prompts for a debugger command, by highlighting the current line.
off when the code was loaded, or if it
was asserted or loaded from
user, then the current goal will still be
shown but out of context.
Note that if the code has been modified since it was last loaded, then Prolog’s line number information may be invalid. If this happens, then just reload the relevant buffer.
Another useful feature which is available for code loaded with
source_info switched on is that the debugger can show the
variable bindings for the current goal, its ancestors, and the clauses
they occur in. The bindings are shown in a separate
Bindings* buffer. This is enabled by the C-c C-g command and
disabled by the C-u C-c C-g command.
Yet another feature which is available for compiled code loaded with
source_info switched on is code coverage highlighting
(see Coverage Analysis). Highlighting of the current buffer is
refreshed by the C-c C-o command and cleared by the C-u C-c
Consultation and compilation is either done via the menu or with the following key-bindings:
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:
Go to beginning of clause. Go to the previous clause if already at the beginning.
Go to end of clause. Go to the next clause if already at the end.
Go to beginning of predicate.
Go to end of predicate.
Go to the previous paragraph (i.e. empty line).
Go to the next paragraph (i.e. empty line).
Go to matching right parenthesis.
Go to matching left parenthesis.
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
Enable and disable creeping, respectively.
Enable and disable leaping, respectively.
Enable and disable zipping, respectively.
Enable and disable bindings window, respectively. When enabled, SICStus
will endeavor to show the variable bindings of the clause containing the
current goal. C-c C-g splits the
vertically and inserts the
*Prolog Bindings* window, which shows
the bindings and is updated upon every debugger command. C-u C-c
C-g deletes the
*Prolog Bindings* window.
Set the print depth for the bindings window as well as for the top level. Prompts for an integer value. Equivalent to the < top-level command; see Queries.
Refresh and clear coverage highlighting for the current buffer,
respectively. Lines containing coverage sites (see Coverage Analysis) will be highlighted in face
(defaults to green) if they were hit at least once and made no nondet
calls with the execution profiler switched on; in face
pltrace-face-reached-nondet (defaults to yellow) if they were hit
at least once and made one or more nondet calls with the execution
profiler switched on; otherwise, they will be highlighted in face
pltrace-face-reached-not (defaults to red). Lines not containing
coverage sites are not highlighted.
Set and remove a line breakpoint. This uses the advanced debugger features introduced in release 3.8; see Advanced Debugging.
Insert the PredSpec of the current predicate into the code.
Insert the template of the current predicate (name, parentheses, commas) into the code.
Insert a line break followed by the template 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.
Convert all variables in a region to anonymous variables. See also the
prolog-electric-underscore-flag Emacs variable.
Help on predicate. This requires the SICStus info files to be
installed. If the SICStus info files are installed in a nonstandard
way, then you may have to change the Emacs variable
Run Prolog. With the second variant, Emacs will prompt for a Lisp list of extra parameters to pass on the command line.
Interrupt Prolog. The same as typing ^C in a shell.
Kill Prolog. Immediately kills the process.