Running SICStus Prolog Under Emacs

You do not have to set up anything special in your .emacs file.  In fact, you should make sure that there is nothing in your .emacs file (perhaps left over from a previous class) that refers to Prolog.  However, you should put the following line as the first line of any prolog file:

% -*-prolog-*-
This tells emacs that that the file contains prolog code and should be edited in prolog mode.  When you start a new prolog file you  should put this line in the file, then exit emacs, then restart it and re-open the file.  You can also manually switch to prolog mode with the command Esc-X prolog-mode <RETURN>.  (I.e., hit escape-key x p r o l o g - m o d e return-key.)

To run prolog give emacs the command Esc-X run-prolog<RETURN>

In the emacs buffer where prolog is running, the following special keys are useful:

send the current line to prolog
ctl-c ctl-u
erase back to the prolog prompt
ctl-c ctl-p
move back to previous input sent to prolog
ctl-c ctl-c
interrupt prolog (like a single ctl-c when not running under emacs)
ctl-h m
show a complete list of keys with special meaning in this buffer

To read your code into prolog,        [farmer].

       to the prolog prompt (note the period at the end!). followed by a RETURN.


In prolog, single-stepping is called "tracing" and a breakpoint is called a "spy point".

Here is a an example debugging session.