# ^D not longer working after importing pac

**URL:** <https://swi-prolog.discourse.group/t/d-not-longer-working-after-importing-pac/8770>\
**Category:** Help!\
**Created:** [February 4, 2025, 4:55pm UTC](https://swi-prolog.discourse.group/t/d-not-longer-working-after-importing-pac/8770 "2025-02-04T16:55:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Schwidom](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/frank_schwidom/32/7662_2.png) [@Frank\_Schwidom](https://swi-prolog.discourse.group/u/Frank_Schwidom)\
**Post date:** [February 4, 2025, 4:55pm UTC](https://swi-prolog.discourse.group/t/d-not-longer-working-after-importing-pac/8770/1 "2025-02-04T16:55:30Z")

</div>

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

normally this works:

```prolog
$ 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:

```prolog

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

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

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![kuniaki.mukai](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@kuniaki.mukai](https://swi-prolog.discourse.group/u/kuniaki.mukai)\
**Post date:** [February 5, 2025, 6:01am UTC](https://swi-prolog.discourse.group/t/d-not-longer-working-after-importing-pac/8770/2 "2025-02-05T06:01:48Z")

</div>

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

```prolog
% 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.

```prolog
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).

```

---

<div class="post-metadata">

**Author:** ![kuniaki.mukai](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@kuniaki.mukai](https://swi-prolog.discourse.group/u/kuniaki.mukai)\
**Post date:** [February 5, 2025, 12:56pm UTC](https://swi-prolog.discourse.group/t/d-not-longer-working-after-importing-pac/8770/4 "2025-02-05T12:56:11Z")

</div>

After your comment, I have inserted a line for ‘end\_of\_file’ for `halt/0`.

```prolog
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.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [February 5, 2025, 11:41pm UTC](https://swi-prolog.discourse.group/t/d-not-longer-working-after-importing-pac/8770/6 "2025-02-05T23:41:12Z")

</div>

> [@kuniaki.mukai](#):
>
> ```prolog
> expand_query(_, 'end_of_file', _) :- halt.
> 
> ```

Wouldn’t this be better?

```prolog
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.)

---

<div class="post-metadata">

**Author:** ![kuniaki.mukai](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@kuniaki.mukai](https://swi-prolog.discourse.group/u/kuniaki.mukai)\
**Post date:** [February 6, 2025, 2:15am UTC](https://swi-prolog.discourse.group/t/d-not-longer-working-after-importing-pac/8770/7 "2025-02-06T02:15:01Z")

</div>

> [@peter.ludemann](#):
>
> Wouldn’t this be better?
> 
> ```prolog
> expand_query(_, end_of_file, end_of_file) :- !.
> 
> ```

Thanks. It works for both terminal and emacs.

> [@peter.ludemann](#):
>
> (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.)

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

```prolog
% ?- 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.
