In other languages: [[gschem repl.ru|Russian]]

====== Using REPL in gschem ======
===== Embedded graphical REPL functions in gschem =====
The entry field for guile procedures is opened with hitting the
key <key>:</key> (colon). After doing this the user may enter
commands in the appeared field and watch the results of their work
in the gschem log window.

===== REPL in the background terminal =====
In the current version of the geda-gaf repository (as of
09.02.2016) there is an additional menu entry for working with
REPL in the background terminal, which is invoked with hitting
key sequence <key>f</key><key>Shift-r</key>.

Please note, that for the moment you can run it several times,
which may confuse your terminal. Moreover, there is a risk of
closing working instance of gschem by using some shortkeys.

For more convenient work in the terminal you may want to turn on
the functions of the //readline// library. For that, type in the
terminal:
<code>
(use-modules (ice-9 readline))
(activate-readline)
</code>

===== External graphical REPL =====
For invoking external graphical REPL window you have to have a
REPL functions library from the //guile-gnome//. In Debian, for
instance, you have to install the package //guile-gnome2-gtk//
to may use it. To open the window, type in the field of the
embedded REPL in gschem as follows:
<code>
(use-modules (gnome-2) (gnome gtk) (gnome gtk graphical-repl))
(guile-gtk-repl)
</code>

===== REPL in any terminal =====
In order to invoke REPL in a terminal you have to open a REPL
socket in gschem. To do so, load the system REPL module and call
the function of server spawning:
<code>
(use-modules (system repl server))
(spawn-server)
</code>

When called without arguments, the spawn-server function uses the
default guile port 37146. You can define another port:
<code>
(spawn-server 1234)
</code>

When you're opening a port, please note the security risks described
[[https://lists.gnu.org/archive/html/guile-devel/2010-10/msg00044.html|here]].

Then you just need to connect to the port using any program which
is able to do this, for example,
 **telnet**,
**netcat**, or some other. Example of using **telnet**:
<code>
$ telnet localhost 37146
</code>

Example of using **netcat**:

<code>
$ nc localhost 37146
</code>

In this case the  //readline// interface won't work.

**Emacs** users may use a shiny //Geiser// environment for working
with REPL in that program.
For that to work, you have to install this package, run the REPL
server in gschem and connect to it in **Emacs** using  <key>M-x</key>
**''connect-to-guile''**.