NextPrevUpTopContentsIndex

define-top-loop-command

Macro
Summary

Defines a top level loop command.

Package

system

Signature

define-top-loop-command name-and-options lambda-list form*

name-and-options ::= name

| ( name option* )

option ::= (:aliases alias* )

| (:result-type result-type )

Arguments

name

A keyword naming the command.

alias

A keyword naming an alias for the command.

lambda-list

A destructuring lambda list.

result-type

One of the symbols values , eval and nil .

Description

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.

Note: for details of pre-defined top level loop commands, enter :? at the Listener prompt.

Example

Given this definition:

(define-top-loop-command (:lave 
                          (:result-type eval)) (form)
  (reverse form))

then the command line

: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

will find all the symbols containing the string bar .


LispWorks Reference Manual - 23 Jul 2004

NextPrevUpTopContentsIndex