Next: , Up: Unit Protocol


18.4.5.1 Motors And Limit Actions

A limit action is a function usually named mumble-limit-action of the signature (mark original-offset remaining-units unit syntax) that is called whenever a general motion function cannot complete the motion. Mark is the mark the object in motion; original-offset is the original offset of the mark, before any motion; remaining-units is the number of units left until the motion would be complete; unit is a string naming the unit; and syntax is the syntax instance passed to the motion function. There is a number of predefined limit actions:

— Function: drei-motion:beep-limit-action mark original-offset remaining unit syntax

This limit action will beep at the user.

— Function: drei-motion:revert-limit-action mark original-offset remaining unit syntax

This limit action will try to restore the mark state from before the attempted action. Note that this will not restore any destructive actions that have been performed, it will only restore the position of mark.

— Condition: drei-motion:motion-limit-error

Class precedence list: motion-limit-error, error, serious-condition, condition, slot-object, t

This error condition signifies that a motion cannot be performed.

— Function: drei-motion:error-limit-action mark original-offset remaining unit syntax

This limit action will signal an error of type motion-limit-error.

A diligent motor is a combination of two motion functions that has the same signature as a standard motion function (see Motion Protocol). The primary motion function is called the motor and the secondary motion function is called the fiddler. When the diligent motor is called, it will start by calling its motor - if the motor cannot carry out its motion, the fiddler will be called, and if the fiddler is capable of performing its motion, the motor will be called again, and if this second motor call also fails, the fiddler will be called yet again, etc. If at any time the call to the fiddler fails, the limit action provided in the call to the diligent motor will be activated. A typical diligent motor is the one used to implement a Backward Lisp Expression command - it attempts to move backwards by a single expression, and if that fails, it tries to move up a level in the expression tree and tries again.

— Function: drei-motion:make-diligent-motor motor fiddler

Create and return a diligent motor with a default limit action of beep-limit-action. motor and fiddler will take turns being called until either motor succeeds or fiddler fails.