calc: Interactive Lisp Functions
18.5.7.2 Interactive Functions
..............................
The functions described here are used in implementing interactive Calc
commands. Note that this list is not exhaustive! If there is an
existing command that behaves similarly to the one you want to define,
you may find helpful tricks by checking the source code for that
command.
-- Function: calc-set-command-flag flag
Set the command flag FLAG. This is generally a Lisp symbol, but
may in fact be anything. The effect is to add FLAG to the list
stored in the variable ‘calc-command-flags’, unless it is already
there. Defining Simple Commands.
-- Function: calc-clear-command-flag flag
If FLAG appears among the list of currently-set command flags,
remove it from that list.
-- Function: calc-record-undo rec
Add the “undo record” REC to the list of steps to take if the
current operation should need to be undone. Stack push and pop
functions automatically call ‘calc-record-undo’, so the kinds of
undo records you might need to create take the form ‘(set SYM
VALUE)’, which says that the Lisp variable SYM was changed and had
previously contained VALUE; ‘(store VAR VALUE)’ which says that the
Calc variable VAR (a string which is the name of the symbol that
contains the variable’s value) was stored and its previous value
was VALUE (either a Calc data object, or ‘nil’ if the variable was
previously void); or ‘(eval UNDO REDO ARGS ...)’, which means that
to undo requires calling the function ‘(UNDO ARGS ...)’ and, if the
undo is later redone, calling ‘(REDO ARGS ...)’.
-- Function: calc-record-why msg args
Record the error or warning message MSG, which is normally a
string. This message will be replayed if the user types ‘w’
(‘calc-why’); if the message string begins with a ‘*’, it is
considered important enough to display even if the user doesn’t
type ‘w’. If one or more ARGS are present, the displayed message
will be of the form, ‘MSG: ARG1, ARG2, ...’, where the arguments
are formatted on the assumption that they are either strings or
Calc objects of some sort. If MSG is a symbol, it is the name of a
Calc predicate (such as ‘integerp’ or ‘numvecp’) which the
arguments did not satisfy; it is expanded to a suitable string such
as “Expected an integer.” The ‘reject-arg’ function calls
‘calc-record-why’ automatically; Predicates.
-- Function: calc-is-inverse
This predicate returns true if the current command is inverse,
i.e., if the Inverse (‘I’ key) flag was set.
-- Function: calc-is-hyperbolic
This predicate is the analogous function for the ‘H’ key.