A keyword naming the command.
A keyword naming an alias for the command.
A destructuring lambda list.
One of the symbols values
, eval
and nil
.
The macro define-top-loop-command
defines a top level loop command called name which takes the parameters specified by lambda-list. If &whole
is used in lambda-list then the variable will be bound to a list containing the whole command line, including the command name, but the command name is not included in lambda-list otherwise.
If any aliases are specified in option, these keywords will also invoke the command.
When the command is used, each form is evaluated in sequence with the variables from lambda-list bound to the subsequent forms on the command line.
If result-type is values
(the default), then the values of the last form will be returned to the top level loop.
If result-type is eval
, then the value of the last form should be a form and is evaluated by the top level loop as if it had been entered at the prompt.
If result-type is nil
, then the last form should return two values. If the second value is nil
then the first value is treated as a list of values to returned to the top level loop. If the second value is non-nil then the first value should be a form and is evaluated by the top level loop as if it had been entered at the prompt.
(define-top-loop-command (:lave
(:result-type eval)) (form)
(reverse form))
:lave (1 2 list)
will evaluate the form (list 2 1)
.
Here are definitions for two commands both of which will run apropos:
(define-top-loop-command (:apropos-eval
(:result-type eval))
(&rest args)
`(apropos ,@args))
(define-top-loop-command :apropos-noeval (&rest args)
(apply 'apropos args))
The first one will evaluate the arguments before calling apropos whereas the second one will just pass the forms, so
:apropos-noeval foo
will find all the symbols containing the string foo
, whereas
(setq foo "bar")
:apropos-eval foo
LispWorks User Guide and Reference Manual - 20 Sep 2017