I started using emacs and slime to develop some little service.
I have found a way to reload the code after changes but I want this a lot more convenient and faster.
This is how I doo it now:
1) start emacs, start slime, then in slime:
2) (load "init.lisp") ; load some initialisation code that does not change
3) (load "myseervice.lisp"); this containts the code that i am working on
4) (myservice:start)
5) At this point the seeervice is runing and i can test it. then I make changes to myseervice.lisp, to modify it. To swap the code to the new version I do this:
6) (myservice:stop)
7) (load "myservice.lisp")
8) go to 4) to start it again...
This works so far. But it is no fun to manually stop, reload and start. And there is a lot of output in slime between the calls, so it is not easy to reuse the previously typed commands 4)-7).
To have a solution I started a devhelper package which should do this for me in only one command, but it 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 now:
1) start emacs, start slime, then in slime:
2) (load "init.lisp") ; load some initialisation code that does not change
3a) (load "myseervice.lisp"); this containts the code that i am working on
3b) (load "devhelper.lisp")
4) (devhelper:start)
5) At this point the seeervice is runing and i can test it. then I make changes to myseervice.lisp, to modify it. To swap the code to the new version I jussst dreamed I could:
6) (devhelper:reload)
But it freezes at this point.
And I am not sticking to this devhelper idea, I just want a smoother development cycle.
How would a real lisper do it? I am very new to all this and I come from conventional programming background ;) with IDEs and imports.
History
Reusing previous commands is not difficult in SLIME/Emacs.
The commands M-p
and M-n
get the previous or next input. M-r
and M-s
allows you to search (using a regular expression) in the input.
Execution from a buffer
Another way is to write down the commands into a Lisp file, open the file in a buffer and then you can execute them from there.
Reload
Your reload idea is okay. You could shutdown a service, load new code and start the service again. You should find out why it freezes. You should debug that. One of the differences between your manual and your coded version is this: the time between stopping, loading and starting is in the coded version much shorter. You should check if there is some problem.
More advanced organization of code
Typically when you have more than one file it makes sense to use one or more systems to organize the code. Also it makes sense if your code is in files that you use the file compiler to compile your 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 features).
A system tool provides you some commands that you can use on a system:
Usually it will issue the smallest amount of commands necessary to compile or load the code. But you can force it to reload or recompile everything.
Typically a system can have subsystems. A subsystem could for example be a compile service. If you change the code, save it and compile and load
the subsystem. ASDF (or a similar tool) will compile the changed files and load them.
More advanced: write your own commands for the system tool, which then stops a running service, compiles/loads the changes and then starts the service.
Recommendation:
Get your version going, find out why it hangs.