From: Peder O. Klingenberg
Subject: Commands in the cmucl repl
Date: 
Message-ID: <ujuk7ahm9ro.fsf@nfsd.linpro.no>
Hi.

When I was first introduced CL professionally a few years ago, I used
Allegro.  I got used to doing shortcuts in the REPL to compile, load,
change directories, etc.

I haven't had the opportunity to work with Allegro for quite some
time, and I miss that feature.

Last night in a fit of boredom I figured I'd write my own REPL for
cmucl, which would have this.  After a few minutes investigating, I
discovered that the existing %TOP-LEVEL function in cmucl already had
some hooks that looked suitable for my needs.  So instead of writing
a substitute REPL, I just implemented the missing functions.

I can now do things like
  * :cd lisp
  * :load foo.lisp
  * :load "bar.lisp"
  * :quit
instead of 
  * (setf (default-directory) "lisp")
and the other obvious lisp-counterparts.  This mirrors my vague 
memories of how I did things in Allegro.

The code implements two functions that are already called by the cmucl
toplevel if they exist: CL::COMMANDP and
CL::INVOKE-COMMAND-INTERACTIVE.  Additionally, it defines
EXT:DEF-COMMAND and EXT:DEF-COMMAND-ALIAS as interface macros to
define new commands.  Command names can be either strings or symbols.
If they are defined using strings, the string is read from using
read-from-string and converted back to a string to make sure it is in
the right *readtable-case*.  Much of the code is more or less copied
from cmucls own debug.lisp.

Note, arguments to commands are weird.  Instead of a normal lamda
list, def-command takes a boolean.  If non-nil, the rest of the
command line is read into a string, and the parsing left to the
function.  The reason for this was that I wanted to be able to pass
unquoted strings to commands, so my initial impulse to loop over a
lambda list calling (read) would fail.

An unfortunate side-effect is that if you fail to pass arguments to a
command that expects them, the call to read-line will wait for input
on the next line.  I haven't found out how to do
read-rest-of-line-if-it's-there-otherwise-don't-bother in an elegant
way.  Clues are welcome.

I googled and read through the cmucl website without finding any other
implementations of these hooks in the cmucl toplevel, so in the hope
that someone other than me finds this useful, the code is available at
<http://www.stud.ifi.uio.no/~pok/download/commands.lisp>.

Does anyone know if the hooks are there for some purpose?  Is there a
plan to implement some standard functionality through them?  Will my
hack stop working RSN as the real versions of commandp and
invoke-command-interactive are defined?

...Peder...
-- 
This must be Thursday.  I never could get the hang of Thursdays.

From: Simon András
Subject: Re: Commands in the cmucl repl
Date: 
Message-ID: <vcdisq1cbup.fsf@proof.math.bme.hu>
·····@news.klingenberg.no (Peder O. Klingenberg) writes:

> Hi.
> 
> When I was first introduced CL professionally a few years ago, I used
> Allegro.  I got used to doing shortcuts in the REPL to compile, load,
> change directories, etc.
> 
> I haven't had the opportunity to work with Allegro for quite some
> time, and I miss that feature.

http://users.actrix.co.nz/mycroft/toplevel/ may be just what you need.

Andras
From: Peder O. Klingenberg
Subject: Re: Commands in the cmucl repl
Date: 
Message-ID: <ujufzl5m38b.fsf@nfsd.linpro.no>
······@math.bme.hu (Simon Andr�s) writes:

> http://users.actrix.co.nz/mycroft/toplevel/ may be just what you need.

Thanks, I'll have a look.  But I'm actually quite happy with my own
little hack, so I don't _need_ it anymore. :)

...Peder...
-- 
This must be Thursday.  I never could get the hang of Thursdays.