Next: Error Messages, Previous: Prefix Arguments, Up: Introduction [Contents][Index]

### 3.8 Undoing Mistakes

The shift-`U` key (`calc-undo`) undoes the most recent operation. If that operation added or dropped objects from the stack, those objects are removed or restored. If it was a “store” operation, you are queried whether or not to restore the variable to its original value. The `U` key may be pressed any number of times to undo successively farther back in time; with a numeric prefix argument it undoes a specified number of operations. When the Calculator is quit, as with the `q` (`calc-quit`) command, the undo history will be truncated to the length of the customizable variable `calc-undo-length` (see Customizing Calc), which by default is ‘`100`’. (Recall that `C-x * c` is synonymous with `calc-quit` while inside the Calculator; this also truncates the undo history.)

Currently the mode-setting commands (like `calc-precision`) are not undoable. You can undo past a point where you changed a mode, but you will need to reset the mode yourself.

The shift-`D` key (`calc-redo`) redoes an operation that was mistakenly undone. Pressing `U` with a negative prefix argument is equivalent to executing `calc-redo`. You can redo any number of times, up to the number of recent consecutive undo commands. Redo information is cleared whenever you give any command that adds new undo information, i.e., if you undo, then enter a number on the stack or make any other change, then it will be too late to redo.

The `M-RET` key (`calc-last-args`) is like undo in that it restores the arguments of the most recent command onto the stack; however, it does not remove the result of that command. Given a numeric prefix argument, this command applies to the ‘`n`’th most recent command which removed items from the stack; it pushes those items back onto the stack.

The `K` (`calc-keep-args`) command provides a related function to `M-RET`. See Stack and Trail.

It is also possible to recall previous results or inputs using the trail. See Trail Commands.

The standard Emacs `C-_` undo key is recognized as a synonym for `U`.

Next: Error Messages, Previous: Prefix Arguments, Up: Introduction [Contents][Index]