How to reboot and restart in SLIME in development

I started using emacs and slime to develop a small service.

I found a way to reload the code after the changes, but I want it to be much more convenient and faster.

Here's how I do it now:

  • 1) run emacs, run the slime, then in slime:

    2) (load "init.lisp"); load some initialization code that is not change

    3) (download "myseervice.lisp"); this contains the code I'm working on

    4) (myservice: start)

    5) At this point, the utility program starts, and I can test it. then I make changes to myseervice.lisp to change it. To change the code to in the new version I do this:

    6) (myservice: stop)

    7) (download "myservice.lisp")

    8) go to 4) to start it again ...


It still works. But do not manually stop, restart and start manually. And there is a lot of output in slime between calls, so it’s not easy to reuse previously entered commands 4) -7).

To have a solution, I started the devhelper package, which should do this for me with only one command, but this does not work:

(defpackage :devhelper (:use :common-lisp :myservice) (:export :start :reload)) (in-package :devhelper) (defun start () (myservice:start)) (defun reload () (myservice:stop) (load "myservice.lisp") ;I think it is not possible to load it here, ;because this module is using the file that it is just loading ;But it does not have to work this way, ;I just like any good solution (myservice:start)) 

And I thought I could do it like this:

  • 1) run emacs, run the slime, then in slime:

    2) (load "init.lisp"); load some initialization code that is not change

    3a) (load "myseervice.lisp"); this contains the code I'm working on

    3b) (download "devhelper.lisp")

    4) (devhelper: start)

    5) At this point, the utility program starts, and I can test it. then I make changes to myseervice.lisp to change it. To change the code to the new version that I dreamed about, I could:

    6) (devhelper: reload)

But it freezes at this point.

And I do not adhere to this devhelper idea, I just want a smoother development cycle.

How to do it? I am very new to all of this, and I'm starting from normal programming;) with an IDE and import.

+4
source share
1 answer

History

Reusing previous commands is not difficult in SLIME / Emacs.

The Mp and Mn commands receive previous or next input. Mr and Ms allows you to search (using regex) for input.

Execution from buffer

Another way is to write commands to a Lisp file, open the file in a buffer, and then you can execute them from there.

Reload

Your reboot idea is fine. You can close the service, download the new code, and start the service again. You must find out why it freezes. You have to debug this. One of the differences between your manual and your encoded version is this: the time between stopping, loading and starting in the encoded version is much shorter. You should check if there are any problems.

More advanced code organization

Usually, when you have several files, it makes sense to use one or more systems to organize the code. It also makes sense if your code is in the files that you use the file compiler to compile the code. This way you get warnings and errors early on. Often in Common Lisp, developers use ASDF as a system tool. Many implementations additionally have their own (with more or less functions).

The system tool provides you with some commands that you can use in the system:

  • load: load compiled or source code if necessary (or forced)
  • compile: if necessary, compile the code (or force)
  • compile and download: compiles and downloads the code if necessary (or forced) ...

It usually produces the smallest number of commands needed to compile or download code. But you can force it to reboot or recompile everything.

Typically, a system may have subsystems. A subsystem may be, for example, a compilation service. If you change the code, save it and the compile and load subsystem. ASDF (or a similar tool) will compile the modified files and load them.

Optional: create your own commands for the system tool, which then stops the running service, compiles / downloads the changes, and then starts the service.

Recommendation:

Get your version, find out why it hangs.

+5
source

All Articles