I'd like to run the gprolog
interactive interpreter in an Emacs sub-process shell (started with M-x shell
).
The interactive interpret starts without a problem, but it does not respond to some keystrokes as expected.
To illustrate the problem, I first show a simple interaction as it occurs when I run gprolog
in a "top-level shell" (i.e. not one running as a subprocess of Emacs).
(In the excerpts below, please regard the delimiters <<
and >>
as "markup" to indicate the text I type. In the actual interaction, I don't type any <<
or >>
sequences. Neither do I type the ▮
characters, which I'm using only to indicate the position of point
. With the exception of the text enclosed by <<
...>>
and ▮
, all text shown in the excerpts below is produced by gprolog
.)
Staring from top-level shell
First I type the following query:
| ?- <<member(X, [a,b,c]).>>▮
Then I hit the Enter key (shown below as [RET]
):
| ?- <<member(X, [a,b,c]).[RET]>>
X = a ? ▮
Now I hit ; once:
| ?- <<member(X, [a,b,c]).[RET]>>
X = a ? <<;>>
X = b ? ▮
Note that pressing ;
was all that I had to do to elicit the next response from gprolog
.
Finally I hit ; twice more, thereby exhausting the list of remaining results:
| ?- <<member(X, [a,b,c]).[RET]>>
X = a ? <<;>>
X = b ? <<;>>
X = c ? <<;>>
no
| ?- ▮
Staring from Emacs sub-process shell
Next I show what an attempt to run the same interaction in an instance of gprolog
invoked from an Emacs sub-process shell.
Up to this point, it looks the same as before:
| ?- <<member(X, [a,b,c]).[RET]>>
X = a ? ▮
But now, if when I press ;
, the semicolon character gets inserted, but gprolog
does not respond:
| ?- <<member(X, [a,b,c]).[RET]>>
X = a ? <<;>>▮
If now I hit Enter, gprolog
(basically) prints out one more result and terminates the query (prematurely):
| ?- <<member(X, [a,b,c]).[RET]>>
X = a ? <<;[RET]>>
;
X = b ?
yes
| ?- ▮
I encountered a similar problem with swipl
(Swiss-Prolog), but found that starting it with the -tty
flag made it usable under an Emacs sub-process shell (though the interface behaves a little differently).
I did not find anything like swipl
's -tty
flag for gprolog
.
M-x run-prolog
instead ofM-x shell
?