Repeating Queries under Gnu Emacs

For example, suppose you made a typing error, as shown below. If you typed ^x ^e, Prolog would duplicate the line. You could then correct the typing error using Emacs editing commands and resubmit the query.

     | ?- parts_of(transmission, X).
     | ?- ^x^e

When you type ^x ^e, the last input string you typed is displayed in the mini-buffer:

      | ?- parts_of(transmission, X).

At this point you have two options. You can edit the query in the mini-buffer and place it in the prolog window by hitting <RET>; hitting <RET> again submits the query to prolog. Alternatively, you can step through the queries submitted to Prolog by typing <ESC> p (<ESC> n moves you down this list). 1

Under GNU Emacs it is also possible to search through the goal history for a goal matching a regular expression. To do so, type ^x ^y and you will be prompted for a regular expression. On entering a regular expression and hitting <RET>, the most recently submitted goal matching the regular expression will be displayed in the mini-buffer. You can choose to submit this query to prolog (after editing it in the mini-buffer if you choose to) or locate the next most recent goal matching the pattern.

Alternatively, you can redisplay an earlier input string by moving the cursor to the line you want to copy and then type ^x ^e.


  1. You can move around a multi-line query using the ^n and ^p keys.