[comp.sources.misc] v15i028: Patch for GNU Emacs Calc, version 1.04 -> 1.05, part 01/20

daveg@csvax.cs.caltech.edu (David Gillespie) (10/15/90)

Posting-number: Volume 15, Issue 28
Submitted-by: daveg@csvax.cs.caltech.edu (David Gillespie)
Archive-name: calc-1.05/part01

Well, Calc 1.05 is finally here.  This version includes many substantial
improvements---here are some highlights:  Graphics using GNUPLOT, much
better algebraic operations, new math functions, numerical root finding
and minimization of functions, lots of new vector-related features,
and over 50 exercises (with complete answers) in the Tutorial section
of the manual.

This shar file and the 19 (!) that follow create one giant patch file,
suitable for use with Patch 2.0.  If you can't unshar the files it's
not too hard to concatenate them by hand since they only build one file.

If hunk #15 fails while patching calc.el, you can ignore the warning.

If you have access to FTP it will be easier to grab 1.05 whole from
csvax.cs.caltech.edu.

								-- Dave




#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
# This is part 1 of a multipart archive                                    
# do not concatenate these parts, unpack them in order with /bin/sh        
#
#	Run the following text with /bin/sh to create:
#	  calc.patch
#
if test -r s2_seq_.tmp
then echo "Must unpack archives in sequence!"
     next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
     exit 1; fi
sed 's/^X//' << 'SHAR_EOF' > calc.patch &&
X
XThe following patches convert Calc version 1.04 into Calc
Xversion 1.05.  To apply them automatically with Patch v2.0,
Xfirst cd into your Calc distribution directory, then execute
X"patch -p0 <calc.patch", where "calc.patch" is the name of this file.
X
XA list of changes appears near the front of calc.el below.
X
XIf you have used calc-split, follow these steps to apply the patches
X(assuming you are using Unix):
X
X   1.  "cd" to your Calc home directory.
X   2.  "rm calc*.el calc*.elc".  (Removes the old files created by calc-split)
X   3.  "mv calc.elX calc.el".    (Restores the original, unsplit files)
X   4.  "mv calc-ext.elX calc-ext.el".
X   5.  Run the patch program as described above.
X
XBecause of previous problems with "macedit", these patches create a
Xcompletely new file, "newmacedit.el".  You should rename this to
X"macedit.el", replacing the old version:
X
X   6.  "mv newmacedit.el macedit.el".
X
XThere is now an automatic "calc-install" command to help installation.
XSee the instructions at the front of the file calc-INSTALL.  You should
Xuse it to recompile Calc unless your setup is too strange for calc-install
Xto handle.
X
XNote that these patches have added to the list of "autoload" commands
Xrecommended by the calc-INSTALL file.
X
XPatches and complete tar files are also available for anonymous FTP
Xfrom csvax.cs.caltech.edu [131.215.131.131], in the "pub" subdirectory.
X
XEnjoy!
X							-- Dave
X
XDave Gillespie
X256-80 Caltech, Pasadena CA 91125
Xdaveg@csvax.cs.caltech.edu, ...!cit-vax!daveg
X
X
X
X*** calc.el	Sun Aug 12 15:11:02 1990
X--- ../dist/calc.el	Tue Oct  9 16:42:35 1990
X***************
X*** 1,4 ****
X! ;; Calculator for GNU Emacs version 1.04
X  ;; Copyright (C) 1990 Dave Gillespie
X  
X  ;; This file is part of GNU Emacs.
X--- 1,4 ----
X! ;; Calculator for GNU Emacs version 1.05
X  ;; Copyright (C) 1990 Dave Gillespie
X  
X  ;; This file is part of GNU Emacs.
X***************
X*** 19,29 ****
X  ;; and this notice must be preserved on all copies.
X  
X  
X  ;;; This is part I of the Emacs Calculator.  It defines simple arithmetic
X  ;;; commands only.  Assuming the autoload commands shown below have been
X  ;;; done, the Calculator will autoload the remaining commands from calc-ext.elc
X  ;;; whenever one is first needed.  If you wish, you can concatenate calc-ext
X! ;;; onto the end of calc to make one big file (.el or .elc).
X  
X  ;;; Suggested usage:
X  ;;;
X--- 19,33 ----
X  ;; and this notice must be preserved on all copies.
X  
X  
X+ ;;;; [calc.el]
X+ 
X  ;;; This is part I of the Emacs Calculator.  It defines simple arithmetic
X  ;;; commands only.  Assuming the autoload commands shown below have been
X  ;;; done, the Calculator will autoload the remaining commands from calc-ext.elc
X  ;;; whenever one is first needed.  If you wish, you can concatenate calc-ext
X! ;;; onto the end of calc to make one big file (.el or .elc).  On the other
X! ;;; hand, you may wish to use calc-install to split Calc into many small,
X! ;;; fast-loading files.
X  
X  ;;; Suggested usage:
X  ;;;
X***************
X*** 61,66 ****
X--- 65,113 ----
X  ;;; and "defmath".  User-accessible variables begin with "var-".
X  
X  
X+ ;;; Version 1.05:
X+ ;;;  * Created a calc-install command to ease installation.
X+ ;;;  * Added lots of exercises to the Tutorial section of the manual.
X+ ;;;  * Added ability to select and operate on sub-formulas.
X+ ;;;  * Substantially improved the algebraic rewrite-rule system.
X+ ;;;  * Added a set of graphing commands that use GNUPLOT.
X+ ;;;  * Added a command (`a R') for finding numerical roots to equations.
X+ ;;;  * Added several new math functions, such as erf and Bessel functions.
X+ ;;;  * Added key bindings for miscellaneous commands using the "f" prefix key.
X+ ;;;  * Added lots of new vector operations, many of them in the spirit of APL.
X+ ;;;  * Added more control over vector display, including an abbreviated mode.
X+ ;;;  * Improved keyboard macro editing; added read-kbd-macro to macedit.el.
X+ ;;;  * Introduced the `m S' (calc-shift-prefix) command.
X+ ;;;  * Enhanced the calc-edit command in several ways.
X+ ;;;  * Made it possible to hit ` (calc-edit) during numeric/algebraic entry.
X+ ;;;  * Enhanced the calc-solve-for command to handle inequalities.
X+ ;;;  * Enhanced calc-simplify to handle equations and inequalities.
X+ ;;;  * Taught log10 and log to look for exact integer or rational results.
X+ ;;;  * Added ability to take Nth roots directly.
X+ ;;;  * Added "increment" and "decrement" commands for integers and floats.
X+ ;;;  * Added "full-help" command, changed "h" key to invoke it.
X+ ;;;  * Added special help for Inverse and Hyperbolic prefixes.
X+ ;;;  * Added an optional prefix argument to `o' (calc-realign).
X+ ;;;  * Changed `t s' and `t r' to use RET as the search exit key.
X+ ;;;  * Made handling of operator keys for V M, V R, etc. more regular.
X+ ;;;  * Improved TeX mode; added support for \matrix format.
X+ ;;;  * Added a variant of `m a' mode that only affects ( and [ keys.
X+ ;;;  * Fixed "Mismatch" message for algebraic entry of semi-open intervals.
X+ ;;;  * Trimmed fat from calc.el to speed loading, moved more to calc-ext.el.
X+ ;;;  * Fixed a bug in which minibuffer entry rounded to out-of-date precision.
X+ ;;;  * Fixed a bug which crashed Calc 1.04 under Epoch.
X+ ;;;  * Fixed a bug which messed up Calc Trail's mode line, among other things.
X+ ;;;  * Fixed a bug which caused trail ">" to show only when in Trail buffer.
X+ ;;;  * Fixed a bug in which "calc" called "calc-grab-region" with too few args.
X+ ;;;  * Fixed bugs in both implementation and documentation of calc-perm.
X+ ;;;  * Fixed a bug in which calc-simplify-extended always used radians.
X+ ;;;  * Fixed a bug where calc-comma failed to override "polar" mode.
X+ ;;;  * Fixed a bug doing mixed arithmetic on rectangular+polar complex numbers.
X+ ;;;  * Fixed several bugs in transcendental functions with complex arguments.
X+ ;;;  * Fixed a bug in which `a s' simplified "x / .5" to ".5 x".
X+ ;;;  * Fixed numerous other bugs in various parts of Calc.
X+ ;;;  * Completed the "Hooks" section of the "Internals" chapter of the manual.
X+ ;;; 
X  ;;; Version 1.04:
X  ;;;  * Included a copy of revision history (from README) in calc.el.
X  ;;;  * Added the "calc-split" feature to split calc-ext.el into smaller bits.
X***************
X*** 116,129 ****
X  
X  (provide 'calc)
X  
X  (defmacro calc-record-compilation-date-macro ()
X!   (` (setq calc-version (concat "Emacs Calc Mode"
X! 				" v1.04 by Dave Gillespie"
X! 				", installed "
X! 				(, (current-time-string))
X! 				" by "
X! 				(, (user-full-name)))))
X  )
X  (defun calc-record-compilation-date ()
X    (calc-record-compilation-date-macro)
X  )
X--- 163,185 ----
X  
X  (provide 'calc)
X  
X+ ;;;; [calc-macs.el]
X+ 
X+ (provide 'calc-macs)
X+ 
X+ (defun calc-need-macros ())
X+ 
X  (defmacro calc-record-compilation-date-macro ()
X!   (` (setq calc-version (, (concat "Emacs Calc Mode"
X! 				   " v1.05 by Dave Gillespie"
X! 				   ", installed "
X! 				   (current-time-string)
X! 				   " by "
X! 				   (user-full-name)))))
X  )
X+ 
X+ ;;;; [calc.el]
X+ 
X  (defun calc-record-compilation-date ()
X    (calc-record-compilation-date-macro)
X  )
X***************
X*** 133,139 ****
X--- 189,217 ----
X  (defvar calc-info-filename "calc-info"
X    "*File name in which to look for the Calculator's Info documentation.")
X  
X+ (defvar calc-settings-file "~/.emacs"
X+   "*File in which to record permanent settings; default is \"~/.emacs\".")
X+   
X+ (defvar calc-gnuplot-name "gnuplot"
X+   "*Name of GNUPLOT program, for calc-graph features.")
X+ 
X+ (defvar calc-gnuplot-plot-command nil
X+   "*Name of command for displaying GNUPLOT output; %s = file name to print.")
X+ 
X+ (defvar calc-gnuplot-print-command "lp %s"
X+   "*Name of command for printing GNUPLOT output; %s = file name to print.")
X+ 
X+ 
X+ ;; Address of the author of Calc, for use by report-calc-bug.
X+ (defvar calc-bug-address "daveg@csvax.cs.caltech.edu")
X+ 
X+ 
X+ ;; If T, scan keymaps to find all DEL-like keys.
X+ ;; If NIL, only DEL itself is mapped to calc-pop.
X+ (defvar calc-scan-for-dels t)
X+ 
X  
X+ 
X  (defvar calc-extensions-loaded nil)
X  
X  
X***************
X*** 140,161 ****
X  
X  ;;; IDEAS:
X  ;;;
X- ;;;   How about putting cursor on an operator or functor in stack window
X- ;;;      to indicate the subterm to which a command should apply?
X  ;;;   Make math-simplify faster!
X  ;;;   Provide analogues of Mathematica's polynomial-munching ops:
X  ;;;      Together, Apart, Cancel, Factor, GCD, quotient/remainder.
X  ;;;   Automatically generate derivatives for functions defined with Z F.
X! ;;;   Handle commutativity and associativity among +, -, *, / in rewrite rules.
X! ;;;   Allow more powerful patterns, e.g., generic function names.
X! ;;;   Have a command that distributes function calls over equations.
X  ;;;
X  ;;;   In no-simplify mode, have a key which executes the top-level call
X  ;;;      once, but does not execute any of the arguments' calls.
X  ;;;   Put a set of evaluations in the c-prefix menu, analogous to m-prefix.
X  ;;;
X- ;;;   During algebraic entry, hit ` to switch to calc-edit entry.
X- ;;;
X  ;;;   When the stack is truncated, put the "." on the *second*-to-bottom line.
X  ;;;   When formatting formulas, suppress extra spaces inside vectors!
X  ;;;   Implement line-breaking in non-flat compositions.
X--- 218,239 ----
X  
X  ;;; IDEAS:
X  ;;;
X  ;;;   Make math-simplify faster!
X  ;;;   Provide analogues of Mathematica's polynomial-munching ops:
X  ;;;      Together, Apart, Cancel, Factor, GCD, quotient/remainder.
X  ;;;   Automatically generate derivatives for functions defined with Z F.
X! ;;;
X! ;;;   Fix rewrite mechanism to do less gratuitous rearrangement of terms.
X! ;;;   Implement a pattern-based "refers" predicate.
X  ;;;
X+ ;;;   Make it possible to Undo a selection command.
X+ ;;;   Figure out how to allow selecting rows of matrices.
X+ ;;;   If cursor was in selection before, move it after j n, j p, j L, etc.
X+ ;;;
X  ;;;   In no-simplify mode, have a key which executes the top-level call
X  ;;;      once, but does not execute any of the arguments' calls.
X  ;;;   Put a set of evaluations in the c-prefix menu, analogous to m-prefix.
X  ;;;
X  ;;;   When the stack is truncated, put the "." on the *second*-to-bottom line.
X  ;;;   When formatting formulas, suppress extra spaces inside vectors!
X  ;;;   Implement line-breaking in non-flat compositions.
X***************
X*** 166,174 ****
X  ;;;   Have "Z R" define a user command based on a set of rewrite rules.
X  ;;;   Support "incf" and "decf" in defmath definitions.
X  ;;;   Have defmath generate calls to calc-binary-op or calc-unary-op.
X  ;;;
X  ;;;   Allow calc-word-size=0 => Common Lisp-style signed bitwise arithmetic.
X! ;;;   Consider implementing some other special functions.
X  ;;;   May as well make continued-fractions stuff available to the user.
X  ;;;   Provide date arithmetic a la HP 48.
X  ;;;   Consider providing infinities and indeterminate values as a data type.
X--- 244,253 ----
X  ;;;   Have "Z R" define a user command based on a set of rewrite rules.
X  ;;;   Support "incf" and "decf" in defmath definitions.
X  ;;;   Have defmath generate calls to calc-binary-op or calc-unary-op.
X+ ;;;   Make some way to define algebraic functions using keyboard macros.
X  ;;;
X  ;;;   Allow calc-word-size=0 => Common Lisp-style signed bitwise arithmetic.
X! ;;;   Consider digamma function (and thus Euler's gamma constant).
X  ;;;   May as well make continued-fractions stuff available to the user.
X  ;;;   Provide date arithmetic a la HP 48.
X  ;;;   Consider providing infinities and indeterminate values as a data type.
X***************
X*** 179,227 ****
X  ;;;
X  ;;;   How about matrix eigenvalues, SVD, pseudo-inverse, etc.?
X  ;;;   Should cache matrix inverses as well as decompositions.
X! ;;;   Allow calc-edit to edit a matrix in a more convenient form.
X  ;;;
X  ;;;   Replace hokey formulas for complex functions with formulas designed
X  ;;;      to minimize roundoff while maintaining the proper branch cuts.
X  ;;;   Provide a better implementation for math-sin-cos-raw.
X  ;;;   Provide a better implementation for math-hypot.
X  ;;;   Provide a better implementation for math-make-frac.
X  ;;;   Provide a better implementation for math-prime-factors.
X  ;;;   Provide a better implementation for math-integral.
X  ;;;   Clean up some of the definitions in the units table.
X- ;;;   Implement dfact for large inputs using gamma function.
X  ;;;
X  ;;;   Provide more examples in the tutorial section of the manual.
X  ;;;   Cover in the tutorial:  language modes, simplification modes,
X! ;;;       bitwise stuff, rewrite rules.
X! ;;;   Add some exercises to the tutorial.
X  ;;;   Provide more Lisp programming examples in the manual.
X! ;;;   Finish the Internals section of the manual.
X  ;;;
X  ;;;   Tim suggests adding spreadsheet-like features.
X! ;;;   How about ultra-low-resolution plots?  (Probably too slow.)
X! ;;;   How about running gnuplot to generate high-res plots?
X  ;;;   Implement language modes for Eqn, Gnuplot, Lisp, Ada, ...?
X  ;;;
X  
X  
X- ;;; Graphically manipulating a composed expression:
X- ;;;   Have an option in math-compose-expr which wraps each term with a
X- ;;;   "(tag C X)" form where C is the composition term and X is the
X- ;;;   sub-expression that generated it.  Now, call a variant of
X- ;;;   math-simplify-comp which returns the innermost X whose C contained
X- ;;;   a given (x,y) location.  In addition, have a variant of
X- ;;;   math-simplify-comp which replaces every non-blank character inside
X- ;;;   a tag form for a given X with some highlight character like "#".
X- ;;;   (Consider supporting Epoch's true highlighting here.)
X- 
X- ;;; Idea: Have "{" and "}" mean select next larger or smaller sub-formula
X- ;;;   around the cursor; when a sub-formula is selected, the next command
X- ;;;   (of any sort) applies to that sub-formula.  Have calc-top-n and
X- ;;;   calc-enter-result fake this up.  Print a warning if a stack entry is
X- ;;;   highlighted which is not touched by the next command.
X- 
X- 
X  ;;; For atan series, if x > tan(pi/12) (about 0.268) reduce using the identity
X  ;;;   atan(x) = atan((x * sqrt(3) - 1) / (sqrt(3) + x)) + pi/6.
X  
X--- 258,296 ----
X  ;;;
X  ;;;   How about matrix eigenvalues, SVD, pseudo-inverse, etc.?
X  ;;;   Should cache matrix inverses as well as decompositions.
X! ;;;
X! ;;;   Handle TeX-mode parsing of \matrix{ ... } where ... contains braces.
X! ;;;   Support AmS-TeX's \{d,t,}frac, \{d,t,}binom notations.
X! ;;;
X! ;;;   If GNUPLOT isn't there, do low-res plots in an Emacs text buffer.
X! ;;;   Support polar plotting with GNUPLOT.
X! ;;;   Make a calc-graph-histogram function.
X  ;;;
X  ;;;   Replace hokey formulas for complex functions with formulas designed
X  ;;;      to minimize roundoff while maintaining the proper branch cuts.
X+ ;;;   Test accuracy of advanced math functions over whole complex plane.
X+ ;;;   Extend Bessel functions to provide arbitrary precision.
X+ ;;;   Extend advanced math functions to handle error forms and intervals.
X  ;;;   Provide a better implementation for math-sin-cos-raw.
X  ;;;   Provide a better implementation for math-hypot.
X  ;;;   Provide a better implementation for math-make-frac.
X  ;;;   Provide a better implementation for math-prime-factors.
X  ;;;   Provide a better implementation for math-integral.
X+ ;;;   Provide a better initial guess for math-nth-root.
X  ;;;   Clean up some of the definitions in the units table.
X  ;;;
X  ;;;   Provide more examples in the tutorial section of the manual.
X  ;;;   Cover in the tutorial:  language modes, simplification modes,
X! ;;;       bitwise stuff, rewrite rules, selections.
X  ;;;   Provide more Lisp programming examples in the manual.
X! ;;;   Finish the Internals section of the manual (and bring it up to date).
X  ;;;
X  ;;;   Tim suggests adding spreadsheet-like features.
X! ;;;   Is constructive real arithmetic worth implementing?
X  ;;;   Implement language modes for Eqn, Gnuplot, Lisp, Ada, ...?
X  ;;;
X  
X  
X  ;;; For atan series, if x > tan(pi/12) (about 0.268) reduce using the identity
X  ;;;   atan(x) = atan((x * sqrt(3) - 1) / (sqrt(3) + x)) + pi/6.
X  
X***************
X*** 258,591 ****
X  
X  
X  
X! ;;; NOTE: The default values listed below and those defined in
X! ;;;       calc-mode-vars-list must match.
X! 
X! (defvar calc-mode-map nil "Keymap for calc-mode.")
X! (defvar calc-digit-map nil "Keymap for digit entry in calc-mode.")
X! 
X! (defvar calc-trail-pointer nil "\"Current\" entry in trail buffer.")
X! 
X! (defvar calc-stack '((top-of-stack 1)) "Calculator stack.")
X! (defvar calc-undo-list nil "List of previous operations in calc-mode.")
X! (defvar calc-redo-list nil "List of recent undo operations in calc-mode.")
X! (defvar calc-main-buffer nil "The Calculator buffer.")
X! (defvar calc-why nil "Explanations of most recent errors.")
X! (defvar calc-next-why nil)
X! 
X! (defvar calc-last-kill nil "Last number killed in calc-mode.")
X! (defvar calc-previous-alg-entry nil "Previous string entered with algebraic entry.")
X! (defvar calc-dollar-values nil "Values to be used for '$' in expressions.")
X! (defvar calc-dollar-used nil "Highest order of '$' that occur in expression.")
X! (defvar calc-quick-prev-results nil "Previous results from Quick Calc.")
X! 
X! (defvar calc-always-load-extensions nil
X!   "*If non-NIL, load the calc-ext module automatically when calc is loaded.")
X! 
X! (defvar calc-stack-top 1
X!   "Index into calc-stack of \"top\" of stack.
X! This is 1 unless calc-truncate-stack has been used.")
X! 
X! (defvar calc-line-numbering t
X!   "*If non-NIL, display line numbers in Calculator stack.")
X! 
X! (defvar calc-line-breaking t
X!   "*If non-NIL, break long values across multiple lines in Calculator stack.")
X! 
X! (defvar calc-display-just nil
X!   "*If NIL, stack display is left-justified.
X! If 'right, stack display is right-justified.
X! If 'center, stack display is centered."
X! )
X! 
X! (defvar calc-number-radix 10
X!   "*Radix for entry and display of numbers in calc-mode, 2-36.")
X! 
X! (defvar calc-leading-zeros nil
X!   "*If non-NIL, leading zeros are provided to pad integers to calc-word-size.")
X! 
X! (defvar calc-group-digits nil
X!   "*If non-NIL, group digits in large displayed integers by inserting spaces.
X! If an integer, group that many digits at a time.
X! If 't', use 4 for binary and hex, 3 otherwise.")
X! 
X! (defvar calc-group-char ","
X!   "*The character (in the form of a string) to be used for grouping digits.
X! This is used only when calc-group-digits mode is on.")
X! 
X! (defvar calc-point-char "."
X!   "*The character (in the form of a string) to be used as a decimal point.")
X! 
X! (defvar calc-frac-format ":"
X!   "*Format of displayed fractions; a string of one or two of \":\" or \"/\".")
X! 
X! (defvar calc-prefer-frac nil
X!   "*If non-NIL, prefer fractional over floating-point results.")
X! 
X! (defvar calc-hms-format "%s@ %s' %s\""
X!   "*Format of display hours-minutes-seconds angles, a format string.
X! String must contain three %s marks, for hours, minutes, seconds respectively.")
X! 
X! (defvar calc-float-format '(float 0)
X!   "*Format to use for display of floating-point numbers in calc-mode.
X! Must be a list of one of the following forms:
X!    (float 0)      Floating point format, display full precision.
X!    (float N)      N > 0: Floating point format, at most N significant figures.
X!    (float -N)     -N < 0: Floating point format, calc-internal-prec - N figs.
X!    (fix N)        N >= 0: Fixed point format, N places after decimal point.
X!    (sci 0)        Scientific notation, full precision.
X!    (sci N)        N > 0: Scientific notation, N significant figures.
X!    (sci -N)       -N < 0: Scientific notation, calc-internal-prec - N figs.
X!    (eng 0)        Engineering notation, full precision.
X!    (eng N)        N > 0: Engineering notation, N significant figures.
X!    (eng -N)       -N < 0: Engineering notation, calc-internal-prec - N figs.")
X! 
X! (defvar calc-full-float-format '(float 0)
X!   "*Format to use when full precision must be displayed.")
X! 
X! (defvar calc-complex-format nil
X!   "*Format to use for display of complex numbers in calc-mode.  Must be one of:
X!    nil            Use (x, y) form.
X!    i              Use x + yi form.
X!    j              Use x + yj form.")
X! 
X! (defvar calc-complex-mode 'cplx
X!   "*Preferred form, either 'cplx or 'polar, for complex numbers.")
X! 
X! (defvar calc-display-strings nil
X!   "*If non-NIL, display vectors of byte-sized integers as strings.")
X! 
X! (defvar calc-matrix-just 'center
X!   "*If NIL, vector elements are left-justified.
X! If 'right, vector elements are right-justified.
X! If 'center, vector elements are centered."
X! )
X! 
X! (defvar calc-vector-commas ","
X!   "*If non-NIL, separate elements of displayed vectors with this string.")
X! 
X! (defvar calc-vector-brackets "[]"
X!   "*If non-NIL, surround displayed vectors with these characters.")
X! 
X! (defvar calc-function-open "("
X!   "*Open-parenthesis string for function call notation.")
X! 
X! (defvar calc-function-close ")"
X!   "*Close-parenthesis string for function call notation.")
X! 
X! (defvar calc-language nil
X!   "*Language or format for entry and display of stack values.  Must be one of:
X!    nil            Use standard Calc notation.
X!    flat           Use standard Calc notation, one-line format.
X!    big 	          Display formulas in 2-d notation (enter w/standard notation).
X!    unform	  Use unformatted display: add(a, mul(b,c)).
X!    c              Use C language notation.
X!    pascal         Use Pascal language notation.
X!    fortran        Use Fortran language notation.
X!    tex            Use TeX notation.
X!    math           Use Mathematica(tm) notation.")
X! 
X! (defvar calc-language-option nil
X!   "*Numeric prefix argument for the command that set calc-language.")
X! 
X! (defvar calc-language-output-filter nil
X!   "Function through which to pass strings after formatting.")
X! 
X! (defvar calc-language-input-filter nil
X!   "Function through which to pass strings before parsing.")
X! 
X! (defvar calc-radix-formatter nil
X!   "*Formatting function used for non-decimal integers.")
X! 
X! (defvar calc-word-size 32
X!   "*Minimum number of bits per word, if any, for binary operations in calc-mode.")
X! 
X! (defvar calc-previous-modulo nil
X!   "*Most recently used value of M in a modulo form.")
X! 
X! (defvar calc-simplify-mode nil
X!   "*Type of simplification applied to results.
X! If 'none, results are not simplified when pushed on the stack.
X! If 'num, functions are simplified only when args are constant.
X! If NIL, only fast simplifications are applied.
X! If 'binary, math-clip is applied if appropriate.
X! If 'alg, math-simplify is applied.
X! If 'ext, math-simplify-extended is applied.
X! If 'units, math-simplify-units is applied.")
X! 
X! (defvar calc-mapping-dir nil
X!   "*Last direction specified in a Map or Reduce command.")
X! 
X! (defvar calc-display-raw nil
X!   "*If non-NIL, calculator display shows unformatted Lisp exprs.  (For debugging)")
X! 
X! (defvar calc-display-sci-high 0
X!   "*Floating-point numbers with this positive exponent or higher above the
X! current precision are displayed in scientific notation in calc-mode.")
X! 
X! (defvar calc-display-sci-low -3
X!   "*Floating-point numbers with this negative exponent or lower are displayed
X! scientific notation in calc-mode.")
X! 
X! (defvar calc-internal-prec 12
X!   "*Number of digits of internal precision for calc-mode calculations.")
X! 
X! (defvar calc-inverse-flag nil
X!   "*If non-NIL, next operation is Inverse.")
X! 
X! (defvar calc-hyperbolic-flag nil
X!   "*If non-NIL, next operation is Hyperbolic.")
X! 
X! (defvar calc-angle-mode 'deg
X!   "*If deg, angles are in degrees; if rad, angles are in radians.
X! If hms, angles are in degrees-minutes-seconds.")
X! 
X! (defvar calc-algebraic-mode nil
X!   "*If non-NIL, numeric entry accepts whole algebraic expressions.
X! If NIL, algebraic expressions must be preceded by \"'\".")
X! 
X! (defvar calc-symbolic-mode nil
X!   "*If non-NIL, inexact numeric computations like sqrt(2) are postponed.
X! If NIL, computations on numbers always yield numbers where possible.")
X! 
X! (defvar calc-integral-limit 3
X!   "*An integer which governs how long calc-integral will look for an integral.
X! The integrator often uses substitution or integration by parts to transform
X! an integral into another one; this controls how many levels of nested
X! sub-integrations are allowed before a given path is abandoned.")
X! 
X! (defvar calc-window-height 7
X!   "*Initial height of Calculator window.")
X! 
X! (defvar calc-display-trail t
X!   "*If non-NIL, M-x calc creates a window to display Calculator trail.")
X! 
X! (defvar calc-display-working-message 'lots
X!   "*If non-NIL, display \"Working...\" for potentially slow Calculator commands.")
X! 
X! (defvar calc-auto-why nil
X!   "*If non-NIL, automatically execute a \"why\" command to explain odd results.")
X! 
X! (defvar calc-said-hello nil)
X! (defvar calc-executing-macro nil)
X! 
X! 
X! (defvar calc-trail-buffer nil)
X! 
X! 
X! (defvar calc-other-modes nil
X!   "List of used-defined strings to append to Calculator mode line.")
X  
X  
X! (defvar calc-settings-file "~/.emacs"
X!   "*File in which to record permanent settings; default is \"~/.emacs\".")
X  
X  (defvar calc-loaded-settings-file nil)
X  
X  
X! (defvar calc-bug-address "daveg@csvax.caltech.edu"
X!   "*Address of the author of Calc, for use by report-calc-bug.")
X! 
X! 
X! (defvar var-i '(special-const (math-imaginary 1))
X!   "*Calculator variable representing the imaginary constant 'i'.")
X! 
X! (defvar var-pi '(special-const (math-pi))
X!   "*Calculator variable representing the constant 'pi'.")
X! 
X! (defvar var-e '(special-const (math-e))
X!   "*Calculator variable representing the constant 'e'.")
X! 
X! 
X! 
X! ;;; Set up the standard keystroke (M-#) to run the Calculator, if that key
X! ;;; has not yet been bound to anything.  For best results, the user should
X! ;;; do this before Calc is even loaded, so that M-# can auto-load Calc.
X! (or (global-key-binding "\e#")
X!     (global-set-key "\e#" 'calc))
X! 
X! 
X! (defun calc-define-del (map func)
X!   (define-key map "\C-d" func)
X!   (mapcar (function (lambda (x) (condition-case err
X! 				    (define-key map x func)
X! 				  (error nil))))
X! 	  (append (where-is-internal 'delete-backward-char global-map)
X! 		  (where-is-internal 'backward-delete-char global-map)))
X! )
X! 
X! ;; Still unused: f g j O W Y { }
X! (if calc-mode-map
X!     nil
X!   (setq calc-mode-map (make-keymap))
X!   (suppress-keymap calc-mode-map t)
X!   (define-key calc-mode-map "+" 'calc-plus)
X!   (define-key calc-mode-map "-" 'calc-minus)
X!   (define-key calc-mode-map "*" 'calc-times)
X!   (define-key calc-mode-map "/" 'calc-divide)
X!   (define-key calc-mode-map "%" 'calc-mod)
X!   (define-key calc-mode-map "&" 'calc-inv)
X!   (define-key calc-mode-map "^" 'calc-power)
X!   (define-key calc-mode-map "e" 'calcDigit-start)
X!   (define-key calc-mode-map "h" 'describe-mode)
X!   (define-key calc-mode-map "i" 'calc-info)
X!   (define-key calc-mode-map "n" 'calc-change-sign)
X!   (define-key calc-mode-map "o" 'calc-realign)
X!   (define-key calc-mode-map "p" 'calc-precision)
X!   (define-key calc-mode-map "q" 'calc-quit)
X!   (define-key calc-mode-map "w" 'calc-why)
X!   (define-key calc-mode-map "?" 'calc-help)
X!   (define-key calc-mode-map " " 'calc-enter)
X!   (define-key calc-mode-map "<" 'calc-scroll-left)
X!   (define-key calc-mode-map ">" 'calc-scroll-right)
X!   (define-key calc-mode-map "'" 'calc-algebraic-entry)
X!   (define-key calc-mode-map "$" 'calc-auto-alg-entry)
X!   (define-key calc-mode-map "\"" 'calc-auto-alg-entry)
X!   (define-key calc-mode-map "\t" 'calc-roll-down)
X!   (define-key calc-mode-map "\M-\t" 'calc-roll-up)
X!   (define-key calc-mode-map "\C-m" 'calc-enter)
X!   (define-key calc-mode-map "\C-j" 'calc-over)
X!   (calc-define-del calc-mode-map 'calc-pop)
X!   (mapcar (function
X! 	   (lambda (x)
X! 	     (define-key calc-mode-map (char-to-string x) 'undefined)))
X! 	  "fgjOWY{}")
X!   (mapcar (function
X! 	   (lambda (x)
X! 	     (define-key calc-mode-map (char-to-string x) 'calc-missing-key)))
X! 	  (concat "ABCDEFGHIJKLMNPQRSTUVXZabcdklmrstuvxyz"
X! 		  ":\\|!()[],;=~`\C-k\M-k\C-w\M-w\C-y\C-_"))
X!   (mapcar (function
X! 	   (lambda (x)
X! 	     (define-key calc-mode-map (char-to-string x) 'calcDigit-start)))
X! 	  "_0123456789.#@")
X! )
X! 
X! (if calc-digit-map
X!     nil
X!   (setq calc-digit-map (make-keymap))
X!   (let ((i 0))
X!     (while (< i 128)
X!       (aset calc-digit-map i
X! 	    (if (eq (aref calc-mode-map i) 'undefined)
X! 		'undefined 'calcDigit-nondigit))
X!       (setq i (1+ i))))
X!   (mapcar (function
X! 	   (lambda (x)
X! 	     (define-key calc-digit-map (char-to-string x) 'calcDigit-key)))
X! 	  "_0123456789.e+-:n#@oh'\"mspM")
X!   (mapcar (function
X! 	   (lambda (x)
X! 	     (define-key calc-digit-map (char-to-string x) 'calcDigit-letter)))
X! 	  "abcdfgijklqrtuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ")
X!   (define-key calc-digit-map "'" 'calcDigit-algebraic)
X!   (define-key calc-digit-map "\C-g" 'abort-recursive-edit)
X!   (calc-define-del calc-digit-map 'calcDigit-backspace)
X! )
X! 
X! (put 'calc-mode 'mode-class 'special)
X! (put 'calc-trail-mode 'mode-class 'special)
X! 
X  (defconst calc-mode-var-list '((calc-always-load-extensions nil)
X  			       (calc-line-numbering t)
X  			       (calc-line-breaking t)
X--- 327,557 ----
X  
X  
X  
X! ;; Calculator stack.
X! ;; Entries are 3-lists:  Formula, Height (in lines), Selection (or nil).
X! (defvar calc-stack '((top-of-stack 1 nil)))
X  
X+ ;; Index into calc-stack of "top" of stack.
X+ ;; This is 1 unless calc-truncate-stack has been used.
X+ ;;(defvar calc-stack-top 1)
X+ 
X+ ;; If non-NIL, load the calc-ext module automatically when calc is loaded.
X+ ;;(defvar calc-always-load-extensions nil)
X+ 
X+ ;; If non-NIL, display line numbers in Calculator stack.
X+ ;;(defvar calc-line-numbering t)
X+ 
X+ ;; If non-NIL, break long values across multiple lines in Calculator stack.
X+ ;;(defvar calc-line-breaking t)
X+ 
X+ ;; If NIL, stack display is left-justified.
X+ ;; If 'right, stack display is right-justified.
X+ ;; If 'center, stack display is centered."
X+ ;;(defvar calc-display-just nil)
X+ 
X+ ;; Radix for entry and display of numbers in calc-mode, 2-36.
X+ ;;(defvar calc-number-radix 10)
X+ 
X+ ;; If non-NIL, leading zeros are provided to pad integers to calc-word-size.
X+ ;;(defvar calc-leading-zeros nil)
X+ 
X+ ;; If non-NIL, group digits in large displayed integers by inserting spaces.
X+ ;; If an integer, group that many digits at a time.
X+ ;; If 't', use 4 for binary and hex, 3 otherwise.
X+ ;;(defvar calc-group-digits nil)
X+ 
X+ ;; The character (in the form of a string) to be used for grouping digits.
X+ ;; This is used only when calc-group-digits mode is on.
X+ ;;(defvar calc-group-char ",")
X+ 
X+ ;; The character (in the form of a string) to be used as a decimal point.
X+ ;;(defvar calc-point-char ".")
X+ 
X+ ;; Format of displayed fractions; a string of one or two of ":" or "/".
X+ ;;(defvar calc-frac-format ":")
X+ 
X+ ;; If non-NIL, prefer fractional over floating-point results.
X+ ;;(defvar calc-prefer-frac nil)
X+ 
X+ ;; Format of display hours-minutes-seconds angles, a format string.
X+ ;; String must contain three %s marks for hours, minutes, seconds respectively.
X+ ;;(defvar calc-hms-format "%s@ %s' %s\"")
X+ 
X+ ;; Format to use for display of floating-point numbers in calc-mode.
X+ ;; Must be a list of one of the following forms:
X+ ;;  (float 0)      Floating point format, display full precision.
X+ ;;  (float N)      N > 0: Floating point format, at most N significant figures.
X+ ;;  (float -N)     -N < 0: Floating point format, calc-internal-prec - N figs.
X+ ;;  (fix N)        N >= 0: Fixed point format, N places after decimal point.
X+ ;;  (sci 0)        Scientific notation, full precision.
X+ ;;  (sci N)        N > 0: Scientific notation, N significant figures.
X+ ;;  (sci -N)       -N < 0: Scientific notation, calc-internal-prec - N figs.
X+ ;;  (eng 0)        Engineering notation, full precision.
X+ ;;  (eng N)        N > 0: Engineering notation, N significant figures.
X+ ;;  (eng -N)       -N < 0: Engineering notation, calc-internal-prec - N figs.
X+ ;;(defvar calc-float-format '(float 0))
X+ 
X+ ;; Format to use when full precision must be displayed.
X+ ;;(defvar calc-full-float-format '(float 0))
X+ 
X+ ;; Format to use for display of complex numbers in calc-mode.  Must be one of:
X+ ;;   nil            Use (x, y) form.
X+ ;;   i              Use x + yi form.
X+ ;;   j              Use x + yj form.
X+ ;;(defvar calc-complex-format nil)
X+ 
X+ ;; Preferred form, either 'cplx or 'polar, for complex numbers.
X+ ;;(defvar calc-complex-mode 'cplx)
X+ 
X+ ;; If non-NIL, display vectors of byte-sized integers as strings.
X+ ;;(defvar calc-display-strings nil)
X+ 
X+ ;; If NIL, vector elements are left-justified.
X+ ;; If 'right, vector elements are right-justified.
X+ ;; If 'center, vector elements are centered."
X+ ;;(defvar calc-matrix-just 'center)
X+ 
X+ ;; If non-NIL, display vectors one element per line.
X+ ;;(defvar calc-break-vectors nil)
X+ 
X+ ;; If non-NIL, display long vectors in full.  If NIL, use abbreviated form.
X+ ;;(defvar calc-full-vectors t)
X+ 
X+ ;; If non-NIL, display long vectors in full in the trail.
X+ ;;(defvar calc-full-trail-vectors t)
X+ 
X+ ;; If non-NIL, separate elements of displayed vectors with this string.
X+ ;;(defvar calc-vector-commas ",")
X+ 
X+ ;; If non-NIL, surround displayed vectors with these characters.
X+ ;;(defvar calc-vector-brackets "[]")
X+ 
X+ ;; Language or format for entry and display of stack values.  Must be one of:
X+ ;;   nil            Use standard Calc notation.
X+ ;;   flat           Use standard Calc notation, one-line format.
X+ ;;   big 	    Display formulas in 2-d notation (enter w/std notation).
X+ ;;   unform	    Use unformatted display: add(a, mul(b,c)).
X+ ;;   c              Use C language notation.
X+ ;;   pascal         Use Pascal language notation.
X+ ;;   fortran        Use Fortran language notation.
X+ ;;   tex            Use TeX notation.
X+ ;;   math           Use Mathematica(tm) notation.
X+ ;;(defvar calc-language nil)
X+ 
X+ ;; Numeric prefix argument for the command that set calc-language.
X+ ;;(defvar calc-language-option nil)
X+ 
X+ ;; Open-parenthesis string for function call notation.
X+ ;;(defvar calc-function-open "(")
X+ 
X+ ;; Close-parenthesis string for function call notation.
X+ ;;(defvar calc-function-close ")")
X+ 
X+ ;; Function through which to pass strings after formatting.
X+ ;;(defvar calc-language-output-filter nil)
X+ 
X+ ;; Function through which to pass strings before parsing.
X+ ;;(defvar calc-language-input-filter nil)
X+ 
X+ ;; Formatting function used for non-decimal integers.
X+ ;;(defvar calc-radix-formatter nil)
X+ 
X+ ;; Minimum number of bits per word, if any, for binary operations in calc-mode.
X+ ;;(defvar calc-word-size 32)
X+ 
X+ ;; Most recently used value of M in a modulo form.
X+ ;;(defvar calc-previous-modulo nil)
X+ 
X+ ;; Type of simplification applied to results.
X+ ;; If 'none, results are not simplified when pushed on the stack.
X+ ;; If 'num, functions are simplified only when args are constant.
X+ ;; If NIL, only fast simplifications are applied.
X+ ;; If 'binary, math-clip is applied if appropriate.
X+ ;; If 'alg, math-simplify is applied.
X+ ;; If 'ext, math-simplify-extended is applied.
X+ ;; If 'units, math-simplify-units is applied.
X+ ;;(defvar calc-simplify-mode nil)
X+ 
X+ ;; Last direction specified in a Map or Reduce command.
X+ ;;(defvar calc-mapping-dir nil)
X+ 
X+ ;; If non-NIL, display shows unformatted Lisp exprs.  (For debugging)
X+ ;;(defvar calc-display-raw nil)
X+ 
X+ ;; Number of digits of internal precision for calc-mode calculations.
X+ ;;(defvar calc-internal-prec 12)
X+ 
X+ ;; If non-NIL, next operation is Inverse.
X+ ;;(defvar calc-inverse-flag nil)
X+ 
X+ ;; If non-NIL, next operation is Hyperbolic.
X+ ;;(defvar calc-hyperbolic-flag nil)
X+ 
X+ ;; If deg, angles are in degrees; if rad, angles are in radians.
X+ ;; If hms, angles are in degrees-minutes-seconds.
X+ ;;(defvar calc-angle-mode 'deg)
X+ 
X+ ;; If non-NIL, numeric entry accepts whole algebraic expressions.
X+ ;; If NIL, algebraic expressions must be preceded by "'".
X+ ;;(defvar calc-algebraic-mode nil)
X+ 
X+ ;; Like calc-algebraic-mode except only affects ( and [ keys.
X+ ;;(defvar calc-incomplete-algebraic-mode nil)
X+ 
X+ ;; If non-NIL, inexact numeric computations like sqrt(2) are postponed.
X+ ;; If NIL, computations on numbers always yield numbers where possible.
X+ ;;(defvar calc-symbolic-mode nil)
X+ 
X+ ;; An integer which governs how long calc-integral will look for an integral.
X+ ;; The integrator often uses substitution or integration by parts to transform
X+ ;; an integral into another one; this controls how many levels of nested
X+ ;; sub-integrations are allowed before a given path is abandoned.
X+ ;;(defvar calc-integral-limit 3)
X+ 
X+ ;; If non-NIL, shifted letter keys are prefix keys rather than normal meanings.
X+ ;;(defvar calc-shift-prefix nil)
X+ 
X+ ;; Initial height of Calculator window.
X+ ;;(defvar calc-window-height 7)
X+ 
X+ ;; If non-NIL, M-x calc creates a window to display Calculator trail.
X+ ;;(defvar calc-display-trail t)
X+ 
X+ ;; If non-NIL, selected sub-formulas are shown by obscuring rest of formula.
X+ ;; If NIL, selected sub-formulas are highlighted by obscuring the sub-formulas.
X+ ;;(defvar calc-show-selections t)
X+ 
X+ ;; If non-NIL, commands operate only on selected portions of formulas.
X+ ;; If NIL, selections displayed but ignored.
X+ ;;(defvar calc-use-selections t)
X+ 
X+ ;; If non-NIL, selection hides deep structure of associative formulas.
X+ ;;(defvar calc-assoc-selections t)
X+ 
X+ ;; If non-NIL, display "Working..." for potentially slow Calculator commands.
X+ ;;(defvar calc-display-working-message 'lots)
X+ 
X+ ;; If non-NIL, automatically execute a "why" command to explain odd results.
X+ ;;(defvar calc-auto-why nil)
X+ 
X+ 
X+ ;; Floating-point numbers with this positive exponent or higher above the
X+ ;; current precision are displayed in scientific notation in calc-mode.
X+ (defvar calc-display-sci-high 0)
X+ 
X+ ;; Floating-point numbers with this negative exponent or lower are displayed
X+ ;; scientific notation in calc-mode.
X+ (defvar calc-display-sci-low -3)
X+ 
X  
X! ;; List of used-defined strings to append to Calculator mode line.
X! (defvar calc-other-modes nil)
X  
X+ ;; T if calc-settings-file has been loaded yet.
X  (defvar calc-loaded-settings-file nil)
X  
X  
X!   
X  (defconst calc-mode-var-list '((calc-always-load-extensions nil)
X  			       (calc-line-numbering t)
X  			       (calc-line-breaking t)
X***************
X*** 602,625 ****
X  			       (calc-full-float-format (float 0))
X  			       (calc-complex-format nil)
X  			       (calc-matrix-just center)
X  			       (calc-vector-commas ",")
X  			       (calc-vector-brackets "[]")
X  			       (calc-complex-mode cplx)
X  			       (calc-simplify-mode nil)
X  			       (calc-mapping-dir nil)
X  			       (calc-word-size 32)
X  			       (calc-previous-modulo nil)
X  			       (calc-internal-prec 12)
X  			       (calc-angle-mode deg)
X  			       (calc-algebraic-mode nil)
X  			       (calc-symbolic-mode nil)
X  			       (calc-integral-limit 3)
X  			       (calc-window-height 7)
X  			       (calc-language nil)
X  			       (calc-language-option nil)
X  			       (calc-display-trail t)
X  			       (calc-display-working-message lots)
X! 			       (calc-auto-why nil)))
X  
X  (defconst calc-local-var-list '(calc-stack
X  				calc-stack-top
X--- 568,607 ----
X  			       (calc-full-float-format (float 0))
X  			       (calc-complex-format nil)
X  			       (calc-matrix-just center)
X+ 			       (calc-full-vectors t)
X+ 			       (calc-full-trail-vectors t)
X+ 			       (calc-break-vectors nil)
X  			       (calc-vector-commas ",")
X  			       (calc-vector-brackets "[]")
X  			       (calc-complex-mode cplx)
X+ 			       (calc-display-strings nil)
X  			       (calc-simplify-mode nil)
X  			       (calc-mapping-dir nil)
X  			       (calc-word-size 32)
X  			       (calc-previous-modulo nil)
X+ 			       (calc-display-raw nil)
X  			       (calc-internal-prec 12)
X  			       (calc-angle-mode deg)
X  			       (calc-algebraic-mode nil)
X+ 			       (calc-incomplete-algebraic-mode nil)
X  			       (calc-symbolic-mode nil)
X  			       (calc-integral-limit 3)
X+ 			       (calc-shift-prefix nil)
X  			       (calc-window-height 7)
X  			       (calc-language nil)
X  			       (calc-language-option nil)
X+ 			       (calc-show-selections t)
X+ 			       (calc-use-selections t)
X+ 			       (calc-assoc-selections t)
X  			       (calc-display-trail t)
X  			       (calc-display-working-message lots)
X! 			       (calc-auto-why nil)
X! 			       (calc-gnuplot-default-device "default")
X! 			       (calc-gnuplot-default-output "/dev/null")
X! 			       (calc-gnuplot-print-device "postscript")
X! 			       (calc-gnuplot-print-output "auto")
X! 			       (calc-gnuplot-geometry nil)
X! 			       (calc-graph-default-resolution 15)))
X  
X  (defconst calc-local-var-list '(calc-stack
X  				calc-stack-top
X***************
X*** 632,637 ****
X--- 614,620 ----
X  				calc-display-just
X  				calc-auto-why
X  				calc-algebraic-mode
X+ 				calc-incomplete-algebraic-mode
X  				calc-symbolic-mode
X  				calc-integral-limit
X  				calc-inverse-flag
X***************
X*** 649,663 ****
X--- 632,790 ----
X  				calc-full-float-format
X  				calc-complex-format
X  				calc-matrix-just
X+ 				calc-full-vectors
X+ 				calc-full-trail-vectors
X+ 				calc-break-vectors
X  				calc-vector-commas
X  				calc-vector-brackets
X  				calc-complex-mode
X+ 				calc-display-strings
X  				calc-simplify-mode
X  				calc-mapping-dir
X+ 				calc-show-selections
X+ 				calc-use-selections
X+ 				calc-assoc-selections
X  				calc-word-size
X  				calc-internal-prec))
X  
X  
X+ (defun calc-init-base ()
X+ 
X+   ;; Set up the standard keystroke (M-#) to run the Calculator, if that key
X+   ;; has not yet been bound to anything.  For best results, the user should
X+   ;; do this before Calc is even loaded, so that M-# can auto-load Calc.
X+   (or (global-key-binding "\e#")
X+       (global-set-key "\e#" 'calc))
X+   
X+   (put 'calc-mode 'mode-class 'special)
X+   (put 'calc-trail-mode 'mode-class 'special)
X+   
X+   ;; Define "inexact-result" as an e-lisp error symbol.
X+   (put 'inexact-result 'error-conditions '(error inexact-result calc-error))
X+   (put 'inexact-result 'error-message "Calc internal error (inexact-result)")
X+   
X+   (setq calc-trail-pointer nil		; "Current" entry in trail buffer.
X+         calc-trail-overlay nil		; Value of overlay-arrow-string.
X+         calc-undo-list nil		; List of previous operations for undo.
X+         calc-redo-list nil		; List of recent undo operations.
X+         calc-main-buffer nil		; Pointer to Calculator buffer.
X+ 	calc-trail-buffer nil		; Pointer to Calc Trail buffer.
X+         calc-why nil			; Explanations of most recent errors.
X+         calc-next-why nil
X+ 	calc-inverse-flag nil
X+ 	calc-hyperbolic-flag nil
X+ 	calc-function-open "("
X+ 	calc-function-close ")"
X+ 	calc-language-output-filter nil
X+ 	calc-language-input-filter nil
X+ 	calc-radix-formatter nil
X+         calc-last-kill nil		; Last number killed in calc-mode.
X+         calc-previous-alg-entry nil	; Previous algebraic entry.
X+         calc-dollar-values nil		; Values to be used for '$'.
X+         calc-dollar-used nil		; Highest order of '$' that occurred.
X+         calc-quick-prev-results nil	; Previous results from Quick Calc.
X+ 	calc-said-hello nil		; Has calc-summary been called yet?
X+ 	calc-executing-macro nil	; Kbd macro executing from "K" key.
X+ 	calc-any-selections nil 	; Nil means no selections present.
X+ 	calc-help-phase 0		; Count of consecutive "?" keystrokes.
X+ 	calc-full-help-flag nil		; Executing calc-full-help?
X+ 	calc-refresh-count 0		; Count of calc-refresh calls.
X+ 	calc-prepared-composition nil
X+ 	calc-selection-cache-default-entry nil
X+ 	math-radix-explicit-format t
X+ 	math-expr-function-mapping nil
X+ 	math-expr-variable-mapping nil
X+ 	math-read-expr-quotes nil
X+         var-i '(special-const (math-imaginary 1))
X+         var-pi '(special-const (math-pi))
X+         var-e '(special-const (math-e)))
X+ 
X+   (mapcar (function (lambda (v) (or (boundp (car v)) (set (car v) (nth 1 v)))))
X+ 	  calc-mode-var-list)
X+   (mapcar (function (lambda (v) (or (boundp v) (set v nil))))
X+ 	  calc-local-var-list)
X+ 
X+   (if (boundp 'calc-mode-map)
X+       nil
X+     (setq calc-mode-map (make-keymap))
X+     (suppress-keymap calc-mode-map t)
X+     (define-key calc-mode-map "+" 'calc-plus)
X+     (define-key calc-mode-map "-" 'calc-minus)
X+     (define-key calc-mode-map "*" 'calc-times)
X+     (define-key calc-mode-map "/" 'calc-divide)
X+     (define-key calc-mode-map "%" 'calc-mod)
X+     (define-key calc-mode-map "&" 'calc-inv)
X+     (define-key calc-mode-map "^" 'calc-power)
X+     (define-key calc-mode-map "e" 'calcDigit-start)
X+     (define-key calc-mode-map "i" 'calc-info)
X+     (define-key calc-mode-map "n" 'calc-change-sign)
X+     (define-key calc-mode-map "q" 'calc-quit)
X+     (define-key calc-mode-map "?" 'calc-help)
X+     (define-key calc-mode-map " " 'calc-enter)
X+     (define-key calc-mode-map "'" 'calc-algebraic-entry)
X+     (define-key calc-mode-map "$" 'calc-algebraic-entry)
X+     (define-key calc-mode-map "\"" 'calc-algebraic-entry)
X+     (define-key calc-mode-map "\t" 'calc-roll-down)
X+     (define-key calc-mode-map "\M-\t" 'calc-roll-up)
X+     (define-key calc-mode-map "\C-m" 'calc-enter)
X+     (define-key calc-mode-map "\C-j" 'calc-over)
X+ 
X+     (mapcar (function
X+ 	     (lambda (x)
X+ 	       (define-key calc-mode-map (char-to-string x) 'undefined)))
X+ 	    "jOWY{}")
X+     (mapcar (function
X+ 	     (lambda (x)
X+ 	       (define-key calc-mode-map (char-to-string x)
X+ 		 'calc-missing-key)))
X+ 	    (concat "ABCDEFGHIJKLMNPQRSTUVXZabcdfghklmoprstuvwxyz"
X+ 		    ":\\|!()[]<>,;=~`\C-k\M-k\C-w\M-w\C-y\C-_"))
X+     (mapcar (function
X+ 	     (lambda (x)
X+ 	       (define-key calc-mode-map (char-to-string x) 'calcDigit-start)))
X+ 	    "_0123456789.#@")
X+ 
X+     (setq calc-digit-map (make-keymap))
X+     (let ((i 0))
X+       (while (< i 128)
X+ 	(aset calc-digit-map i
X+ 	      (if (eq (aref calc-mode-map i) 'undefined)
X+ 		  'undefined 'calcDigit-nondigit))
X+ 	(setq i (1+ i))))
X+     (mapcar (function
X+ 	     (lambda (x)
X+ 	       (define-key calc-digit-map (char-to-string x)
X+ 		 'calcDigit-key)))
X+ 	    "_0123456789.e+-:n#@oh'\"mspM")
X+     (mapcar (function
X+ 	     (lambda (x)
X+ 	       (define-key calc-digit-map (char-to-string x)
X+ 		 'calcDigit-letter)))
X+ 	    "abcdfgijklqrtuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ")
X+     (define-key calc-digit-map "'" 'calcDigit-algebraic)
X+     (define-key calc-digit-map "`" 'calcDigit-edit)
X+     (define-key calc-digit-map "\C-g" 'abort-recursive-edit)
X+ 
X+     (mapcar (function
X+ 	     (lambda (x)
X+ 	       (condition-case err
X+ 		   (progn
X+ 		     (define-key calc-digit-map x 'calcDigit-backspace)
X+ 		     (define-key calc-mode-map x 'calc-pop))
X+ 		 (error nil))))
X+ 	    (if calc-scan-for-dels
X+ 		(append (where-is-internal 'delete-backward-char global-map)
X+ 			(where-is-internal 'backward-delete-char global-map)
X+ 			'("\C-d"))
X+ 	      '("\177" "\C-d"))))
X+ 
X+ ;;;; (Autoloads here)
X+ 
X+ )
X+ 
X+ (calc-init-base)
X+ 
X+ 
X  (defun calc-mode ()
X    "Calculator major mode.
X  
X***************
X*** 692,715 ****
X    (kill-all-local-variables)
X    (use-local-map calc-mode-map)
X    (mapcar (function (lambda (v) (make-local-variable v))) calc-local-var-list)
X    (setq truncate-lines t)
X    (setq buffer-read-only t)
X    (setq major-mode 'calc-mode)
X    (setq mode-name "Calculator")
X!   (if (memq 'top-of-stack (mapcar 'car-safe calc-stack))
X!       (setq calc-stack (copy-sequence calc-stack))
X!     (setq calc-stack '((top-of-stack 1))
X! 	  calc-stack-top 1))   ; backward compatibility
X    (or calc-loaded-settings-file
X        (string-match "\\.emacs" calc-settings-file)
X        (progn
X  	(setq calc-loaded-settings-file t)
X  	(load calc-settings-file t)))   ; t = missing-ok
X!   (if (eq window-system 'x)
X        (progn
X  	(or (boundp 'calc-old-x-paste-text)
X  	    (setq calc-old-x-paste-text (symbol-function 'x-paste-text)))
X! 	(define-key mouse-map x-button-middle 'calc-x-paste-text)))
X    (run-hooks 'calc-mode-hook)
X    (calc-refresh t)
X    (calc-set-mode-line)
X--- 819,846 ----
X    (kill-all-local-variables)
X    (use-local-map calc-mode-map)
X    (mapcar (function (lambda (v) (make-local-variable v))) calc-local-var-list)
X+   (make-local-variable 'overlay-arrow-position)
X+   (make-local-variable 'overlay-arrow-string)
X    (setq truncate-lines t)
X    (setq buffer-read-only t)
X    (setq major-mode 'calc-mode)
X    (setq mode-name "Calculator")
X!   (setq calc-stack-top (length (or (memq (assq 'top-of-stack calc-stack)
X! 					 calc-stack)
X! 				   (setq calc-stack (list (list 'top-of-stack
X! 								1 nil))))))
X!   (setq calc-stack-top (- (length calc-stack) calc-stack-top -1))
X    (or calc-loaded-settings-file
X        (string-match "\\.emacs" calc-settings-file)
X        (progn
X  	(setq calc-loaded-settings-file t)
X  	(load calc-settings-file t)))   ; t = missing-ok
X!   (if (and (eq window-system 'x) (fboundp 'x-paste-text))
X        (progn
X  	(or (boundp 'calc-old-x-paste-text)
X  	    (setq calc-old-x-paste-text (symbol-function 'x-paste-text)))
X! 	(substitute-key-definition 'x-paste-text 'calc-x-paste-text
X! 				   mouse-map)))
X    (run-hooks 'calc-mode-hook)
X    (calc-refresh t)
X    (calc-set-mode-line)
X***************
X*** 741,751 ****
X        (let ((buffer-read-only nil))
X  	(insert calc-version
X  		"\n")))
X-   (or (and calc-trail-pointer
X- 	   (eq (marker-buffer calc-trail-pointer) (current-buffer)))
X-       (save-excursion
X- 	(goto-line 2)
X- 	(setq calc-trail-pointer (point-marker))))
X    (run-hooks 'calc-trail-mode-hook)
X  )
X  
X--- 872,877 ----
X***************
X*** 773,779 ****
X  	  (progn
X  	    (calc-extensions)
X  	    (if (< (prefix-numeric-value arg) 0)
X! 		(calc-grab-region (region-beginning) (region-end)))))
X      (if (eq major-mode 'calc-mode)
X  	(calc-quit)
X        (let ((oldbuf (current-buffer)))
X--- 899,905 ----
X  	  (progn
X  	    (calc-extensions)
X  	    (if (< (prefix-numeric-value arg) 0)
X! 		(calc-grab-region (region-beginning) (region-end) nil))))
X      (if (eq major-mode 'calc-mode)
X  	(calc-quit)
X        (let ((oldbuf (current-buffer)))
X***************
X*** 802,814 ****
X  	       (= (window-width) (screen-width))
X  	       (calc-trail-display 1 t)))
X  	(calc-summary full-display)
X  	(and calc-said-hello
X  	     (interactive-p)
X  	     (progn
X  	       (sit-for 2)
X  	       (message "")))
X! 	(setq calc-said-hello t)
X! 	(run-hooks 'calc-start-hook))))
X  )
X  
X  (defun full-calc ()
X--- 928,940 ----
X  	       (= (window-width) (screen-width))
X  	       (calc-trail-display 1 t)))
X  	(calc-summary full-display)
X+ 	(run-hooks 'calc-start-hook)
X  	(and calc-said-hello
X  	     (interactive-p)
X  	     (progn
X  	       (sit-for 2)
X  	       (message "")))
X! 	(setq calc-said-hello t))))
X  )
X  
X  (defun full-calc ()
X***************
X*** 817,822 ****
X--- 943,950 ----
X    (calc nil t)
X  )
X  
X+ ;;;; [calc-misc.el]
X+ 
X  (defun another-calc ()
X    "Create another, independent Calculator buffer."
X    (interactive)
X***************
X*** 829,834 ****
X--- 957,964 ----
X    (calc-mode)
X  )
X  
X+ ;;;; [calc.el]
X+ 
X  (defun calc-quit ()
X    "Close the Calculator window(s).
X  This does not destroy the Calculator buffers or forget the stack contents,
X***************
X*** 845,851 ****
X  	     (< (window-height win) (1- (screen-height))))
X  	(setq calc-window-height (- (window-height win) 2)))
X      (delete-windows-on buf)
X!     (delete-windows-on calc-trail-buffer)
X      (bury-buffer buf)
X      (bury-buffer calc-trail-buffer))
X  )
X--- 975,981 ----
X  	     (< (window-height win) (1- (screen-height))))
X  	(setq calc-window-height (- (window-height win) 2)))
X      (delete-windows-on buf)
X!     (delete-windows-on (calc-trail-buffer))
X      (bury-buffer buf)
X      (bury-buffer calc-trail-buffer))
X  )
X***************
X*** 853,878 ****
X  (defun quick-calc ()
X    "Do a quick calculation in the minibuffer without invoking full Calculator."
X    (interactive)
X!   (save-excursion
X!     (calc-create-buffer)
X!     (let* ((calc-command-flags nil)
X! 	   (calc-language (if (memq calc-language '(nil big))
X! 			      'flat calc-language))
X! 	   (calc-dollar-values calc-quick-prev-results)
X! 	   (calc-dollar-used 0)
X! 	   (enable-recursive-minibuffers t)
X! 	   (alg-exp (calc-do-alg-entry "" "Quick calc: "))
X! 	   buf)
X!       (setq calc-quick-prev-results alg-exp)
X!       (while alg-exp
X! 	(setq buf (concat buf
X! 			  (and buf " ")
X! 			  (if calc-extensions-loaded
X! 			      (math-format-value (car alg-exp) 1000)
X! 			    (math-format-flat-expr (car alg-exp) 0)))
X! 	      alg-exp (cdr alg-exp)))
X!       (calc-handle-whys)
X!       (message buf)))
X  )
X  
X  (defun calc-eval (str &optional separator &rest args)
X--- 983,989 ----
X  (defun quick-calc ()
X    "Do a quick calculation in the minibuffer without invoking full Calculator."
X    (interactive)
X!   (calc-do-quick-calc)
X  )
X  
X  (defun calc-eval (str &optional separator &rest args)
X***************
X*** 879,884 ****
X--- 990,1026 ----
X    "Do a quick calculation and return the result as a string.
X  Return value will either be the formatted result in string form,
X  or a list containing a character position and an error message in string form."
X+   "Do a quick calculation in the minibuffer without invoking full Calculator."
X+   (interactive)
X+   (calc-do-calc-eval str separator args)
X+ )
X+ 
X+ ;;;; [calc-aent.el]
X+ 
X+ (defun calc-do-quick-calc ()
X+   (if (eq major-mode 'calc)
X+       (calc-algebraic-entry)
X+     (save-excursion
X+       (calc-create-buffer)
X+       (let* ((calc-command-flags nil)
X+ 	     (calc-language (if (memq calc-language '(nil big))
X+ 				'flat calc-language))
X+ 	     (calc-dollar-values calc-quick-prev-results)
X+ 	     (calc-dollar-used 0)
X+ 	     (enable-recursive-minibuffers t)
X+ 	     (alg-exp (calc-do-alg-entry "" "Quick calc: "))
X+ 	     buf)
X+ 	(setq calc-quick-prev-results alg-exp)
X+ 	(while alg-exp
X+ 	  (setq buf (concat buf
X+ 			    (and buf " ")
X+ 			    (math-format-value (car alg-exp) 1000))
X+ 		alg-exp (cdr alg-exp)))
X+ 	(calc-handle-whys)
X+ 	(message buf))))
X+ )
X+ 
X+ (defun calc-do-calc-eval (str separator args)
X    (save-excursion
X      (calc-create-buffer)
SHAR_EOF
echo "End of part 1, continue with part 2"
echo "2" > s2_seq_.tmp
exit 0