## Slime REPL Hook

Please note:

You need to enable this mode manually by uncommenting this line in `eql-start-swank.lisp` in your Slime directory:
`(setf eql:*slime-mode* :repl-hook)`

Requires ECL threads.

This should work with any Slime version that plays together with ECL.
Tested with ECL 12.7.1 (Windows: ECL 12.12.1)

### Prepare

- Add to your `~/.emacs` file:

      (add-to-list 'load-path "~/slime/")         ; slime path
      (add-to-list 'load-path "~/slime/contrib/") ; slime/contrib path
      (require 'slime)
      (slime-require 'swank-listener-hooks)
      (slime-setup '(slime-fancy))

- Add to your `~/.swank.lisp` file (or copy file `eql/slime/.swank.lisp` in your home directory):
  (Please note: this isn't really optional -- you need to set this option for a useful Slime + EQL.)

      (setf swank:*globally-redirect-io* t) ; print output in Emacs

- Copy file `eql/slime/eql-start-swank.lisp` in your `slime/` directory

### Run

- Run the swank server (the command line option `-slime` can be omitted if the file name contains "start-swank"), optionally passing a Lisp file:

      eql <path-to-slime>/eql-start-swank.lisp [file.lisp]

- Run Emacs and do: `Meta-X slime-connect` (please note: use `slime-connect`) and hit `Return` 2 times (confirming the default values).

  Please note: if `:dont-close` is set to `T` in `eql-start-swank.lisp`, quitting/restarting Emacs will not affect a running EQL program, that is: if you quit/restart Emacs, you can connect to the same swank/EQL you left when quitting Emacs.

### Notes

#### Eval Region

- Load your Lisp file from the Slime REPL: `(load "file.lisp")`
- Run your program from the Slime REPL (not using Eval Region).
- Only at this point you may use Eval Region for re-defining functions etc.

The point here is: if you directly try to Eval Region an expression containing an EQL function, your swank server will crash, because it will not be evaluated in the GUI thread (Qt GUI methods need to be called from the GUI thread).

So, only run EQL functions directly from the Slime REPL.
If you want to use Eval Region containing EQL functions, use the method described above.

You may use the macro `qeval` if you want to ensure evaluation in the GUI thread (this is meant to be used together with Eval Region only).
It behaves like a `progn`, so you can do something like this:

    (qeval
      (defvar *label* (qnew "QLabel"))
      (defvar *edit*  (qnew "QLineEdit")))

Wrapping forms in `qeval` will have no effect if you run your code outside of Slime (so there's no need to remove `qeval` in your final program).

But note: the advantage using Eval Region (without `qeval`) is that Lisp error conditions (not driven by Qt events) will not stop/pause your EQL program (that is, Qt event processing will continue).

Instead, if there is an error in code you either enter in the Slime REPL, or run with Eval Region wrapped in `qeval`, the program will always pause (Qt event processing will be stopped until you take some action).

#### Abort / Restart

Be careful after entering the Slime debugger. If you see this:
`[ABORT] Return to SLIME's top level.`
`[RESTART-QT-EVENTS] Last resort only - prefer "Return to SLIME's top level"`
Always choose the first one, otherwise you'll be stuck.

#### Help

For help see the `qapropos` and `qgui` functions.