10.3 Listener commands

10.3.1 :REDO

Events can be specified in a number of ways for re-evaluation by the :redo command.

If you type :redo alone, the environment re-evaluates the last expression entered.

Recall from the introductory chapter that if you type

:redo n
the environment re-evaluates the nth event in the history list.

If you type

:redo -n
the environment subtracts the number n from the current prompt number, h, and re-evaluates the event in the history list.

If you type

:redo s
it searches for the symbol s in the history list. If it finds an instance of s, the expression containing it is re-evaluated. If it reaches the first event and has not found s, no re-evaluation can occur.

The following instructions provide examples of the use of these other history mechanisms. To appreciate these examples fully, re-start FreeLisp and enter the following forms:

1. Type (setq x 12) at the prompt, followed by x, then (setq x 2)

By doing so, x has been set to 12, printed out, and then re-set to 2:

CL-USER 1 > (setq x 12)
12

CL-USER 2 > x
12

CL-USER 3 > (setq x 2)
2

CL-USER 4 >

2. Type :redo alone

The environment re-evaluates the previous expression, (setq x 2). This produces the same result as before.

CL-USER 4 > :redo
(SETQ X 2)
2

CL-USER 5 >

3. Type :redo -3

The environment works out that re-evaluation of event 2 is required. This event is x, and so the result of evaluation is 2. Notice that this is different from the result of the original evaluation: x has since changed.

CL-USER 5 > :redo -3
X
2

CL-USER 6 > 

Now, we will search the history list for a symbol.

4. Type :redo setq.

The most recent occurrence of the symbol setq is sought from the history list, and the result of this search is the re-evaluation of the second event, (setq x 2).

CL-USER 6 > :redo setq
(SETQ X 2)
2

CL-USER 7 >

Note: You cannot re-evaluate events with a history number equal to or greater than that of the current prompt, because they do not exist. If you attempt to do this, the environment will report that an error has occurred. An expression or command becomes an event in the history list only after it has been evaluated


FreeLisp User's Guide - 5 FEB 1996

Generated with Harlequin WebMaker