^D not longer working after importing pac

swi prolog version: version 9.3.19-13-gc4848cb0b-DIRTY

normally this works:

$ swipl
reading ~/.swiplrc (FS)
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.19-13-gc4848cb0b-DIRTY)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

(ins)?- 

% halt

(halt by ^D)

But when I import pac, then I run into problems:


(ins)?- use_module( library( pac)).
true.

(ins)?-  % ^D here
ERROR: Unknown procedure: end_of_file/0 (DWIM could not correct goal)

Thanks in advance

How about to disable pac query expansion by disable_pac_query/0,
which is all what I could propose for now.

% swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.19-18-gb55bb91c4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

102 ?- use_module(library(pac)).
true.

?- disable_pac_query.
true.

?- ^D
% halt
% 

Probably it is related to the following codes about pac query expansion,
which I borrowed without knowing exactly what '$current_typein_module'(C) does.

user: expand_query(X, Y, Z, Z) :- user:chk_pac_query, !,
	'$current_typein_module'(C),
	pac:expand_query(C, X, Y).
user: expand_query(X, X, Z, Z).

After your comment, I have inserted a line for ‘end_of_file’ for halt/0.

expand_query(_, [], []).
expand_query(_, 'end_of_file', _) :- halt.
expand_query(M, M:[X|Y], M:[X|Y]).
expand_query(M, X, Y) :-
	once(expand_goal(X, M, Y, Z, [])),
	assert_in_user(Z).

In terminal, ^D works for halt. However, in Ediprolog mode in Emacs, ^D works like Delete one character forward. I think I should give up to control ^D due to my little knowledge. Thanks for letting me to learn that ^D means something like end_of_file.

It depends. On windows terminal you use ^Z to
generate a end of file into the input stream.
The predcate get_code/1 will return -1. The
predicate read_term/2 will return end_of_file.

The top-level uses read_term/2 I guess.
Expanding end_of_file to halt is not a good idea.
Because the interpretation of end_of_file is
context dependent. During [user] it means

that nor more clauses are consulted, just like here:

Disclaimer: I don’t know whether pac supports [user] ?

Wouldn’t this be better?

expand_query(_, end_of_file, end_of_file) :- !.

(I don’t know exactly what your expand_query/3 does; but I presume it’s just a transformation of the input, so you don’t want to execute a halt but instead want to leave end_of_file as-is.)

Thanks. It works for both terminal and emacs.

Agree.
One of purpose of expand_query is to run queries which use my macro like this (zip).

% ?- maplist(pred([X,Y,X-Y]), [a,b],[1,2], Z).
%@ Z = [a-1, b-2].

Sometime it is convenient particularly in ediprolog mode when I’m in a hurry to run queries for testing, though I think one should not invent private macros so freely.