How to set X-server for emacs/0, edit/1 works on terminal

emacs/0, edit/1 works well in Gnu Emacs ediprolog mode. However, they don’t work on terminal with the message attached below. I am not familiar with setting X-server. Is there any tutoroial enough to fix this.

Thank you for help.

  % swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.11-24-g382b43850-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).

?- emacs.
[PCE fatal: @display/display: Failed to connect to X-server at `192.168.86.1:0': No permission to contact X-server?
*********************************************************************
* You MUST be running the X11 Windowing environment.  If you are,   *
* check the setting of your DISPLAY environment variable as well    *
* the access rights to your X11 server.  See xauth(1) and xhost(1). *
*********************************************************************
	in: 	<No exception goal>
]
Host stack:
 [15] pce_principal:send(@emacs_mark_list/emacs_bookmark_editor, append(new(_15504, dialog)))
 [14] Send-method on @emacs_mark_list/emacs_bookmark_editor: emacs_bookmark_editor->initialise
 [13] '$c_call_prolog'
 [12] pce_principal:new(@emacs_mark_list/emacs_bookmark_editor, emacs_bookmark_editor)
 [11] Send-method on @emacs/emacs: emacs->initialise(@emacs_buffers/dict)
% The following threads wouldn't die: [main]

EDIT
I have found a solution on the net, though I don’t understand meaning.

open /Applications/Utilities/XQuartz.app
ssh -Y <user-name>@<host>
export DISPLAY=:0.0

EDIT.
The above “solution” was my illusion. It did not work.

EDIT.
On Emacs.app, This is OK.
M-x shell
swipl
?- emacs.

On terminal. This is not OK.
emacs
M-x shell
swipl
?- emacs.
(The same error message)

EDIT.
This works ! Put the one line just before the swipl command.

% export DISPLAY=:0.0
% swipl
?- emacs.
1 Like