12.3 Other Operations on Variables

The s e (calc-edit-variable) command edits the stored value of a variable without ever putting that value on the stack or simplifying or evaluating the value. It prompts for the name of the variable to edit. If the variable has no stored value, the editing buffer will start out empty. If the editing buffer is empty when you press C-c C-c to finish, the variable will be made void. See Editing Stack Entries, for a general description of editing.

The s e command is especially useful for creating and editing rewrite rules which are stored in variables. Sometimes these rules contain formulas which must not be evaluated until the rules are actually used. (For example, they may refer to ‘deriv(x,y)’, where x will someday become some expression involving y; if you let Calc evaluate the rule while you are defining it, Calc will replace ‘deriv(x,y)’ with 0 because the formula x does not itself refer to y.) By contrast, recalling the variable, editing with `, and storing will evaluate the variable’s value as a side effect of putting the value on the stack.

There are several special-purpose variable-editing commands that use the s prefix followed by a shifted letter:

s A

Edit AlgSimpRules. See Algebraic Simplifications.

s D

Edit Decls. See Declarations.

s E

Edit EvalRules. See Basic Simplifications.

s F

Edit FitRules. See Curve Fitting.

s G

Edit GenCount. See Solving Equations.

s H

Edit Holidays. See Business Days.

s I

Edit IntegLimit. See Calculus.

s L

Edit LineStyles. See Graphics.

s P

Edit PointStyles. See Graphics.

s R

Edit PlotRejects. See Graphics.

s T

Edit TimeZone. See Time Zones.

s U

Edit Units. See User-Defined Units.

s X

Edit ExtSimpRules. See “Unsafe” Simplifications.

These commands are just versions of s e that use fixed variable names rather than prompting for the variable name.

The s p (calc-permanent-variable) command saves a variable’s value permanently in your Calc init file (the file given by the variable calc-settings-file, typically ~/.emacs.d/calc.el), so that its value will still be available in future Emacs sessions. You can re-execute s p later on to update the saved value, but the only way to remove a saved variable is to edit your calc init file by hand. (See General Mode Commands, for a way to tell Calc to use a different file for the Calc init file.)

If you do not specify the name of a variable to save (i.e., s p RET), all Calc variables with defined values are saved except for the special constants pi, e, i, phi, and gamma; the variables TimeZone and PlotRejects; FitRules, DistribRules, and other built-in rewrite rules; and PlotDatan variables generated by the graphics commands. (You can still save these variables by explicitly naming them in an s p command.)

The s i (calc-insert-variables) command writes the values of all Calc variables into a specified buffer. The variables are written with the prefix var- in the form of Lisp setq commands which store the values in string form. You can place these commands in your Calc init file (or .emacs) if you wish, though in this case it would be easier to use s p RET. (Note that s i omits the same set of variables as s p RET; the difference is that s i will store the variables in any buffer, and it also stores in a more human-readable format.)