calc: Basic Commands
4.1 Basic Commands
==================
To start the Calculator in its standard interface, type ‘M-x calc’. By
default this creates a pair of small windows, ‘*Calculator*’ and ‘*Calc
Trail*’. The former displays the contents of the Calculator stack and
is manipulated exclusively through Calc commands. It is possible
(though not usually necessary) to create several Calc mode buffers each
of which has an independent stack, undo list, and mode settings. There
is exactly one Calc Trail buffer; it records a list of the results of
all calculations that have been done. The Calc Trail buffer uses a
variant of Calc mode, so Calculator commands still work when the trail
buffer’s window is selected. It is possible to turn the trail window
off, but the ‘*Calc Trail*’ buffer itself still exists and is updated
silently. Trail Commands.
In most installations, the ‘C-x * c’ key sequence is a more
convenient way to start the Calculator. Also, ‘C-x * *’ is a synonym
for ‘C-x * c’ unless you last used Calc in its Keypad mode.
Most Calc commands use one or two keystrokes. Lower- and upper-case
letters are distinct. Commands may also be entered in full ‘M-x’ form;
for some commands this is the only form. As a convenience, the ‘x’ key
(‘calc-execute-extended-command’) is like ‘M-x’ except that it enters
the initial string ‘calc-’ for you. For example, the following key
sequences are equivalent: ‘S’, ‘M-x calc-sin <RET>’, ‘x sin <RET>’.
Although Calc is designed to be used from the keyboard, some of
Calc’s more common commands are available from a menu. In the menu, the
arguments to the functions are given by referring to their stack level
numbers.
The Calculator exists in many parts. When you type ‘C-x * c’, the
Emacs “auto-load” mechanism will bring in only the first part, which
contains the basic arithmetic functions. The other parts will be
auto-loaded the first time you use the more advanced commands like trig
functions or matrix operations. This is done to improve the response
time of the Calculator in the common case when all you need to do is a
little arithmetic. If for some reason the Calculator fails to load an
extension module automatically, you can force it to load all the
extensions by using the ‘C-x * L’ (‘calc-load-everything’) command.
Mode Settings.
If you type ‘M-x calc’ or ‘C-x * c’ with any numeric prefix argument,
the Calculator is loaded if necessary, but it is not actually started.
If the argument is positive, the ‘calc-ext’ extensions are also loaded
if necessary. User-written Lisp code that wishes to make use of Calc’s
arithmetic routines can use ‘(calc 0)’ or ‘(calc 1)’ to auto-load the
Calculator.
If you type ‘C-x * b’, then next time you use ‘C-x * c’ you will get
a Calculator that uses the full height of the Emacs screen. When
full-screen mode is on, ‘C-x * c’ runs the ‘full-calc’ command instead
of ‘calc’. From the Unix shell you can type ‘emacs -f full-calc’ to
start a new Emacs specifically for use as a calculator. When Calc is
started from the Emacs command line like this, Calc’s normal “quit”
commands actually quit Emacs itself.
The ‘C-x * o’ command is like ‘C-x * c’ except that the Calc window
is not actually selected. If you are already in the Calc window, ‘C-x *
o’ switches you out of it. (The regular Emacs ‘C-x o’ command would
also work for this, but it has a tendency to drop you into the Calc
Trail window instead, which ‘C-x * o’ takes care not to do.)
For one quick calculation, you can type ‘C-x * q’ (‘quick-calc’)
which prompts you for a formula (like ‘2+3/4’). The result is displayed
at the bottom of the Emacs screen without ever creating any special
Calculator windows. Quick Calculator.
Finally, if you are using the X window system you may want to try
‘C-x * k’ (‘calc-keypad’) which runs Calc with a “calculator keypad”
picture as well as a stack display. Click on the keys with the mouse to
operate the calculator. Keypad Mode.
The ‘q’ key (‘calc-quit’) exits Calc mode and closes the Calculator’s
window(s). It does not delete the Calculator buffers. If you type ‘M-x
calc’ again, the Calculator will reappear with the contents of the stack
intact. Typing ‘C-x * c’ or ‘C-x * *’ again from inside the Calculator
buffer is equivalent to executing ‘calc-quit’; you can think of ‘C-x *
*’ as toggling the Calculator on and off.
The ‘C-x * x’ command also turns the Calculator off, no matter which
user interface (standard, Keypad, or Embedded) is currently active. It
also cancels ‘calc-edit’ mode if used from there.
The ‘d <SPC>’ key sequence (‘calc-refresh’) redraws the contents of
the Calculator buffer from memory. Use this if the contents of the
buffer have been damaged somehow.
The ‘o’ key (‘calc-realign’) moves the cursor back to its “home”
position at the bottom of the Calculator buffer.
The ‘<’ and ‘>’ keys are bound to ‘calc-scroll-left’ and
‘calc-scroll-right’. These are just like the normal horizontal
scrolling commands except that they scroll one half-screen at a time by
default. (Calc formats its output to fit within the bounds of the
window whenever it can.)
The ‘{’ and ‘}’ keys are bound to ‘calc-scroll-down’ and
‘calc-scroll-up’. They scroll up or down by one-half the height of the
Calc window.
The ‘C-x * 0’ command (‘calc-reset’; that’s ‘C-x *’ followed by a
zero) resets the Calculator to its initial state. This clears the
stack, resets all the modes to their initial values (the values that
were saved with ‘m m’ (‘calc-save-modes’)), clears the caches (
Caches), and so on. (It does _not_ erase the values of any
variables.) With an argument of 0, Calc will be reset to its default
state; namely, the modes will be given their default values. With a
positive prefix argument, ‘C-x * 0’ preserves the contents of the stack
but resets everything else to its initial state; with a negative prefix
argument, ‘C-x * 0’ preserves the contents of the stack but resets
everything else to its default state.