]> code.delx.au - gnu-emacs/blobdiff - man/calc.texi
(byte-compile-lambda): Add parameter add-lambda.
[gnu-emacs] / man / calc.texi
index 97f06047773bc19f46957a0849331e1de5953b5b..6e397a0052c8fa5f952959b83211963c4b280e81 100644 (file)
 @copying
 This file documents Calc, the GNU Emacs calculator.
 
-Copyright (C) 1990, 1991, 2001, 2002, 2005 Free Software Foundation, Inc.
+Copyright (C) 1990, 1991, 2001, 2002, 2003, 2004,
+   2005 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.1 or
+under the terms of the GNU Free Documentation License, Version 1.2 or
 any later version published by the Free Software Foundation; with the
 Invariant Sections being just ``GNU GENERAL PUBLIC LICENSE'', with the
 Front-Cover texts being ``A GNU Manual,'' and with the Back-Cover
@@ -118,8 +119,8 @@ Software Foundation raise funds for GNU development.''
 @page
 
 @vskip 0pt plus 1filll
-Copyright @copyright{} 1990, 1991, 2001, 2002, 2005
-Free Software Foundation, Inc.
+Copyright @copyright{} 1990, 1991, 2001, 2002, 2003, 2004,
+   2005 Free Software Foundation, Inc.
 @insertcopying
 @end titlepage
 
@@ -162,6 +163,7 @@ longer Info tutorial.)
 * Store and Recall::      Storing and recalling variables.
 * Graphics::              Commands for making graphs of data.
 * Kill and Yank::         Moving data into and out of Calc.
+* Keypad Mode::           Operating Calc from a keypad.
 * Embedded Mode::         Working with formulas embedded in a file.
 * Programming::           Calc as a programmable calculator.
 
@@ -186,7 +188,7 @@ longer Info tutorial.)
 
 @display
 Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
-59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
+51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.
@@ -532,7 +534,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 @end smallexample
 
 Also add information on how to contact you by electronic and paper mail.
@@ -582,8 +584,8 @@ and what are the various ways that it can be used.
 * What is Calc::
 * About This Manual::
 * Notations Used in This Manual::
-* Using Calc::
 * Demonstration of Calc::
+* Using Calc::
 * History and Acknowledgements::
 @end menu
 
@@ -763,7 +765,7 @@ regularly using Emacs.
 (If you don't have the @key{LFD} or @key{TAB} keys on your keyboard,
 the @kbd{C-j} and @kbd{C-i} keys are equivalent to them, respectively.
 If you don't have a Meta key, look for Alt or Extend Char.  You can
-also press @key{ESC} or @key{C-[} first to get the same effect, so
+also press @key{ESC} or @kbd{C-[} first to get the same effect, so
 that @kbd{M-x}, @kbd{@key{ESC} x}, and @kbd{C-[ x} are all equivalent.)
 
 Sometimes the @key{RET} key is not shown when it is ``obvious''
@@ -796,7 +798,8 @@ Tutorial.
 
 To begin, start Emacs if necessary (usually the command @code{emacs}
 does this), and type @kbd{M-# c} (or @kbd{@key{ESC} # c}) to start the
-Calculator.  (@xref{Starting Calc}, if this doesn't work for you.)
+Calculator.  (You can also use @kbd{M-x calc} if this doesn't work.
+@xref{Starting Calc}, for various ways of starting the Calculator.)
 
 Be sure to type all the sample input exactly, especially noting the
 difference between lower-case and upper-case letters.  Remember,
@@ -986,11 +989,15 @@ don't even have an @key{ESC} key, you can fake it by holding down
 Control or @key{CTRL} while typing a left square bracket
 (that's @kbd{C-[} in Emacs notation).
 
-@kbd{M-#} is a @dfn{prefix key}; when you press it, Emacs waits for
-you to press a second key to complete the command.  In this case,
-you will follow @kbd{M-#} with a letter (upper- or lower-case, it
-doesn't matter for @kbd{M-#}) that says which Calc interface you
-want to use.
+The key @kbd{M-#} is bound to the command @code{calc-dispatch}, 
+which can be rebound if convenient.  
+(@xref{Key Bindings,,Customizing Key Bindings,emacs,
+The GNU Emacs Manual}.)
+
+When you press @kbd{M-#}, Emacs waits for you to press a second key to
+complete the command.  In this case, you will follow @kbd{M-#} with a
+letter (upper- or lower-case, it doesn't matter for @kbd{M-#}) that says
+which Calc interface you want to use.
 
 To get Calc's standard interface, type @kbd{M-# c}.  To get
 Keypad mode, type @kbd{M-# k}.  Type @kbd{M-# ?} to get a brief
@@ -1028,7 +1035,7 @@ with the file you were editing on top and Calc on the bottom.
 
 ...
 --**-Emacs: myfile             (Fundamental)----All----------------------
---- Emacs Calculator Mode ---                   |Emacs Calc Mode v2.00...
+--- Emacs Calculator Mode ---                   |Emacs Calc Mode v2....
 2:  17.3                                        |    17.3
 1:  -5                                          |    3
     .                                           |    2
@@ -1149,28 +1156,30 @@ Stack; the lower window is a picture of a typical calculator keypad.
 \medskip
 @end tex
 @smallexample
-                                        |--- Emacs Calculator Mode ---
-                                        |2:  17.3
-                                        |1:  -5
-                                        |    .
-                                        |--%%-Calc: 12 Deg       (Calcul
-                                        |----+-----Calc 2.00-----+----1
-                                        |FLR |CEIL|RND |TRNC|CLN2|FLT |
-                                        |----+----+----+----+----+----|
-                                        | LN |EXP |    |ABS |IDIV|MOD |
-                                        |----+----+----+----+----+----|
-                                        |SIN |COS |TAN |SQRT|y^x |1/x |
-                                        |----+----+----+----+----+----|
-                                        |  ENTER  |+/- |EEX |UNDO| <- |
-                                        |-----+---+-+--+--+-+---++----|
-                                        | INV |  7  |  8  |  9  |  /  |
-                                        |-----+-----+-----+-----+-----|
-                                        | HYP |  4  |  5  |  6  |  *  |
-                                        |-----+-----+-----+-----+-----|
-                                        |EXEC |  1  |  2  |  3  |  -  |
-                                        |-----+-----+-----+-----+-----|
-                                        | OFF |  0  |  .  | PI  |  +  |
-                                        |-----+-----+-----+-----+-----+
+@group
+|--- Emacs Calculator Mode ---
+|2:  17.3
+|1:  -5
+|    .
+|--%%-Calc: 12 Deg       (Calcul
+|----+-----Calc 2.1------+----1
+|FLR |CEIL|RND |TRNC|CLN2|FLT |
+|----+----+----+----+----+----|
+| LN |EXP |    |ABS |IDIV|MOD |
+|----+----+----+----+----+----|
+|SIN |COS |TAN |SQRT|y^x |1/x |
+|----+----+----+----+----+----|
+|  ENTER  |+/- |EEX |UNDO| <- |
+|-----+---+-+--+--+-+---++----|
+| INV |  7  |  8  |  9  |  /  |
+|-----+-----+-----+-----+-----|
+| HYP |  4  |  5  |  6  |  *  |
+|-----+-----+-----+-----+-----|
+|EXEC |  1  |  2  |  3  |  -  |
+|-----+-----+-----+-----+-----|
+| OFF |  0  |  .  | PI  |  +  |
+|-----+-----+-----+-----+-----+
+@end group
 @end smallexample
 
 Keypad mode is much easier for beginners to learn, because there
@@ -1332,9 +1341,7 @@ righthand label:  Type @kbd{d @} (1) @key{RET}}.
 @end smallexample
 
 To leave Embedded mode, type @kbd{M-# e} again.  The mode line
-and keyboard will revert to the way they were before.  (If you have
-actually been trying this as you read along, you'll want to press
-@kbd{M-# 0} [with the digit zero] now to reset the modes you changed.)
+and keyboard will revert to the way they were before.
 
 The related command @kbd{M-# w} operates on a single word, which
 generally means a single number, inside text.  It uses any
@@ -1517,8 +1524,7 @@ and record them as the current keyboard macro.
 
 @item 0
 (This is the ``zero'' digit key.)  Reset the Calculator to
-its default state:  Empty stack, and default mode settings.
-With any prefix argument, reset everything but the stack.
+its initial state:  Empty stack, and initial mode settings.
 @end table
 
 @node History and Acknowledgements, , Using Calc, Getting Started
@@ -1586,7 +1592,7 @@ Many people have contributed to Calc by reporting bugs and suggesting
 features, large and small.  A few deserve special mention:  Tim Peters,
 who helped develop the ideas that led to the selection commands, rewrite
 rules, and many other algebra features; 
-@texline Fran\c cois
+@texline Fran\c{c}ois
 @infoline Francois
 Pinard, who contributed an early prototype of the Calc Summary appendix
 as well as providing valuable suggestions in many other areas of Calc;
@@ -4309,8 +4315,8 @@ even @kbd{V R x max @key{RET}} if you had preferred.)
 
 If your system has the GNUPLOT program, you can see graphs of your
 data and your straight line to see how well they match.  (If you have
-GNUPLOT 3.0, the following instructions will work regardless of the
-kind of display you have.  Some GNUPLOT 2.0, non-X-windows systems
+GNUPLOT 3.0 or higher, the following instructions will work regardless
+of the kind of display you have.  Some GNUPLOT 2.0, non-X-windows systems
 may require additional steps to view the graphs.)
 
 Let's start by plotting the original data.  Recall the ``@var{x}'' and ``@var{y}''
@@ -10010,7 +10016,6 @@ numeric entry, undo, numeric prefix arguments, etc.
 * Numeric Entry::
 * Algebraic Entry::
 * Quick Calculator::
-* Keypad Mode::
 * Prefix Arguments::
 * Undo::
 * Error Messages::
@@ -12812,7 +12817,9 @@ If you press @kbd{m v} with a numeric prefix argument @var{n}, you
 get a special ``dimensioned'' Matrix mode in which matrices of
 unknown size are assumed to be @var{n}x@var{n} square matrices.
 Then, the function call @samp{idn(1)} will expand into an actual
-matrix rather than representing a ``generic'' matrix.
+matrix rather than representing a ``generic'' matrix.  Simply typing
+@kbd{C-u m v} will get you a square Matrix mode, in which matrices of
+unknown size are assumed to be square matrices of unspecified size.
 
 @cindex Declaring scalar variables
 Of course these modes are approximations to the true state of
@@ -13200,6 +13207,8 @@ The value is not a vector.
 The value is a vector.
 @item matrix
 The value is a matrix (a rectangular vector of vectors).
+@item sqmatrix
+The value is a square matrix.
 @end table
 
 These type symbols can be combined with the other type symbols
@@ -15973,7 +15982,8 @@ Command is @kbd{m p}.
 
 @item
 Matrix/Scalar mode.  Default value is @mathit{-1}.  Value is 0 for Scalar
-mode, @mathit{-2} for Matrix mode, or @var{N} for 
+mode, @mathit{-2} for Matrix mode, @mathit{-3} for square Matrix mode,
+or @var{N} for  
 @texline @math{N\times N}
 @infoline @var{N}x@var{N} 
 Matrix mode.  Command is @kbd{m v}.
@@ -16051,7 +16061,10 @@ Symbolic mode (@kbd{m s}; @pxref{Symbolic Mode}).
 Matrix mode (@kbd{m v}; @pxref{Matrix Mode}).
 
 @item Matrix@var{n}
-Dimensioned Matrix mode (@kbd{C-u @var{n} m v}).
+Dimensioned Matrix mode (@kbd{C-u @var{n} m v}; @pxref{Matrix Mode}).
+
+@item SqMatrix
+Square Matrix mode (@kbd{C-u m v}; @pxref{Matrix Mode}).
 
 @item Scalar
 Scalar mode (@kbd{m v}; @pxref{Matrix Mode}).
@@ -17570,7 +17583,7 @@ beginning of daylight savings time; converting a date/time form that
 falls in this hour results in a time value for the following hour,
 from 3 a.m.@: to 4 a.m.  At the end of daylight savings time, the
 hour from 1 a.m.@: to 2 a.m.@: repeats itself; converting a date/time
-form that falls in in this hour results in a time value for the first
+form that falls in this hour results in a time value for the first
 manifestation of that time (@emph{not} the one that occurs one hour later).
 
 If @code{math-daylight-savings-hook} is @code{nil}, then the
@@ -22660,11 +22673,10 @@ to @expr{a / (c - b)}, and @expr{(a - b) / (-c)} to @expr{(b - a) / c}.
 
 The formula @expr{x^0} is simplified to @expr{1}, or to @samp{idn(1)}
 in Matrix mode.  The formula @expr{0^x} is simplified to @expr{0}
-unless @expr{x} is a negative number or complex number, in which
-case the result is an infinity or an unsimplified formula according
-to the current infinite mode.  Note that @expr{0^0} is an
-indeterminate form, as evidenced by the fact that the simplifications
-for @expr{x^0} and @expr{0^x} conflict when @expr{x=0}.
+unless @expr{x} is a negative number, complex number or zero.
+If @expr{x} is negative, complex or @expr{0.0}, @expr{0^x} is an
+infinity or an unsimplified formula according to the current infinite
+mode.  The expression @expr{0^0} is simplified to @expr{1}.
 
 Powers of products or quotients @expr{(a b)^c}, @expr{(a/b)^c}
 are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c}
@@ -22766,7 +22778,7 @@ simplified to @expr{x} for any @expr{x}.  This occurs even if you have
 stored a different value in the Calc variable @samp{e}; but this would
 be a bad idea in any case if you were also using natural logarithms!
 
-Among the logical functions, @tfn{(@var{a} <= @var{b})} changes to
+Among the logical functions, @tfn{!(@var{a} <= @var{b})} changes to
 @tfn{@var{a} > @var{b}} and so on.  Equations and inequalities where both sides
 are either negative-looking or zero are simplified by negating both sides
 and reversing the inequality.  While it might seem reasonable to simplify
@@ -23494,11 +23506,11 @@ argument once).
 @tindex integ
 The @kbd{a i} (@code{calc-integral}) [@code{integ}] command computes the
 indefinite integral of the expression on the top of the stack with
-respect to a variable.  The integrator is not guaranteed to work for
-all integrable functions, but it is able to integrate several large
-classes of formulas.  In particular, any polynomial or rational function
-(a polynomial divided by a polynomial) is acceptable.  (Rational functions
-don't have to be in explicit quotient form, however; 
+respect to a prompted-for variable.  The integrator is not guaranteed to
+work for all integrable functions, but it is able to integrate several
+large classes of formulas.  In particular, any polynomial or rational
+function (a polynomial divided by a polynomial) is acceptable.
+(Rational functions don't have to be in explicit quotient form, however; 
 @texline @math{x/(1+x^{-2})}
 @infoline @expr{x/(1+x^-2)}
 is not strictly a quotient of polynomials, but it is equivalent to
@@ -23507,6 +23519,11 @@ is not strictly a quotient of polynomials, but it is equivalent to
 integrated.  Finally, rational functions involving trigonometric or
 hyperbolic functions can be integrated.
 
+With an argument (@kbd{C-u a i}), this command will compute the definite
+integral of the expression on top of the stack.  In this case, the
+command will again prompt for an integration variable, then prompt for a
+lower limit and an upper limit.
+
 @ifinfo
 If you use the @code{integ} function directly in an algebraic formula,
 you can also write @samp{integ(f,x,v)} which expresses the resulting
@@ -25688,7 +25705,7 @@ stack.  It also works elementwise on vectors.  For example, if
 variable and the lefthand side is a number (as in @samp{2.34 = x}), then
 Calc keeps the lefthand side instead.  Finally, this command works with
 assignments @samp{x := 2.34} as well as equations, always taking the
-the righthand side, and for @samp{=>} (evaluates-to) operators, always
+righthand side, and for @samp{=>} (evaluates-to) operators, always
 taking the lefthand side.
 
 @kindex a &
@@ -28293,12 +28310,21 @@ pushes the old value of @samp{a} on the stack and stores @samp{a = 6}.
 @pindex calc-unstore
 @cindex Void variables
 @cindex Un-storing variables
-Until you store something in them, variables are ``void,'' that is, they
-contain no value at all.  If they appear in an algebraic formula they
-will be left alone even if you press @kbd{=} (@code{calc-evaluate}).
+Until you store something in them, most variables are ``void,'' that is,
+they contain no value at all.  If they appear in an algebraic formula
+they will be left alone even if you press @kbd{=} (@code{calc-evaluate}).
 The @kbd{s u} (@code{calc-unstore}) command returns a variable to the
 void state.
 
+@kindex s c
+@pindex calc-copy-variable
+The @kbd{s c} (@code{calc-copy-variable}) command copies the stored
+value of one variable to another.  One way it differs from a simple
+@kbd{s r} followed by an @kbd{s t} (aside from saving keystrokes) is
+that the value never goes on the stack and thus is never rounded,
+evaluated, or simplified in any way; it is not even rounded down to the
+current precision.
+
 The only variables with predefined values are the ``special constants''
 @code{pi}, @code{e}, @code{i}, @code{phi}, and @code{gamma}.  You are free
 to unstore these variables or to store new values into them if you like,
@@ -28308,25 +28334,26 @@ you change the value of one of these variables, or of one of the other
 special variables @code{inf}, @code{uinf}, and @code{nan} (which are
 normally void).
 
-Note that @code{pi} doesn't actually have 3.14159265359 stored
-in it, but rather a special magic value that evaluates to @cpi{}
-at the current precision.  Likewise @code{e}, @code{i}, and
-@code{phi} evaluate according to the current precision or polar mode.
-If you recall a value from @code{pi} and store it back, this magic
-property will be lost.
-
-@kindex s c
-@pindex calc-copy-variable
-The @kbd{s c} (@code{calc-copy-variable}) command copies the stored
-value of one variable to another.  It differs from a simple @kbd{s r}
-followed by an @kbd{s t} in two important ways.  First, the value never
-goes on the stack and thus is never rounded, evaluated, or simplified
-in any way; it is not even rounded down to the current precision.
-Second, the ``magic'' contents of a variable like @code{e} can
-be copied into another variable with this command, perhaps because
-you need to unstore @code{e} right now but you wish to put it
-back when you're done.  The @kbd{s c} command is the only way to
-manipulate these magic values intact.
+Note that @code{pi} doesn't actually have 3.14159265359 stored in it,
+but rather a special magic value that evaluates to @cpi{} at the current
+precision.  Likewise @code{e}, @code{i}, and @code{phi} evaluate
+according to the current precision or polar mode.  If you recall a value
+from @code{pi} and store it back, this magic property will be lost.  The
+magic property is preserved, however, when a variable is copied with
+@kbd{s c}.
+
+@kindex s k
+@pindex calc-copy-special-constant
+If one of the ``special constants'' is redefined (or undefined) so that
+it no longer has its magic property, the property can be restored with 
+@kbd{s k} (@code{calc-copy-special-constant}).  This command will prompt
+for a special constant and a variable to store it in, and so a special
+constant can be stored in any variable.  Here, the special constant that
+you enter doesn't depend on the value of the corresponding variable;
+@code{pi} will represent 3.14159@dots{} regardless of what is currently
+stored in the Calc variable @code{pi}.  If one of the other special
+variables, @code{inf}, @code{uinf} or @code{nan}, is given a value, its
+original behavior can be restored by voiding it with @kbd{s u}.
 
 @node Recalling Variables, Operations on Variables, Storing Variables, Store and Recall
 @section Recalling Variables
@@ -28681,11 +28708,11 @@ treatment to @samp{=>}.
 
 @noindent
 The commands for graphing data begin with the @kbd{g} prefix key.  Calc
-uses GNUPLOT 2.0 or 3.0 to do graphics.  These commands will only work
+uses GNUPLOT 2.0 or later to do graphics.  These commands will only work
 if GNUPLOT is available on your system.  (While GNUPLOT sounds like
 a relative of GNU Emacs, it is actually completely unrelated.
-However, it is free software and can be obtained from the Free
-Software Foundation's machine @samp{prep.ai.mit.edu}.)
+However, it is free software.   It can be obtained from
+@samp{http://www.gnuplot.info}.)
 
 @vindex calc-gnuplot-name
 If you have GNUPLOT installed on your system but Calc is unable to
@@ -28694,7 +28721,7 @@ in your Calc init file or @file{.emacs}.  You may also need to set some Lisp
 variables to show Calc how to run GNUPLOT on your system; these
 are described under @kbd{g D} and @kbd{g O} below.  If you are
 using the X window system, Calc will configure GNUPLOT for you
-automatically.  If you have GNUPLOT 3.0 and you are not using X,
+automatically.  If you have GNUPLOT 3.0 or later and you are not using X,
 Calc will configure GNUPLOT to display graphs using simple character
 graphics that will work on any terminal.
 
@@ -28813,7 +28840,7 @@ is the height of the point
 at coordinate @expr{(x_i, y_j)} on the surface.  The 3D graph will
 be displayed from a certain default viewpoint; you can change this
 viewpoint by adding a @samp{set view} to the @samp{*Gnuplot Commands*}
-buffer as described later.  See the GNUPLOT 3.0 documentation for a
+buffer as described later.  See the GNUPLOT documentation for a
 description of the @samp{set view} command.
 
 Each point in the matrix will be displayed as a dot in the graph,
@@ -29640,7 +29667,7 @@ whole line.  So you can usually transfer a single number into Calc
 just by double-clicking on it in the shell, then middle-clicking
 in the Calc window.
 
-@node Keypad Mode, Embedded Mode, Kill and Yank, Introduction
+@node Keypad Mode, Embedded Mode, Kill and Yank, Top
 @chapter Keypad Mode
 
 @noindent
@@ -29697,7 +29724,7 @@ original buffer.
 
 @smallexample
 @group
-|----+-----Calc 2.00-----+----1
+|----+-----Calc 2.1------+----1
 |FLR |CEIL|RND |TRNC|CLN2|FLT |
 |----+----+----+----+----+----|
 | LN |EXP |    |ABS |IDIV|MOD |
@@ -30102,20 +30129,21 @@ your own favorite delimiters.  Delimiters like @samp{$ $} can appear
 on their own separate lines or in-line with the formula.
 
 If you give a positive or negative numeric prefix argument, Calc
-instead uses the current point as one end of the formula, and moves
-forward or backward (respectively) by that many lines to find the
-other end.  Explicit delimiters are not necessary in this case.
+instead uses the current point as one end of the formula, and includes
+that many lines forward or backward (respectively, including the current
+line). Explicit delimiters are not necessary in this case.
 
-With a prefix argument of zero, Calc uses the current region
-(delimited by point and mark) instead of formula delimiters.
+With a prefix argument of zero, Calc uses the current region (delimited
+by point and mark) instead of formula delimiters.  With a prefix
+argument of @kbd{C-u} only, Calc uses the current line as the formula.
 
 @kindex M-# w
 @pindex calc-embedded-word
-With a prefix argument of @kbd{C-u} only, Calc scans for the first
-non-numeric character (i.e., the first character that is not a
-digit, sign, decimal point, or upper- or lower-case @samp{e})
-forward and backward to delimit the formula.  @kbd{M-# w}
-(@code{calc-embedded-word}) is equivalent to @kbd{C-u M-# e}.
+The @kbd{M-# w} (@code{calc-embedded-word}) command will start Embedded
+mode on the current ``word''; in this case Calc will scan for the first
+non-numeric character (i.e., the first character that is not a digit,
+sign, decimal point, or upper- or lower-case @samp{e}) forward and
+backward to delimit the formula.
 
 When you enable Embedded mode for a formula, Calc reads the text
 between the delimiters and tries to interpret it as a Calc formula.
@@ -30254,10 +30282,11 @@ Plain formulas are preceded and followed by @samp{%%%} signs
 by default.  This notation has the advantage that the @samp{%}
 character begins a comment in @TeX{} and La@TeX{}, so if your formula is 
 embedded in a @TeX{} or La@TeX{} document its plain version will be
-invisible in the final printed copy.  @xref{Customizing
-Embedded Mode}, to see how to change the ``plain'' formula
-delimiters, say to something that @dfn{eqn} or some other
-formatter will treat as a comment.
+invisible in the final printed copy.  Certain major modes have different
+delimiters to ensure that the ``plain'' version will be 
+in a comment for those modes, also.  
+See @ref{Customizing Embedded Mode} to see how to change the ``plain''
+formula delimiters. 
 
 There are several notations which Calc's parser for ``big''
 formatted formulas can't yet recognize.  In particular, it can't
@@ -30484,7 +30513,7 @@ mode.
 
 @kindex M-# u
 @kindex M-# =
-@pindex calc-embedded-update
+@pindex calc-embedded-update-formula
 Another way to change the assignment to @code{foo} would simply be
 to edit the number using regular Emacs editing rather than Embedded
 mode.  Then, we have to find a way to get Embedded mode to notice
@@ -30682,8 +30711,9 @@ formula are never used (except for global annotations, described
 below).
 
 The scan does not look for the leading @samp{% }, only for the
-square brackets and the text they enclose.  You can edit the mode
-annotations to a style that works better in context if you wish.
+square brackets and the text they enclose.  In fact, the leading
+characters are different for different major modes.  You can edit the
+mode annotations to a style that works better in context if you wish.
 @xref{Customizing Embedded Mode}, to see how to change the style
 that Calc uses when it generates the annotations.  You can write
 mode annotations into the file yourself if you know the syntax;
@@ -30783,14 +30813,11 @@ You can modify Embedded mode's behavior by setting various Lisp
 variables described here.  These variables are customizable 
 (@pxref{Customizable Variables}), or you can use @kbd{M-x set-variable}
 or @kbd{M-x edit-options} to adjust a variable on the fly.
-(Another possibility would
-be to use a file-local variable annotation at the end of the
-file; @pxref{File Variables, , Local Variables in Files, emacs, the
-Emacs manual}.)
-
-While none of these variables will be buffer-local by default, you
-can make any of them local to any Embedded mode buffer.  (Their
-values in the @samp{*Calculator*} buffer are never used.)
+(Another possibility would be to use a file-local variable annotation at
+the end of the file; 
+@pxref{File Variables, , Local Variables in Files, emacs, the Emacs manual}.)
+Many of the variables given mentioned here can be set to depend on the
+major mode of the editing buffer (@pxref{Customizable Variables}).
 
 @vindex calc-embedded-open-formula
 The @code{calc-embedded-open-formula} variable holds a regular
@@ -30873,11 +30900,13 @@ begins a ``plain'' formula written in front of the formatted
 formula when @kbd{d p} mode is turned on.  Note that this is an
 actual string, not a regular expression, because Calc must be able
 to write this string into a buffer as well as to recognize it.
-The default string is @code{"%%% "} (note the trailing space).
+The default string is @code{"%%% "} (note the trailing space), but may
+be different for certain major modes.
 
 @vindex calc-embedded-close-plain
 The @code{calc-embedded-close-plain} variable is a string which
-ends a ``plain'' formula.  The default is @code{" %%%\n"}.  Without
+ends a ``plain'' formula.  The default is @code{" %%%\n"}, but may be
+different for different major modes.  Without
 the trailing newline here, the first line of a Big mode formula
 that followed might be shifted over with respect to the other lines.
 
@@ -30907,11 +30936,12 @@ not activate just anything surrounded by formula delimiters; after
 all, blank lines are considered formula delimiters by default!
 But if your language includes a delimiter which can only occur
 actually in front of a formula, you can take advantage of it here.
-The default pattern is @code{"%Embed\n\\(% .*\n\\)*"}, which
-checks for @samp{%Embed} followed by any number of lines beginning
-with @samp{%} and a space.  This last is important to make Calc
-consider mode annotations part of the pattern, so that the formula's
-opening delimiter really is sure to follow the pattern.
+The default pattern is @code{"%Embed\n\\(% .*\n\\)*"}, but may be
+different for different major modes.
+This pattern will check for @samp{%Embed} followed by any number of
+lines beginning with @samp{%} and a space.  This last is important to
+make Calc consider mode annotations part of the pattern, so that the
+formula's opening delimiter really is sure to follow the pattern.
 
 @vindex calc-embedded-open-mode
 The @code{calc-embedded-open-mode} variable is a string (not a
@@ -30919,14 +30949,15 @@ regular expression) which should precede a mode annotation.
 Calc never scans for this string; Calc always looks for the
 annotation itself.  But this is the string that is inserted before
 the opening bracket when Calc adds an annotation on its own.
-The default is @code{"% "}.
+The default is @code{"% "}, but may be different for different major
+modes. 
 
 @vindex calc-embedded-close-mode
 The @code{calc-embedded-close-mode} variable is a string which
 follows a mode annotation written by Calc.  Its default value
-is simply a newline, @code{"\n"}.  If you change this, it is a
-good idea still to end with a newline so that mode annotations
-will appear on lines by themselves.
+is simply a newline, @code{"\n"}, but may be different for different
+major modes.  If you change this, it is a good idea still to end with a
+newline so that mode annotations will appear on lines by themselves.
 
 @node Programming, Customizable Variables, Embedded Mode, Top
 @chapter Programming
@@ -31384,23 +31415,35 @@ are @emph{not} affected by @kbd{Z `} and @kbd{Z '}.
 @node Queries in Macros, , Local Values in Macros, Keyboard Macros
 @subsection Queries in Keyboard Macros
 
-@noindent
-@kindex Z =
-@pindex calc-kbd-report
-The @kbd{Z =} (@code{calc-kbd-report}) command displays an informative
-message including the value on the top of the stack.  You are prompted
-to enter a string.  That string, along with the top-of-stack value,
-is displayed unless @kbd{m w} (@code{calc-working}) has been used
-to turn such messages off.
+@c @noindent
+@c @kindex Z =
+@c @pindex calc-kbd-report
+@c The @kbd{Z =} (@code{calc-kbd-report}) command displays an informative
+@c message including the value on the top of the stack.  You are prompted
+@c to enter a string.  That string, along with the top-of-stack value,
+@c is displayed unless @kbd{m w} (@code{calc-working}) has been used
+@c to turn such messages off.
 
+@noindent
 @kindex Z #
 @pindex calc-kbd-query
-The @kbd{Z #} (@code{calc-kbd-query}) command displays a prompt message
-(which you enter during macro definition), then does an algebraic entry
-which takes its input from the keyboard, even during macro execution.
-This command allows your keyboard macros to accept numbers or formulas
-as interactive input.  All the normal conventions of algebraic input,
-including the use of @kbd{$} characters, are supported.
+The @kbd{Z #} (@code{calc-kbd-query}) command prompts for an algebraic
+entry which takes its input from the keyboard, even during macro
+execution.  All the normal conventions of algebraic input, including the
+use of @kbd{$} characters, are supported.  The prompt message itself is
+taken from the top of the stack, and so must be entered (as a string)
+before the @kbd{Z #} command.  (Recall, as a string it can be entered by
+pressing the @kbd{"} key and will appear as a vector when it is put on
+the stack.  The prompt message is only put on the stack to provide a
+prompt for the @kbd{Z #} command; it will not play any role in any
+subsequent calculations.)  This command allows your keyboard macros to
+accept numbers or formulas as interactive input.
+
+As an example, 
+@kbd{2 @key{RET} "Power: " @key{RET} Z # 3 @key{RET} ^} will prompt for
+input with ``Power: '' in the minibuffer, then return 2 to the provided
+power.  (The response to the prompt that's given, 3 in this example,
+will not be part of the macro.)
 
 @xref{Keyboard Macro Query, , , emacs, the Emacs Manual}, for a description of
 @kbd{C-x q} (@code{kbd-macro-query}), the standard Emacs way to accept
@@ -33617,22 +33660,25 @@ example, for a rectangular complex number the result is the sum of
 the absolute values of the components.
 @end defun
 
-@findex two-pi
+@findex e
+@findex gamma-const
+@findex ln-2
+@findex ln-10
+@findex phi
 @findex pi-over-2
 @findex pi-over-4
 @findex pi-over-180
 @findex sqrt-two-pi
 @findex sqrt-e
-@findex e
-@findex ln-2
-@findex ln-10
+@findex two-pi
 @defun pi
 The function @samp{(pi)} computes @samp{pi} to the current precision.
 Other related constant-generating functions are @code{two-pi},
 @code{pi-over-2}, @code{pi-over-4}, @code{pi-over-180}, @code{sqrt-two-pi},
-@code{e}, @code{sqrt-e}, @code{ln-2}, and @code{ln-10}.  Each function
-returns a floating-point value in the current precision, and each uses
-caching so that all calls after the first are essentially free.
+@code{e}, @code{sqrt-e}, @code{ln-2}, @code{ln-10}, @code{phi} and
+@code{gamma-const}.  Each function returns a floating-point value in the
+current precision, and each uses caching so that all calls after the
+first are essentially free.
 @end defun
 
 @defmac math-defcache @var{func} @var{initial} @var{form}
@@ -34681,7 +34727,7 @@ step, before the Calc window is destroyed.
 @end defvar
 
 @defvar calc-window-hook
-If this hook exists, it is called to create the Calc window.
+If this hook is non-@code{nil}, it is called to create the Calc window.
 Upon return, this new Calc window should be the current window.
 (The Calc buffer will already be the current buffer when the
 hook is called.)  If the hook is not defined, Calc will
@@ -34690,10 +34736,24 @@ and @code{select-window} to create the Calc window.
 @end defvar
 
 @defvar calc-trail-window-hook
-If this hook exists, it is called to create the Calc Trail window.
-The variable @code{calc-trail-buffer} will contain the buffer
-which the window should use.  Unlike @code{calc-window-hook},
-this hook must @emph{not} switch into the new window.
+If this hook is non-@code{nil}, it is called to create the Calc Trail
+window.  The variable @code{calc-trail-buffer} will contain the buffer
+which the window should use.  Unlike @code{calc-window-hook}, this hook
+must @emph{not} switch into the new window.
+@end defvar
+
+@defvar calc-embedded-mode-hook
+This hook is called the first time that Embedded mode is entered.
+@end defvar
+
+@defvar calc-embedded-new-buffer-hook
+This hook is called each time that Embedded mode is entered in a
+new buffer.
+@end defvar
+
+@defvar calc-embedded-new-formula-hook
+This hook is called each time that Embedded mode is enabled for a
+new formula.
 @end defvar
 
 @defvar calc-edit-mode-hook
@@ -34797,11 +34857,7 @@ expression is basically a pattern that Calc can search for.
 See @ref{Regexp Search,, Regular Expression Search, emacs, The GNU Emacs Manual}
 to see how regular expressions work.
 
-@table @code
-
-@item calc-settings-file
-
-@vindex calc-settings-file
+@defvar calc-settings-file
 The variable @code{calc-settings-file} holds the file name in
 which commands like @kbd{m m} and @kbd{Z P} store ``permanent''
 definitions.  
@@ -34811,9 +34867,9 @@ If @code{calc-settings-file} is not your user init file (typically
 exists) the first time Calc is invoked.
 
 The default value for this variable is @code{"~/.calc.el"}.
+@end defvar
 
-@item calc-gnuplot-name
-
+@defvar calc-gnuplot-name
 See @ref{Graphics}.@*
 The variable @code{calc-gnuplot-name} should be the name of the
 GNUPLOT program (a string).  If you have GNUPLOT installed on your
@@ -34822,10 +34878,10 @@ variable.  (@pxref{Customizable Variables})
 You may also need to set some Lisp variables to show Calc how to run
 GNUPLOT on your system, see @ref{Devices, ,Graphical Devices} .  The default value
 of @code{calc-gnuplot-name} is @code{"gnuplot"}.
+@end defvar
 
-@item  calc-gnuplot-plot-command
-@itemx calc-gnuplot-print-command
-
+@defvar  calc-gnuplot-plot-command
+@defvarx calc-gnuplot-print-command
 See @ref{Devices, ,Graphical Devices}.@*
 The variables @code{calc-gnuplot-plot-command} and
 @code{calc-gnuplot-print-command} represent system commands to
@@ -34838,9 +34894,9 @@ to display or print the output.
 The default value of @code{calc-gnuplot-plot-command} is @code{nil},
 and the default value of @code{calc-gnuplot-print-command} is
 @code{"lp %s"}.
+@end defvar
 
-@item calc-language-alist
-
+@defvar calc-language-alist
 See @ref{Basic Embedded Mode}.@*
 The variable @code{calc-language-alist} controls the languages that
 Calc will associate with major modes.  When Calc embedded mode is
@@ -34866,9 +34922,10 @@ The default value of @code{calc-language-alist} is
     (fortran-mode . fortran)
     (f90-mode . fortran))
 @end example
+@end defvar
 
-@item calc-embedded-announce-formula
-
+@defvar calc-embedded-announce-formula
+@defvarx calc-embedded-announce-formula-alist
 See @ref{Customizing Embedded Mode}.@*
 The variable @code{calc-embedded-announce-formula} helps determine
 what formulas @kbd{M-# a} will activate in a buffer.  It is a
@@ -34881,9 +34938,32 @@ The default pattern is @code{"%Embed\n\\(% .*\n\\)*"}, which checks
 for @samp{%Embed} followed by any number of lines beginning with
 @samp{%} and a space.
 
-@item  calc-embedded-open-formula
-@itemx calc-embedded-close-formula
+The variable @code{calc-embedded-announce-formula-alist} is used to
+set @code{calc-embedded-announce-formula} to different regular
+expressions depending on the major mode of the editing buffer.
+It consists of a list of pairs of the form @code{(@var{MAJOR-MODE} .
+@var{REGEXP})}, and its default value is
+@example
+   ((c++-mode     . "//Embed\n\\(// .*\n\\)*")
+    (c-mode       . "/\\*Embed\\*/\n\\(/\\* .*\\*/\n\\)*")
+    (f90-mode     . "!Embed\n\\(! .*\n\\)*")
+    (fortran-mode . "C Embed\n\\(C .*\n\\)*")
+    (html-helper-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*")
+    (html-mode    . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*")
+    (nroff-mode   . "\\\\\"Embed\n\\(\\\\\" .*\n\\)*")
+    (pascal-mode  . "@{Embed@}\n\\(@{.*@}\n\\)*")
+    (sgml-mode    . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*")
+    (xml-mode     . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*")
+    (texinfo-mode . "@@c Embed\n\\(@@c .*\n\\)*"))
+@end example
+Any major modes added to @code{calc-embedded-announce-formula-alist}
+should also be added to @code{calc-embedded-open-close-plain-alist} 
+and @code{calc-embedded-open-close-mode-alist}.
+@end defvar
 
+@defvar  calc-embedded-open-formula
+@defvarx calc-embedded-close-formula
+@defvarx calc-embedded-open-close-formula-alist
 See @ref{Customizing Embedded Mode}.@*
 The variables @code{calc-embedded-open-formula} and
 @code{calc-embedded-open-formula} control the region that Calc will
@@ -34909,9 +34989,19 @@ Lines beginning with @samp{.EQ} and @samp{.EN} (@dfn{eqn} delimiters);
 Lines containing a single @samp{%} or @samp{.\"} symbol and nothing else.
 @end enumerate
 
-@item  calc-embedded-open-word
-@itemx calc-embedded-close-word
+The variable @code{calc-embedded-open-close-formula-alist} is used to
+set @code{calc-embedded-open-formula} and
+@code{calc-embedded-close-formula} to different regular
+expressions depending on the major mode of the editing buffer.
+It consists of a list of lists of the form 
+@code{(@var{MAJOR-MODE}  @var{OPEN-FORMULA-REGEXP}
+@var{CLOSE-FORMULA-REGEXP})}, and its default value is
+@code{nil}.
+@end defvar
 
+@defvar  calc-embedded-open-word
+@defvarx calc-embedded-close-word
+@defvarx calc-embedded-open-close-word-alist
 See @ref{Customizing Embedded Mode}.@*
 The variables @code{calc-embedded-open-word} and
 @code{calc-embedded-close-word} control the region that Calc will
@@ -34922,9 +35012,19 @@ The default values of @code{calc-embedded-open-word} and
 @code{calc-embedded-close-word} are @code{"^\\|[^-+0-9.eE]"} and 
 @code{"$\\|[^-+0-9.eE]"} respectively.
 
-@item  calc-embedded-open-plain
-@itemx calc-embedded-close-plain
+The variable @code{calc-embedded-open-close-word-alist} is used to
+set @code{calc-embedded-open-word} and
+@code{calc-embedded-close-word} to different regular
+expressions depending on the major mode of the editing buffer.
+It consists of a list of lists of the form 
+@code{(@var{MAJOR-MODE}  @var{OPEN-WORD-REGEXP}
+@var{CLOSE-WORD-REGEXP})}, and its default value is
+@code{nil}.
+@end defvar
 
+@defvar  calc-embedded-open-plain
+@defvarx calc-embedded-close-plain
+@defvarx calc-embedded-open-close-plain-alist
 See @ref{Customizing Embedded Mode}.@*
 The variables @code{calc-embedded-open-plain} and
 @code{calc-embedded-open-plain} are used to delimit ``plain''
@@ -34938,9 +35038,34 @@ The default string for @code{calc-embedded-open-plain} is
 the trailing newline here, the first line of a Big mode formula
 that followed might be shifted over with respect to the other lines.
 
-@item  calc-embedded-open-new-formula
-@itemx calc-embedded-close-new-formula
+The variable @code{calc-embedded-open-close-plain-alist} is used to
+set @code{calc-embedded-open-plain} and
+@code{calc-embedded-close-plain} to different strings
+depending on the major mode of the editing buffer.
+It consists of a list of lists of the form 
+@code{(@var{MAJOR-MODE}  @var{OPEN-PLAIN-STRING}
+@var{CLOSE-PLAIN-STRING})}, and its default value is
+@example
+   ((c++-mode     "// %% "   " %%\n")
+    (c-mode       "/* %% "   " %% */\n")
+    (f90-mode     "! %% "    " %%\n")
+    (fortran-mode "C %% "    " %%\n")
+    (html-helper-mode "<!-- %% " " %% -->\n")
+    (html-mode "<!-- %% " " %% -->\n")
+    (nroff-mode   "\\\" %% " " %%\n")
+    (pascal-mode  "@{%% "    " %%@}\n")
+    (sgml-mode     "<!-- %% " " %% -->\n")
+    (xml-mode     "<!-- %% " " %% -->\n")
+    (texinfo-mode "@@c %% "   " %%\n"))
+@end example
+Any major modes added to @code{calc-embedded-open-close-plain-alist}
+should also be added to @code{calc-embedded-announce-formula-alist}
+and @code{calc-embedded-open-close-mode-alist}.
+@end defvar
 
+@defvar  calc-embedded-open-new-formula
+@defvarx calc-embedded-close-new-formula
+@defvarx calc-embedded-open-close-new-formula-alist
 See @ref{Customizing Embedded Mode}.@*
 The variables @code{calc-embedded-open-new-formula} and
 @code{calc-embedded-close-new-formula} are strings which are
@@ -34956,9 +35081,19 @@ if typed at the end of a line.  (It follows that if @kbd{M-# f} is
 typed on a blank line, both a leading opening newline and a trailing
 closing newline are omitted.)
 
-@item  calc-embedded-open-mode
-@itemx calc-embedded-close-mode
+The variable @code{calc-embedded-open-close-new-formula-alist} is used to
+set @code{calc-embedded-open-new-formula} and
+@code{calc-embedded-close-new-formula} to different strings
+depending on the major mode of the editing buffer.
+It consists of a list of lists of the form 
+@code{(@var{MAJOR-MODE}  @var{OPEN-NEW-FORMULA-STRING}
+@var{CLOSE-NEW-FORMULA-STRING})}, and its default value is
+@code{nil}.
+@end defvar
 
+@defvar  calc-embedded-open-mode
+@defvarx calc-embedded-close-mode
+@defvarx calc-embedded-open-close-mode-alist
 See @ref{Customizing Embedded Mode}.@*
 The variables @code{calc-embedded-open-mode} and
 @code{calc-embedded-close-mode} are strings which Calc will place before
@@ -34973,7 +35108,30 @@ If you change the value of @code{calc-embedded-close-mode}, it is a good
 idea still to end with a newline so that mode annotations will appear on
 lines by themselves.
 
-@end table
+The variable @code{calc-embedded-open-close-mode-alist} is used to
+set @code{calc-embedded-open-mode} and
+@code{calc-embedded-close-mode} to different strings
+expressions depending on the major mode of the editing buffer.
+It consists of a list of lists of the form 
+@code{(@var{MAJOR-MODE}  @var{OPEN-MODE-STRING}
+@var{CLOSE-MODE-STRING})}, and its default value is
+@example
+   ((c++-mode     "// "   "\n")
+    (c-mode       "/* "   " */\n")
+    (f90-mode     "! "    "\n")
+    (fortran-mode "C "    "\n")
+    (html-helper-mode "<!-- " " -->\n")
+    (html-mode    "<!-- " " -->\n")
+    (nroff-mode   "\\\" " "\n")
+    (pascal-mode  "@{ "    " @}\n")
+    (sgml-mode    "<!-- " " -->\n")
+    (xml-mode     "<!-- " " -->\n")
+    (texinfo-mode "@@c "   "\n"))
+@end example
+Any major modes added to @code{calc-embedded-open-close-mode-alist}
+should also be added to @code{calc-embedded-announce-formula-alist}
+and @code{calc-embedded-open-close-plain-alist}.
+@end defvar
 
 @node Reporting Bugs, Summary, Customizable Variables, Top
 @appendix Reporting Bugs
@@ -35011,7 +35169,7 @@ CVS tree.  See @uref{http://savannah.gnu.org/projects/emacs}.
 @appendix Calc Summary
 
 @noindent
-This section includes a complete list of Calc 2.02 keystroke commands.
+This section includes a complete list of Calc 2.1 keystroke commands.
 Each line lists the stack entries used by the command (top-of-stack
 last), the keystrokes themselves, the prompts asked by the command,
 and the result of the command (also with top-of-stack last).
@@ -35078,11 +35236,12 @@ keystrokes are not listed in this summary.
 @r{       @:     M-# r  @:             @:    36  @:calc-grab-rectangle@:}
 @r{       @:     M-# s  @:             @:        @:calc-info-summary@:}
 @r{       @:     M-# t  @:             @:        @:calc-tutorial@:}
-@r{       @:     M-# u  @:             @:        @:calc-embedded-update@:}
+@r{       @:     M-# u  @:             @:        @:calc-embedded-update-formula@:}
 @r{       @:     M-# w  @:             @:        @:calc-embedded-word@:}
 @r{       @:     M-# x  @:             @:        @:calc-quit@:}
 @r{       @:     M-# y  @:            @:1,28,49  @:calc-copy-to-buffer@:}
 @r{       @:     M-# z  @:             @:        @:calc-user-invocation@:}
+@r{       @:     M-# =  @:             @:        @:calc-embedded-update-formula@:}
 @r{       @:     M-# :  @:             @:    36  @:calc-grab-sum-down@:}
 @r{       @:     M-# _  @:             @:    36  @:calc-grab-sum-across@:}
 @r{       @:     M-# `  @:editing      @:    30  @:calc-embedded-edit@:}
@@ -35616,6 +35775,7 @@ keystrokes are not listed in this summary.
 @r{       @:      s d   @:var, decl    @:        @:calc-declare-variable@:}
 @r{       @:      s e   @:var, editing @: 29,30  @:calc-edit-variable@:}
 @r{       @:      s i   @:buffer       @:        @:calc-insert-variables@:}
+@r{       @:      s k   @:const, var   @:    29  @:calc-copy-special-constant@:}
 @r{    a b@:      s l   @:var          @:    29  @:@:a  (letting var=b)}
 @r{  a ...@:      s m   @:op, var      @: 22,29  @:calc-store-map@:}
 @r{       @:      s n   @:var          @: 29,47  @:calc-store-neg@:  (v/-1)}
@@ -35857,8 +36017,7 @@ keystrokes are not listed in this summary.
 @c
 @r{       @:      Z `   @:             @:        @:calc-kbd-push@:}
 @r{       @:      Z '   @:             @:        @:calc-kbd-pop@:}
-@r{      a@:      Z =   @:message      @:    28  @:calc-kbd-report@:}
-@r{       @:      Z #   @:prompt       @:        @:calc-kbd-query@:}
+@r{       @:      Z #   @:             @:        @:calc-kbd-query@:}
 
 @c
 @r{   comp@:      Z C   @:func, args   @:    50  @:calc-user-define-composition@:}