]> code.delx.au - gnu-emacs/blobdiff - man/calc.texi
(byte-compile-lambda): Add parameter add-lambda.
[gnu-emacs] / man / calc.texi
index 948b6049198ef6a6e04aaea5a8bc47357e77f4a7..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
 
@@ -187,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.
@@ -533,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.
@@ -4314,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}''
@@ -12816,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
@@ -13204,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
@@ -15977,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}.
@@ -16055,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}).
@@ -17574,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
@@ -23497,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
@@ -23510,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
@@ -25691,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 &
@@ -28694,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
@@ -28707,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.
 
@@ -28826,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,
@@ -30268,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
@@ -30696,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;
@@ -30797,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
@@ -30887,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.
 
@@ -30921,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
@@ -30933,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
@@ -34725,6 +34742,20 @@ 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
 This hook is called by @code{calc-edit} (and the other ``edit''
 commands) when the temporary editing buffer is being created.
@@ -34894,6 +34925,7 @@ The default value of @code{calc-language-alist} is
 @end defvar
 
 @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
@@ -34905,10 +34937,33 @@ activated.  (Calc also uses other patterns to find formulas, such as
 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.
+
+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
@@ -34933,10 +34988,20 @@ Lines beginning with @samp{.EQ} and @samp{.EN} (@dfn{eqn} delimiters);
 @item
 Lines containing a single @samp{%} or @samp{.\"} symbol and nothing else.
 @end enumerate
+
+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
@@ -34946,10 +35011,20 @@ regular expressions.
 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.
+
+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''
@@ -34962,10 +35037,35 @@ The default string for @code{calc-embedded-open-plain} is
 @code{calc-embedded-close-plain} is @code{" %%%\n"}, 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.
+
+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
@@ -34980,10 +35080,20 @@ also @code{"\n\n"}.  The final newline is omitted by @w{@kbd{M-# f}}
 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.)
+
+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
@@ -34997,6 +35107,30 @@ and the default value of @code{calc-embedded-close-mode} is
 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.
+
+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