Lispworks, of course, allows multiple "green" threads, and they have a convenient function already written that forks a listener running on a socket. I leveraged this to implement what I call "lwclient".
Put this in your $HOME/.lispworks:
;; Arrange for LW to start a Listener server once multiprocessing gets going.
;; Used by lwclient.
(push (list "start-lwserver"
nil
(lambda ()
(comm:start-up-server :service 65000
:address "localhost"
:process-name "lwserver")))
mp:*initial-processes*)
And put this in $HOME/bin/lwclient:
(Later I'll rewrite lwclient in actual Lisp, using the lw-console command I mentioned here.)#!/usr/bin/zsh(
echo "lwclient$RANDOM"
echo "(progn "
for f in "$@" ; do
if [[ $f = /* ]] ; then
echo "(editor:find-file-command nil #p\"$f\")"
else
echo "(editor:find-file-command nil #p\"$PWD/$f\")"
fi
done
echo ")"
) \
| nc -q 1 localhost 65000 \
> /dev/null
I even aliased "vi" to call "lwclient" instead:
function vi {
lwclient "$@"
}Usage example:lwclient some_file# or using my above alias
vi some_file
To use this, the Lispworks IDE has to be running, of course, and (at the moment) you need netcat (the "nc" command).
To invoke the real "vi", use "vim" (or whatever editor you used to use).
Caveat: If you ssh to your machine (and LW is already running there), use "vim" to run the real vim, otherwise Lispworks will happily pop up a window on your remote machine and your shell will look like this:
and you'll smack yourself on the forehead and get a concussion.% vi some_file
%
And, in case you're a total neophyte, I'll also point out Caveat 2: This allows anyone with an account on your machine to run arbitrary code under your ID. Use with caution.
Update 6/20/07: See here for an updated version of lwclient.
Great, works fine (linux, lw 5.0.2)