[gnu.emacs.sources] Patch for Gnu Emacs Calc, 1.06 -> 1.07, part 1/3

daveg@near.cs.caltech.edu (Dave Gillespie) (10/31/90)

In the 1.06 patches I mentioned I had to put Calc aside for now
in favor of other work.  What's this patch, then?  Never you mind.
But this really will be the last udpate for a while...  :-)

								-- 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.06 into Calc
Xversion 1.07.  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 or calc-install, follow these steps to apply
Xthe patches (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
XSee the instructions at the front of the file calc-INSTALL to see how
Xto install the newly patched Calc.
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	Wed Oct 24 02:19:42 1990
X--- ../dist/calc.el	Tue Oct 30 08:33:46 1990
X***************
X*** 1,4 ****
X! ;; Calculator for GNU Emacs version 1.06
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.07
X  ;; Copyright (C) 1990 Dave Gillespie
X  
X  ;; This file is part of GNU Emacs.
X***************
X*** 66,71 ****
X--- 66,92 ----
X  ;;; and "defmath".  User-accessible variables begin with "var-".
X  
X  
X+ ;;; Version 1.07:
X+ ;;;  * Added `m F' (calc-settings-file-name) command.
X+ ;;;  * Added calc-autoload-directory variable.
X+ ;;;  * Extended Z ` to accept a prefix argument.
X+ ;;;  * Added keystrokes (v h, v k) for head, tail, cons.
X+ ;;;  * Extended `v e' to accept a vector as the filler.
X+ ;;;  * Changed `V M', `V R' to accept mapping-mode keys in uppercase, too.
X+ ;;;  * Changed V M ' etc. to accept $, $$, ... as argument indicators.
X+ ;;;  * Changed `t y' to accept a prefix argument.
X+ ;;;  * Put in a cleaner and safer random number generator for `k r' et al.
X+ ;;;  * Fixed a bug which completely broke `a r' command!
X+ ;;;  * Fixed "0 * matrix" to generate a zero matrix instead of 0.
X+ ;;;  * Fixed a bug in `a R' which sometimes caused it to crash.
X+ ;;;  * Fixed a fatal typo in the TeX version of the manual.
X+ ;;;  * Fixed a bug that prevented C-k, C-w, M-w from working in Trail buffer.
X+ ;;;  * Fixed another bug in `Z P' command.
X+ ;;;  * Fixed a bug in `u s' which incorrectly simplified subtractions.
X+ ;;;  * Fixed an argument-name aliasing bug evaluating lambda( ) formulas.
X+ ;;;  * Fixed overfull hboxes in the manual.
X+ ;;;  * Fixed various other bugs in the manual.
X+ ;;; 
X  ;;; Version 1.06:
X  ;;;  * Added "calc-keypad" mode for X window system users (try it!).
X  ;;;  * Improved "calc-eval" for calling/operating Calc from user-written Lisp.
X***************
X*** 200,206 ****
X  
X  (defmacro calc-record-compilation-date-macro ()
X    (` (setq calc-version (, (concat "Emacs Calc Mode"
X! 				   " v1.06 by Dave Gillespie"
X  				   ", installed "
X  				   (current-time-string)
X  				   " by "
X--- 221,227 ----
X  
X  (defmacro calc-record-compilation-date-macro ()
X    (` (setq calc-version (, (concat "Emacs Calc Mode"
X! 				   " v1.07 by Dave Gillespie"
X  				   ", installed "
X  				   (current-time-string)
X  				   " by "
X***************
X*** 220,226 ****
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--- 241,252 ----
X  
X  (defvar calc-settings-file "~/.emacs"
X    "*File in which to record permanent settings; default is \"~/.emacs\".")
X! 
X! (defvar calc-autoload-directory nil
X!   "Name of directory from which .elc files made by calc-split or calc-install
X! should be loaded.  Should include a trailing \"/\".
X! If nil, use original installation directory.")
X! 
X  (defvar calc-gnuplot-name "gnuplot"
X    "*Name of GNUPLOT program, for calc-graph features.")
X  
X***************
X*** 284,289 ****
X--- 310,316 ----
X  ;;;
X  ;;;   How about matrix eigenvalues, SVD, pseudo-inverse, etc.?
X  ;;;   Should cache matrix inverses as well as decompositions.
X+ ;;;   If dividing by a non-square matrix, use least-squares automatically.
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*** 316,323 ****
X  ;;;   Is constructive real arithmetic worth implementing?
X  ;;;   Implement language modes for Eqn, Gnuplot, Lisp, Ada, ...?
X  ;;;
X- ;;;   "2 M 7 SPC 5 M 13 * 4 M 7 *" goes into an infinite recursion.
X- ;;;
X  
X  
X  ;;; For atan series, if x > tan(pi/12) (about 0.268) reduce using the identity
X--- 343,348 ----
X***************
X*** 1730,1736 ****
X  	   (null (buffer-name calc-trail-buffer)))
X         (save-excursion
X  	 (setq calc-trail-buffer (get-buffer-create "*Calc Trail*"))
X! 	 (let ((buf (current-buffer)))
X  	   (set-buffer calc-trail-buffer)
X  	   (or (eq major-mode 'calc-trail-mode)
X  	       (calc-trail-mode buf)))))
X--- 1755,1763 ----
X  	   (null (buffer-name calc-trail-buffer)))
X         (save-excursion
X  	 (setq calc-trail-buffer (get-buffer-create "*Calc Trail*"))
X! 	 (let ((buf (or (and (not (eq major-mode 'calc-mode))
X! 			     (get-buffer "*Calculator*"))
X! 			(current-buffer))))
X  	   (set-buffer calc-trail-buffer)
X  	   (or (eq major-mode 'calc-trail-mode)
X  	       (calc-trail-mode buf)))))
X***************
X*** 3002,3007 ****
X--- 3029,3043 ----
X  	 (cons (car a) (mapcar 'math-float (cdr a))))
X  	((eq (car a) 'intv)
X  	 (cons (car a) (cons (nth 1 a) (mapcar 'math-float (nthcdr 2 a)))))
X+ 	((and (memq (car a) '(* /))
X+ 	      (math-numberp (nth 1 a)))
X+ 	 (list (car a) (math-float (nth 1 a))
X+ 	       (list 'calcFunc-float (nth 2 a))))
X+ 	((and (eq (car a) '/)
X+ 	      (eq (car (nth 1 a)) '*)
X+ 	      (math-numberp (nth 1 (nth 1 a))))
X+ 	 (list '* (math-float (nth 1 (nth 1 a)))
X+ 	       (list 'calcFunc-float (list '/ (nth 2 (nth 1 a)) (nth 2 a)))))
X  	(t (math-reject-arg a 'objectp)))
X  )
X  (fset 'calcFunc-float (symbol-function 'math-float))
X***************
X*** 3349,3357 ****
X  	(< a 1000) (> a -1000) (< b 1000) (> b -1000)
X  	(* a b))
X     (and (Math-zerop a) (not (eq (car-safe b) 'mod))
X! 	(if (and (math-floatp b) (Math-ratp a)) (math-float a) a))
X     (and (Math-zerop b) (not (eq (car-safe a) 'mod))
X! 	(if (and (math-floatp a) (Math-ratp b)) (math-float b) b))
X     (and (Math-objvecp a) (Math-objvecp b)
X  	(or
X  	 (and (Math-integerp a) (Math-integerp b)
X--- 3385,3397 ----
X  	(< a 1000) (> a -1000) (< b 1000) (> b -1000)
X  	(* a b))
X     (and (Math-zerop a) (not (eq (car-safe b) 'mod))
X! 	(if (math-matrixp b)
X! 	    (math-diag-matrix 0 (1- (length b)))
X! 	  (if (and (math-floatp b) (Math-ratp a)) (math-float a) a)))
X     (and (Math-zerop b) (not (eq (car-safe a) 'mod))
X! 	(if (math-matrixp a)
X! 	    (math-diag-matrix 0 (1- (length a)))
X! 	  (if (and (math-floatp a) (Math-ratp b)) (math-float b) b)))
X     (and (Math-objvecp a) (Math-objvecp b)
X  	(or
X  	 (and (Math-integerp a) (Math-integerp b)
X***************
X*** 4455,4461 ****
X    (interactive "sBug Subject: ")
X    (mail nil calc-bug-address topic)
X    (goto-char (point-max))
X!   (insert "\nIn Calc 1.06, Emacs " (emacs-version) "\n\n")
X    (message (substitute-command-keys "Type \\[mail-send] to send bug report."))
X  )
X  
X--- 4495,4501 ----
X    (interactive "sBug Subject: ")
X    (mail nil calc-bug-address topic)
X    (goto-char (point-max))
X!   (insert "\nIn Calc 1.07, Emacs " (emacs-version) "\n\n")
X    (message (substitute-command-keys "Type \\[mail-send] to send bug report."))
X  )
X  
X***************
X*** 4487,4492 ****
X--- 4527,4533 ----
X         cd <Calc home directory>
X         emacs -batch -l calc -f calc-install"
X    (interactive)
X+   (setq max-lisp-eval-depth (max 400 max-lisp-eval-depth))
X    (find-file "calc-ext.el")
X    (end-of-buffer)
X    (backward-paragraph 2)
X***************
X*** 4494,4499 ****
X--- 4535,4543 ----
X    (find-file "calc.el")
X    (search-forward "calc-info-filename \"")
X    (insert (file-name-directory buffer-file-name))
X+   (search-forward "calc-autoload-directory nil")
X+   (delete-backward-char 3)
X+   (insert "\"" default-directory "\"")
X    (calc-split (file-name-directory (buffer-file-name)) nil t)
X    (find-file "calc-ext.el")
X    (calc-split (file-name-directory (buffer-file-name)) nil t)
X*** calc-ext.el	Wed Oct 24 02:19:47 1990
X--- ../dist/calc-ext.el	Tue Oct 30 08:33:55 1990
X***************
X*** 1,4 ****
X! ;; Calculator for GNU Emacs version 1.06, part II
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.07, part II
X  ;; Copyright (C) 1990 Dave Gillespie
X  
X  ;; This file is part of GNU Emacs.
X***************
X*** 339,344 ****
X--- 339,345 ----
X    (define-key calc-mode-map "mB" 'calc-bin-simplify-mode)
X    (define-key calc-mode-map "mD" 'calc-default-simplify-mode)
X    (define-key calc-mode-map "mE" 'calc-ext-simplify-mode)
X+   (define-key calc-mode-map "mF" 'calc-settings-file-name)
X    (define-key calc-mode-map "mM" 'calc-more-recursion-depth)
X    (define-key calc-mode-map "mN" 'calc-num-simplify-mode)
X    (define-key calc-mode-map "mO" 'calc-no-simplify-mode)
X***************
X*** 390,396 ****
X--- 391,399 ----
X    (define-key calc-mode-map "vd" 'calc-diag)
X    (define-key calc-mode-map "ve" 'calc-expand-vector)
X    (define-key calc-mode-map "vf" 'calc-vector-find)
X+   (define-key calc-mode-map "vh" 'calc-head)
X    (define-key calc-mode-map "vi" 'calc-ident)
X+   (define-key calc-mode-map "vk" 'calc-cons)
X    (define-key calc-mode-map "vl" 'calc-vlength)
X    (define-key calc-mode-map "vm" 'calc-mask-vector)
X    (define-key calc-mode-map "vn" 'calc-rnorm)
X***************
X*** 631,637 ****
X       "I + a m (match-not); c h (from-hms); k n (prev prime)"
X       "I + f G (gamma-Q); f e (erfc); k B (etc., lower-tail dists)"
X       "I + V S (reverse sort); V G (reverse grade)"
X!      "I + v s (remove subvec)")
X     "inverse" nil)
X  )
X  
X--- 634,640 ----
X       "I + a m (match-not); c h (from-hms); k n (prev prime)"
X       "I + f G (gamma-Q); f e (erfc); k B (etc., lower-tail dists)"
X       "I + V S (reverse sort); V G (reverse grade)"
X!      "I + v s (remove subvec); v h (tail)")
X     "inverse" nil)
X  )
X  
X***************
X*** 642,648 ****
X       "H + F (float floor), R (float round); P (constant \"e\")"
X       "H + a d (total derivative); k c (permutations)"
X       "H + k b (bern-poly), k e (euler-poly); k s (stirling-2)"
X!      "H + f G (gamma-g), f B (beta-B)"
X       "H + v e (expand w/filler); V H (weighted histogram)"
X       "H + a S (general solve eqn), j I (general isolate)"
X       "H + a R (widen/root), a N (widen/min), a X (widen/max)")
X--- 645,651 ----
X       "H + F (float floor), R (float round); P (constant \"e\")"
X       "H + a d (total derivative); k c (permutations)"
X       "H + k b (bern-poly), k e (euler-poly); k s (stirling-2)"
X!      "H + f G (gamma-g), f B (beta-B); v h (rhead), v k (rcons)"
X       "H + v e (expand w/filler); V H (weighted histogram)"
X       "H + a S (general solve eqn), j I (general isolate)"
X       "H + a R (widen/root), a N (widen/min), a X (widen/max)")
X***************
X*** 655,661 ****
X     '("I H + S (arcsinh), C (arccosh), T (arctanh)"
X       "I H + E (log10), L (exp10); f G (gamma-G)"
X       "I H + F (float ceiling), R (float truncate)"
X!      "I H + a S (general invert func)")
X     "inverse-hyperbolic" nil)
X  )
X  
X--- 658,664 ----
X     '("I H + S (arcsinh), C (arccosh), T (arctanh)"
X       "I H + E (log10), L (exp10); f G (gamma-G)"
X       "I H + F (float ceiling), R (float truncate)"
X!      "I H + a S (general invert func); v h (rtail)")
X     "inverse-hyperbolic" nil)
X  )
X  
X***************
X*** 922,927 ****
X--- 925,931 ----
X    (calc-wrapper
X     (setq math-lud-cache nil
X  	 math-log2-cache nil
X+ 	 math-random-cache nil
X  	 math-max-digits-cache nil
X  	 math-checked-rewrites nil
X  	 math-integral-cache nil
X***************
X*** 2101,2127 ****
X    "Kill the Calculator stack element containing the cursor.
X  With numeric prefix argument N, kill the N stack elements at+below cursor."
X    (interactive "P")
X!   (calc-wrapper
X!    (calc-force-refresh)
X!    (calc-set-command-flag 'no-align)
X!    (let ((num (max (calc-locate-cursor-element (point)) 1))
X! 	 (n (prefix-numeric-value nn)))
X!      (if (< n 0)
X! 	 (progn
X! 	   (if (eobp)
X! 	       (setq num (1- num)))
X! 	   (setq num (- num n)
X! 		 n (- n))))
X!      (let ((stuff (calc-top-list n (- num n -1))))
X!        (calc-cursor-stack-index num)
X!        (let ((first (point)))
X! 	 (calc-cursor-stack-index (- num n))
X! 	 (if (null nn)
X! 	     (backward-char 1))   ; don't include newline for raw C-k
X! 	 (copy-region-as-kill first (point))
X! 	 (if (not no-delete)
X! 	     (calc-pop-stack n (- num n -1))))
X!        (setq calc-last-kill (cons (car kill-ring) stuff)))))
X  )
X  
X  (defun calc-force-refresh ()
X--- 2105,2133 ----
X    "Kill the Calculator stack element containing the cursor.
X  With numeric prefix argument N, kill the N stack elements at+below cursor."
X    (interactive "P")
X!   (if (eq major-mode 'calc-mode)
X!       (calc-wrapper
X!        (calc-force-refresh)
X!        (calc-set-command-flag 'no-align)
X!        (let ((num (max (calc-locate-cursor-element (point)) 1))
X! 	     (n (prefix-numeric-value nn)))
X! 	 (if (< n 0)
X! 	     (progn
X! 	       (if (eobp)
X! 		   (setq num (1- num)))
X! 	       (setq num (- num n)
X! 		     n (- n))))
X! 	 (let ((stuff (calc-top-list n (- num n -1))))
X! 	   (calc-cursor-stack-index num)
X! 	   (let ((first (point)))
X! 	     (calc-cursor-stack-index (- num n))
X! 	     (if (null nn)
X! 		 (backward-char 1))   ; don't include newline for raw C-k
X! 	     (copy-region-as-kill first (point))
X! 	     (if (not no-delete)
X! 		 (calc-pop-stack n (- num n -1))))
X! 	   (setq calc-last-kill (cons (car kill-ring) stuff)))))
X!     (kill-line nn))
X  )
X  
X  (defun calc-force-refresh ()
X***************
X*** 2147,2162 ****
X  (defun calc-kill-region (top bot &optional no-delete)
X    "Kill the Calculator stack elements between Point and Mark."
X    (interactive "r")
X!   (calc-wrapper
X!    (calc-force-refresh)
X!    (calc-set-command-flag 'no-align)
X!    (let* ((top-num (calc-locate-cursor-element top))
X! 	  (bot-num (calc-locate-cursor-element (1- bot)))
X! 	  (num (- top-num bot-num -1)))
X!      (copy-region-as-kill top bot)
X!      (setq calc-last-kill (cons (car kill-ring) (calc-top-list num bot-num)))
X!      (if (not no-delete)
X! 	 (calc-pop-stack num bot-num))))
X  )
X  
X  (defun calc-copy-as-kill (n)
X--- 2153,2173 ----
X  (defun calc-kill-region (top bot &optional no-delete)
X    "Kill the Calculator stack elements between Point and Mark."
X    (interactive "r")
X!   (if (eq major-mode 'calc-mode)
X!       (calc-wrapper
X!        (calc-force-refresh)
X!        (calc-set-command-flag 'no-align)
X!        (let* ((top-num (calc-locate-cursor-element top))
X! 	      (bot-num (calc-locate-cursor-element (1- bot)))
X! 	      (num (- top-num bot-num -1)))
X! 	 (copy-region-as-kill top bot)
X! 	 (setq calc-last-kill (cons (car kill-ring)
X! 				    (calc-top-list num bot-num)))
X! 	 (if (not no-delete)
X! 	     (calc-pop-stack num bot-num))))
X!     (if no-delete
X! 	(copy-region-as-kill top bot)
X!       (kill-region top bot)))
X  )
X  
X  (defun calc-copy-as-kill (n)
X***************
X*** 4224,4230 ****
X       (and (eq many 0) (setq many 25))
X       (setq expr (calc-normalize (math-rewrite expr rules many)))
X       (let (sel)
X!        (setq expr (calc-locate-select-marker sel)))
X       (calc-pop-push-record-list n "rwrt" (list expr)))
X     (calc-handle-whys))
X  )
X--- 4235,4241 ----
X       (and (eq many 0) (setq many 25))
X       (setq expr (calc-normalize (math-rewrite expr rules many)))
X       (let (sel)
X!        (setq expr (calc-locate-select-marker expr)))
X       (calc-pop-push-record-list n "rwrt" (list expr)))
X     (calc-handle-whys))
X  )
X***************
X*** 6904,6910 ****
X    (calc-do-prefix-help
X     '("Deg, Rad, HMS; Frac; Polar; Algebraic; Symbolic"
X       "Working; Xtensions; Mode-save"
X!      "SHIFT + Shifted-prefixes"
X       "SHIFT + simplify: Off, Num, Default, Bin-clip, Alg, Units")
X     "mode" ?m)
X  )
X--- 6915,6921 ----
X    (calc-do-prefix-help
X     '("Deg, Rad, HMS; Frac; Polar; Algebraic; Symbolic"
X       "Working; Xtensions; Mode-save"
X!      "SHIFT + Shifted-prefixes, mode-Filename"
X       "SHIFT + simplify: Off, Num, Default, Bin-clip, Alg, Units")
X     "mode" ?m)
X  )
X***************
X*** 6954,6959 ****
X--- 6965,6997 ----
X       (save-buffer)))
X  )
X  
X+ (defun calc-settings-file-name (name &optional arg)
X+   "Set the file name for Calc mode settings and permanent definitions.
X+ This is normally ~/.emacs.  This command resets all mode settings to
X+ the defaults and then, if the file name does not contain \".emacs\" and
X+ a file by that name already exists, loads the settings from the file.
X+ With a positive prefix argument, loads even if file contains \".emacs\".
X+ With a negative prefix argument, never loads the new settings file.
X+ If argument is 2 or greater in absolute value, previous mode settings
X+ are not cleared first.
X+ If you give a blank file name, the current settings file name is shown."
X+   (interactive "sSettings file name (normally ~/.emacs): \nP")
X+   (calc-wrapper
X+    (setq arg (if arg (prefix-numeric-value arg) 0))
X+    (if (equal name "")
X+        (message "Calc settings file is \"%s\"" calc-settings-file)
X+      (if (< (math-abs arg) 2)
X+ 	 (let ((list calc-mode-var-list))
X+ 	   (while list
X+ 	     (set (car (car list)) (nth 1 (car list))))))
X+      (setq calc-settings-file name)
X+      (or (and (string-match "\\.emacs" calc-settings-file)
X+ 	      (> arg 0))
X+ 	 (< arg 0)
X+ 	 (load name t)
X+ 	 (message "New file"))))
X+ )
X+ 
X  (defun calc-shift-prefix ()
X    "Turn shifted prefixes mode on or off.
X  In this mode, the prefix keys A, B, D, F, G, J, K, and M can be used shifted
X***************
X*** 7285,7297 ****
X     (calc-trail-here))
X  )
X  
X! (defun calc-trail-yank ()
X!   "Yank the value indicated by the trail pointer onto the Calculator stack."
X!   (interactive)
X    (calc-wrapper
X!    (calc-set-command-flag 'hold-trail)
X     (calc-enter-result 0 "yank"
X  		      (calc-with-trail-buffer
X  		       (if (or (looking-at "Emacs Calc")
X  			       (looking-at "----")
X  			       (looking-at " ? ? ?[^ \n]* *$")
X--- 7323,7338 ----
X     (calc-trail-here))
X  )
X  
X! (defun calc-trail-yank (arg)
X!   "Yank the value indicated by the trail pointer onto the Calculator stack.
X! With a numeric argument, yank the Nth entry above the trail pointer."
X!   (interactive "P")
X    (calc-wrapper
X!    (or arg (calc-set-command-flag 'hold-trail))
X     (calc-enter-result 0 "yank"
X  		      (calc-with-trail-buffer
X+ 		       (if arg
X+ 			   (forward-line (- (prefix-numeric-value arg))))
X  		       (if (or (looking-at "Emacs Calc")
X  			       (looking-at "----")
X  			       (looking-at " ? ? ?[^ \n]* *$")
X***************
X*** 7305,7311 ****
X  			      (str (buffer-substring (point) (1- next)))
X  			      (val (math-read-plain-expr str)))
X  			 (if (eq (car-safe val) 'error)
X! 			     (error "Can't yank that line: " (nth 2 val))
X  			   val)))))
X  )
X  
X--- 7346,7352 ----
X  			      (str (buffer-substring (point) (1- next)))
X  			      (val (math-read-plain-expr str)))
X  			 (if (eq (car-safe val) 'error)
X! 			     (error "Can't yank that line: %s" (nth 2 val))
X  			   val)))))
X  )
X  
X***************
X*** 7695,7701 ****
X    (calc-do-prefix-help
X     '("Pack, Unpack, Identity, Diagonal, indeX, Build"
X       "Row, Column, Subvector; Length; Find; Mask, Expand"
X!      "Tranpose, Arrange, reVerse; rNorm"
X       "SHIFT + Det, & (inverse), LUD, Trace, conJtrn, Cross"
X       "SHIFT + Sort, Grade, Histogram; cNorm"
X       "SHIFT + Apply, Map, Reduce, accUm, Inner-, Outer-prod"
X--- 7736,7742 ----
X    (calc-do-prefix-help
X     '("Pack, Unpack, Identity, Diagonal, indeX, Build"
X       "Row, Column, Subvector; Length; Find; Mask, Expand"
X!      "Tranpose, Arrange, reVerse; Head, Kons; rNorm"
X       "SHIFT + Det, & (inverse), LUD, Trace, conJtrn, Cross"
X       "SHIFT + Sort, Grade, Histogram; cNorm"
X       "SHIFT + Apply, Map, Reduce, accUm, Inner-, Outer-prod"
X***************
X*** 7934,7944 ****
X  
X  (defun calc-cons (arg)
X    "Insert the object in stack level 2 at front of vector at top of stack.
X! With Inverse flag, insert object at top of stack at end of vector at
X  stack level 2."
X    (interactive "P")
X    (calc-wrapper
X!    (if (calc-is-inverse)
X         (calc-binary-op "rcns" 'calcFunc-rcons arg)
X       (calc-binary-op "cons" 'calcFunc-cons arg)))
X  )
X--- 7975,7985 ----
X  
X  (defun calc-cons (arg)
X    "Insert the object in stack level 2 at front of vector at top of stack.
X! With Hyperbolic flag, insert object at top of stack at end of vector at
X  stack level 2."
X    (interactive "P")
X    (calc-wrapper
X!    (if (calc-is-hyperbolic)
X         (calc-binary-op "rcns" 'calcFunc-rcons arg)
X       (calc-binary-op "cons" 'calcFunc-cons arg)))
X  )
X***************
X*** 7946,7968 ****
X  
X  (defun calc-head (arg)
X    "Extract the first element of the vector on the top of the stack.
X! With Inverse flag, extract all but the last element of the vector."
X    (interactive "P")
X    (calc-wrapper
X     (if (calc-is-inverse)
X!        (calc-unary-op "rhed" 'calcFunc-rhead arg)
X!      (calc-unary-op "head" 'calcFunc-head arg)))
X  )
X  
X- 
X  (defun calc-tail (arg)
X    "Extract all but the first element of the vector on the top of the stack.
X! With Inverse flag, extract the last element of the vector."
X    (interactive "P")
X!   (calc-wrapper
X!    (if (calc-is-inverse)
X!        (calc-unary-op "rtai" 'calcFunc-rtail arg)
X!      (calc-unary-op "tail" 'calcFunc-tail arg)))
X  )
X  
X  (defun calc-vlength (arg)
X--- 7987,8011 ----
X  
X  (defun calc-head (arg)
X    "Extract the first element of the vector on the top of the stack.
X! With Hyperbolic flag, extract all but the last element of the vector.
X! With Inverse flag, extract the tail of the vector."
X    (interactive "P")
X    (calc-wrapper
X     (if (calc-is-inverse)
X!        (if (calc-is-hyperbolic)
X! 	   (calc-unary-op "rtai" 'calcFunc-rtail arg)
X! 	 (calc-unary-op "tail" 'calcFunc-tail arg))
X!      (if (calc-is-hyperbolic)
X! 	 (calc-unary-op "rhed" 'calcFunc-rhead arg)
X!        (calc-unary-op "head" 'calcFunc-head arg))))
X  )
X  
X  (defun calc-tail (arg)
X    "Extract all but the first element of the vector on the top of the stack.
X! With Hyperbolic flag, extract the last element of the vector."
X    (interactive "P")
X!   (calc-inverse-func)
X!   (calc-head arg)
X  )
X  
X  (defun calc-vlength (arg)
X***************
X*** 8392,8401 ****
X  	     (setq hyp (not hyp)))
X  	    ((eq key prefix)
X  	     (setq prefix nil))
X! 	    ((and (memq key '(?a ?b ?c ?f ?k ?m ?v ?V)) (null prefix))
X  	     (setq prefix (downcase key)))
X  	    ((eq prefix ?m)
X! 	     (setq prefix nil)
X  	     (if (eq key ?e)
X  		 (setq calc-mapping-dir nil)
X  	       (if (memq key '(?r ?c ?a ?d))
X--- 8435,8445 ----
X  	     (setq hyp (not hyp)))
X  	    ((eq key prefix)
X  	     (setq prefix nil))
X! 	    ((and (memq key '(?a ?b ?c ?f ?k ?m ?M ?v ?V)) (null prefix))
X  	     (setq prefix (downcase key)))
X  	    ((eq prefix ?m)
X! 	     (setq prefix nil
X! 		   key (downcase key))
X  	     (if (eq key ?e)
X  		 (setq calc-mapping-dir nil)
X  	       (if (memq key '(?r ?c ?a ?d))
X***************
X*** 8402,8444 ****
X  		   (setq calc-mapping-dir (char-to-string key))
X  		 (beep))))
X  	    ((memq key '(?\$ ?\'))
X! 	     (let ((expr (if (eq key ?\$)
X! 			     (progn
X! 			       (setq calc-dollar-used 1)
X! 			       (if calc-dollar-values
X! 				   (list (car calc-dollar-values))
X! 				 (error "Stack underflow")))
X! 			   (calc-do-alg-entry "" "Function: ")))
X! 		   (arglist nil))
X  	       (if (/= (length expr) 1)
X  		   (error "Bad format"))
X  	       (if (eq (car-safe (car expr)) 'calcFunc-lambda)
X  		   (setq oper (list "$" (- (length (car expr)) 2) (car expr))
X  			 done t)
X! 		 (calc-default-formula-arglist (car expr))
X! 		 (setq arglist (sort arglist 'string-lessp)
X! 		       arglist (read-from-minibuffer
X! 				"Function argument list: "
X! 				(if arglist
X! 				    (prin1-to-string arglist)
X! 				  "()")
X! 				minibuffer-local-map
X! 				t))
X  		 (setq oper (list "$"
X  				  (length arglist)
X! 				  (append '(calcFunc-lambda)
X! 					  (mapcar
X! 					   (function
X! 					    (lambda (x)
X! 					      (list 'var
X! 						    x
X! 						    (intern
X! 						     (concat
X! 						      "var-"
X! 						      (symbol-name x))))))
X! 					   arglist)
X! 					  expr))
X! 		       done t))))
X  	    ((setq oper (assq key (nth (if inv (if hyp 3 1) (if hyp 2 0))
X  				       (cond ((eq prefix ?a) calc-a-oper-keys)
X  					     ((eq prefix ?b) calc-b-oper-keys)
X--- 8446,8503 ----
X  		   (setq calc-mapping-dir (char-to-string key))
X  		 (beep))))
X  	    ((memq key '(?\$ ?\'))
X! 	     (let* ((arglist nil)
X! 		    (has-args nil)
X! 		    (record-entry nil)
X! 		    (expr (if (eq key ?\$)
X! 			      (progn
X! 				(setq calc-dollar-used 1)
X! 				(if calc-dollar-values
X! 				    (list (car calc-dollar-values))
X! 				  (error "Stack underflow")))
X! 			    (let* ((calc-dollar-values calc-arg-values)
X! 				   (calc-dollar-used 0)
X! 				   (func (calc-do-alg-entry "" "Function: ")))
X! 			      (setq record-entry t)
X! 			      (if (> calc-dollar-used 0)
X! 				  (setq has-args calc-dollar-used
X! 					arglist (nthcdr
X! 						 (- (length calc-arg-values)
X! 						    calc-dollar-used)
X! 						 (reverse calc-arg-values))))
X! 			      func))))
X  	       (if (/= (length expr) 1)
X  		   (error "Bad format"))
X  	       (if (eq (car-safe (car expr)) 'calcFunc-lambda)
X  		   (setq oper (list "$" (- (length (car expr)) 2) (car expr))
X  			 done t)
X! 		 (or has-args
X! 		     (progn
X! 		       (calc-default-formula-arglist (car expr))
X! 		       (setq record-entry t
X! 			     arglist (sort arglist 'string-lessp)
X! 			     arglist (read-from-minibuffer
X! 				      "Function argument list: "
X! 				      (if arglist
X! 					  (prin1-to-string arglist)
X! 					"()")
X! 				      minibuffer-local-map
X! 				      t)
X! 			     arglist (mapcar (function
X! 					      (lambda (x)
X! 						(list 'var
X! 						      x
X! 						      (intern
X! 						       (concat
X! 							"var-"
X! 							(symbol-name x))))))
X! 					     arglist))))
X  		 (setq oper (list "$"
X  				  (length arglist)
X! 				  (append '(calcFunc-lambda) arglist expr))
X! 		       done t))
X! 	       (if record-entry
X! 		   (calc-record (nth 2 oper) "oper"))))
X  	    ((setq oper (assq key (nth (if inv (if hyp 3 1) (if hyp 2 0))
X  				       (cond ((eq prefix ?a) calc-a-oper-keys)
X  					     ((eq prefix ?b) calc-b-oper-keys)
X***************
X*** 8496,8501 ****
X--- 8555,8567 ----
X  		 name)))))
X  )
X  
X+ (defconst calc-arg-values '( ( var ArgA var-ArgA ) ( var ArgB var-ArgB )
X+ 			     ( var ArgC var-ArgC ) ( var ArgD var-ArgD )
X+ 			     ( var ArgE var-ArgE ) ( var ArgF var-ArgF )
X+ 			     ( var ArgG var-ArgG ) ( var ArgH var-ArgH )
X+ 			     ( var ArgI var-ArgI ) ( var ArgJ var-ArgJ )
X+ ))
X+ 
X  (defconst calc-oper-keys '( ( ( ?+ 2 calcFunc-add )
X  			      ( ?- 2 calcFunc-sub )
X  			      ( ?* 2 calcFunc-mul )
X***************
X*** 8657,8662 ****
X--- 8723,8730 ----
X  				( ?d 2 calcFunc-diag )
X  				( ?e 2 calcFunc-vexp )
X  				( ?f 2 calcFunc-find )
X+ 				( ?h 1 calcFunc-head )
X+ 				( ?k 2 calcFunc-cons )
X  				( ?l 1 calcFunc-vlen )
X  				( ?m 2 calcFunc-vmask )
X  				( ?n 1 calcFunc-rnorm )
X***************
X*** 8675,8685 ****
X  				( ?X 1 calcFunc-vxor )
X  				( ?- 1 calcFunc-vdiff )
X  				( ?^ 1 calcFunc-vint ) )
X! 			      ( ( ?s 3 calcFunc-rsubvec )
X  				( ?G 1 calcFunc-rgrade )
X  				( ?S 1 calcFunc-rsort ) )
X  			      ( ( ?e 3 calcFunc-vexp )
X  				( ?H 3 calcFunc-histogram ) )
X  ))
X  
X  
X--- 8743,8757 ----
X  				( ?X 1 calcFunc-vxor )
X  				( ?- 1 calcFunc-vdiff )
X  				( ?^ 1 calcFunc-vint ) )
X! 			      ( ( ?h 1 calcFunc-tail )
X! 				( ?s 3 calcFunc-rsubvec )
X  				( ?G 1 calcFunc-rgrade )
X  				( ?S 1 calcFunc-rsort ) )
X  			      ( ( ?e 3 calcFunc-vexp )
X+ 				( ?h 1 calcFunc-rhead )
X+ 				( ?k 2 calcFunc-rcons )
X  				( ?H 3 calcFunc-histogram ) )
X+ 			      ( ( ?h 1 calcFunc-rtail ) )
X  ))
X  
X  
X***************
X*** 9337,9342 ****
X--- 9409,9418 ----
X  		 (fill-region pt (point)))
X  	     (indent-rigidly pt (point) 3)
X  	     (delete-region pt (1+ pt))
X+ 	     (insert "  (put '" (symbol-name cmd)
X+ 		     " 'calc-user-defn '"
X+ 		     (prin1-to-string (get cmd 'calc-user-defn))
X+ 		     ")\n")
X  	     (let* ((func (calc-stack-command-p cmd))
X  		    (ffunc (and func (symbolp func) (symbol-function func)))
X  		    (pt (point)))
X***************
X*** 9351,9356 ****
X--- 9427,9440 ----
X  		      (or (and (string-match "\"" str) (not q-ok))
X  			  (fill-region pt (point)))
X  		      (indent-rigidly pt (point) 3)
X+ 		      (delete-region pt (1+ pt))
X+ 		      (setq pt (point))
X+ 		      (insert "(put '" (symbol-name func)
X+ 			      " 'calc-user-defn '"
X+ 			      (prin1-to-string (get func 'calc-user-defn))
X+ 			      ")\n")
X+ 		      (fill-region pt (point))
X+ 		      (indent-rigidly pt (point) 3)
X  		      (delete-region pt (1+ pt))))))
X  	 (and (stringp fcmd)
X  	      (insert "  (fset '" (prin1-to-string cmd)
X***************
X*** 9752,9758 ****
X  )
X  
X  
X! (defun calc-kbd-push ()
X    "Save modes and quick variables around a section of a keyboard macro.
X  
X  Saved:  var-0 thru var-9, precision, word size, angular mode,
X--- 9836,9842 ----
X  )
X  
X  
X! (defun calc-kbd-push (arg)
X    "Save modes and quick variables around a section of a keyboard macro.
X  
X  Saved:  var-0 thru var-9, precision, word size, angular mode,
X***************
X*** 9759,9767 ****
X  simplification mode, vector mapping direction, Alg, Sym, Frac, Polar modes.
X  
X  Values are restored on exit, even if the macro halts with an error."
X!   (interactive)
X    (calc-wrapper
X!    (let* ((var-0 (and (boundp 'var-0) var-0))
X  	  (var-1 (and (boundp 'var-1) var-1))
X  	  (var-2 (and (boundp 'var-2) var-2))
X  	  (var-3 (and (boundp 'var-3) var-3))
X--- 9843,9852 ----
X  simplification mode, vector mapping direction, Alg, Sym, Frac, Polar modes.
X  
X  Values are restored on exit, even if the macro halts with an error."
X!   (interactive "P")
X    (calc-wrapper
X!    (let* ((defs (and arg (> (prefix-numeric-value arg) 0)))
X! 	  (var-0 (and (boundp 'var-0) var-0))
X  	  (var-1 (and (boundp 'var-1) var-1))
X  	  (var-2 (and (boundp 'var-2) var-2))
X  	  (var-3 (and (boundp 'var-3) var-3))
X***************
X*** 9771,9786 ****
X  	  (var-7 (and (boundp 'var-7) var-7))
X  	  (var-8 (and (boundp 'var-8) var-8))
X  	  (var-9 (and (boundp 'var-9) var-9))
X! 	  (calc-internal-prec calc-internal-prec)
X! 	  (calc-word-size calc-word-size)
X! 	  (calc-angle-mode calc-angle-mode)
X! 	  (calc-simplify-mode calc-simplify-mode)
X! 	  (calc-mapping-dir calc-mapping-dir)
X! 	  (calc-algebraic-mode calc-algebraic-mode)
X! 	  (calc-incomplete-algebraic-mode calc-incomplete-algebraic-mode)
X! 	  (calc-symbolic-mode calc-symbolic-mode)
X! 	  (calc-prefer-frac calc-prefer-frac)
X! 	  (calc-complex-mode calc-complex-mode)
X  	  (count 0)
X  	  (body "")
X  	  ch)
X--- 9856,9872 ----
X  	  (var-7 (and (boundp 'var-7) var-7))
X  	  (var-8 (and (boundp 'var-8) var-8))
X  	  (var-9 (and (boundp 'var-9) var-9))
X! 	  (calc-internal-prec (if defs 12 calc-internal-prec))
X! 	  (calc-word-size (if defs 32 calc-word-size))
X! 	  (calc-angle-mode (if defs 'deg calc-angle-mode))
X! 	  (calc-simplify-mode (if defs nil calc-simplify-mode))
X! 	  (calc-mapping-dir (if arg nil calc-mapping-dir))
X! 	  (calc-algebraic-mode (if arg nil calc-algebraic-mode))
X! 	  (calc-incomplete-algebraic-mode (if arg nil
X! 					    calc-incomplete-algebraic-mode))
X! 	  (calc-symbolic-mode (if defs nil calc-symbolic-mode))
X! 	  (calc-prefer-frac (if defs nil calc-prefer-frac))
X! 	  (calc-complex-mode (if defs nil calc-complex-mode))
X  	  (count 0)
X  	  (body "")
X  	  ch)
X***************
X*** 10452,10465 ****
X  (defun math-build-call (f args)
X    (if (eq (car-safe f) 'calcFunc-lambda)
X        (if (= (length args) (- (length f) 2))
X! 	  (let ((argnames (cdr f))
X! 		(argvals args)
X! 		(res (nth (1- (length f)) f)))
X! 	    (while argvals 
X! 	      (setq res (math-expr-subst res (car argnames) (car argvals))
X! 		    argnames (cdr argnames)
X! 		    argvals (cdr argvals)))
X! 	    res)
X  	(cons 'calcFunc-call (cons (math-calcFunc-to-var f) args)))
X      (if (and (eq f 'calcFunc-neg)
X  	     (= (length args) 1))
X--- 10538,10545 ----
X  (defun math-build-call (f args)
X    (if (eq (car-safe f) 'calcFunc-lambda)
X        (if (= (length args) (- (length f) 2))
X! 	  (math-multi-subst (nth (1- (length f)) f) (cdr f) args)
X! 	(calc-record-why "Wrong number of arguments" f)
X  	(cons 'calcFunc-call (cons (math-calcFunc-to-var f) args)))
X      (if (and (eq f 'calcFunc-neg)
X  	     (= (length args) 1))
X***************
X*** 10476,10481 ****
X--- 10556,10580 ----
X  	  (cons f args)))))
X  )
X  
X+ ;;; Do substitutions in parallel to avoid crosstalk.
X+ (defun math-multi-subst (expr olds news)
X+   (let ((args nil)
X+ 	temp)
X+     (while (and olds news)
X+       (setq args (cons (cons (car olds) (car news)) args)
X+ 	    olds (cdr olds)
X+ 	    news (cdr news)))
X+     (math-multi-subst-rec expr))
X+ )
X+ 
X+ (defun math-multi-subst-rec (expr)
X+   (cond ((setq temp (assoc expr args)) (cdr temp))
X+ 	((Math-primp expr) expr)
X+ 	(t
X+ 	 (cons (car expr)
X+ 	       (mapcar 'math-multi-subst-rec (cdr expr)))))
X+ )
X+ 
X  (defun calcFunc-call (f &rest args)
X    (setq args (math-build-call (math-var-to-calcFunc f) args))
X    (if (eq (car-safe args) 'calcFunc-call)
X***************
X*** 11405,11417 ****
X    (or (math-vectorp mask) (math-reject-arg mask 'vectorp))
X    (or (math-constp mask) (math-reject-arg mask 'constp))
X    (or (math-vectorp vec) (math-reject-arg vec 'vectorp))
X!   (setq vec (cdr vec))
X!   (let ((new nil))
X      (while (setq mask (cdr mask))
X        (if (math-zerop (car mask))
X! 	  (setq new (cons (or filler (car mask)) new))
X! 	(setq new (cons (or (car vec) (car mask)) new)
X! 	      vec (cdr vec))))
X      (cons 'vec (nreverse new)))
X  )
X  (fset 'calcFunc-vexp (symbol-function 'math-vec-expand))
X--- 11504,11519 ----
X    (or (math-vectorp mask) (math-reject-arg mask 'vectorp))
X    (or (math-constp mask) (math-reject-arg mask 'constp))
X    (or (math-vectorp vec) (math-reject-arg vec 'vectorp))
X!   (let ((new nil)
X! 	(fvec (and filler (math-vectorp filler))))
X      (while (setq mask (cdr mask))
X        (if (math-zerop (car mask))
X! 	  (setq new (cons (or (if fvec
X! 				  (car (setq filler (cdr filler)))
X! 				filler)
X! 			      (car mask)) new))
X! 	(setq vec (cdr vec)
X! 	      new (cons (or (car vec) (car mask)) new))))
X      (cons 'vec (nreverse new)))
X  )
X  (fset 'calcFunc-vexp (symbol-function 'math-vec-expand))
X***************
X*** 16248,16259 ****
X  
X  ;;; Produce a random digit in the range 0..999.
X  ;;; Avoid various pitfalls that may lurk in the built-in (random) function!
X  (defun math-random-digit ()
X!   (prog1
X!       (% (lsh (random math-first-random-flag) -4) 1000)
X!     (setq math-first-random-flag nil))
X  )
X! (setq math-first-random-flag t)
X  
X  ;;; Produce an N-digit random integer.
X  (defun math-random-digits (n)
X--- 16350,16383 ----
X  
X  ;;; Produce a random digit in the range 0..999.
X  ;;; Avoid various pitfalls that may lurk in the built-in (random) function!
X+ ;;; Shuffling algorithm from Numerical Recipes, section 7.1.
X  (defun math-random-digit ()
X!   (let (i)
X!     (or math-random-cache
X! 	(progn
X! 	  (random t)
X! 	  (setq i 0
X! 		math-random-shift -4)  ; assume RAND_MAX >= 16383
X! 	  ;; This exercises the random number generator and also helps
X! 	  ;; deduce a better value for RAND_MAX.
X! 	  (while (< (setq i (1+ i)) 30)
X! 	    (if (> (lsh (random) math-random-shift) 4095)
X! 		(setq math-random-shift (1- math-random-shift))))
X! 	  (setq math-random-last (logand (lsh (random) math-random-shift) 1023)
X! 		math-random-cache (make-vector 13 nil)
X! 		i -1)
X! 	  (while (< (setq i (1+ i)) 13)
X! 	    (aset math-random-cache i (logand (lsh (random) math-random-shift)
X! 					      1023)))))
X!     (while (progn
X! 	     (setq i (/ math-random-last 79)   ; 0 <= i < 13
X! 		   math-random-last (aref math-random-cache i))
X! 	     (aset math-random-cache i (logand (lsh (random) math-random-shift)
X! 					       1023))
X! 	     (>= math-random-last 1000)))
X!     math-random-last)
X  )
X! (setq math-random-cache nil)
X  
X  ;;; Produce an N-digit random integer.
X  (defun math-random-digits (n)
X***************
X*** 16338,16344 ****
X  (fset 'calcFunc-random (symbol-function 'math-random))
X  
X  ;;; Choose N objects at random from the set MAX without duplicates.
X! (defun math-shuffle (n max)
X    (or (and (Math-num-integerp n)
X  	   (or (natnump (setq n (math-trunc n))) (eq n -1)))
X        (math-reject-arg n 'integerp))
X--- 16462,16469 ----
X  (fset 'calcFunc-random (symbol-function 'math-random))
X  
X  ;;; Choose N objects at random from the set MAX without duplicates.
X! (defun math-shuffle (n &optional max)
X!   (or max (setq max n n -1))
X    (or (and (Math-num-integerp n)
X  	   (or (natnump (setq n (math-trunc n))) (eq n -1)))
X        (math-reject-arg n 'integerp))
X***************
X*** 17132,17138 ****
X  	(and invb (Math-zerop b)))
X      nil)
X     ((and scalar-okay (Math-objvecp a) (Math-objvecp b))
X!     (math-mul-or-div a b inva invb))
X     ((and (eq (car-safe a) '^)
X  	 inva
X  	 (math-looks-negp (nth 2 a)))
X--- 17257,17265 ----
X  	(and invb (Math-zerop b)))
X      nil)
X     ((and scalar-okay (Math-objvecp a) (Math-objvecp b))
X!     (setq a (math-mul-or-div a b inva invb))
X!     (and (Math-objvecp a)
X! 	 a))
X     ((and (eq (car-safe a) '^)
X  	 inva
X  	 (math-looks-negp (nth 2 a)))
X***************
X*** 17271,17277 ****
X  in the order they were encountered; the first non-NIL value which is different
X  from the original expression returned is used.  The argument EXPR may be
X  destructively modified."
X!   (append '(progn)
X  	  (mapcar (function
X  		   (lambda (func)
X  		     (list 'put (list 'quote func) ''math-simplify
X--- 17398,17404 ----
X  in the order they were encountered; the first non-NIL value which is different
X  from the original expression returned is used.  The argument EXPR may be
X  destructively modified."
X!   (append '(progn (math-need-std-simps))
X  	  (mapcar (function
X  		   (lambda (func)
X  		     (list 'put (list 'quote func) ''math-simplify
X***************
X*** 17287,17292 ****
X--- 17414,17423 ----
X  
X  ;;;; [calc-alg.el]
X  
X+ (defun math-need-std-simps ()
X+   ;; Placeholder, to synchronize autoloading.
X+ )
X+ 
X  (math-defsimplify (+ -)
X    (math-simplify-plus))
X  
X***************
X*** 18156,18163 ****
X      (if (and (eq (car expr) 'calcFunc-quote)
X  	     (= (length expr) 2))
X  	(math-rwcomp-match-vars (nth 1 expr))
X!       (cons (car expr)
X! 	    (mapcar 'math-rwcomp-match-vars (cdr expr)))))
X  )
X  
X  (defun math-rwcomp-register-expr (num)
X--- 18287,18300 ----
X      (if (and (eq (car expr) 'calcFunc-quote)
X  	     (= (length expr) 2))
X  	(math-rwcomp-match-vars (nth 1 expr))
X!       (if (and (eq (car expr) 'calcFunc-plain)
X! 	       (= (length expr) 2)
X! 	       (not (Math-primp (nth 1 expr))))
X! 	  (list (car expr)
X! 		(cons (car (nth 1 expr))
X! 		      (mapcar 'math-rwcomp-match-vars (cdr (nth 1 expr)))))
X! 	(cons (car expr)
X! 	      (mapcar 'math-rwcomp-match-vars (cdr expr))))))
X  )
X  
X  (defun math-rwcomp-register-expr (num)
X***************
X*** 20841,20862 ****
X  		     next (math-sub-float guess step))
X  	       (not (math-lessp-float high next))
X  	       (not (math-lessp-float next low)))
X! 	  (if (or (Math-zerop vnext)
X! 		  (math-nearly-equal next guess))
X! 	      (list 'vec next vnext)
X  	    (setq var-DUMMY next
X  		  vnext (math-evaluate-expr expr))
X! 	    (if (and better
X! 		     (math-lessp-float (math-abs (or oostep
X! 						     (math-sub-float
X! 						      high low)))
X! 				       (math-abs
X! 					(math-mul-float '(float 2 0)
X! 							step))))
X! 		(math-newton-search-root expr deriv nil nil nil ostep
X! 					 low vlow high vhigh)
X! 	      (math-newton-search-root expr deriv next vnext step ostep
X! 				       low vlow high vhigh)))
X  	(if (or (and (Math-posp vlow) (Math-posp vhigh))
X  		(and (Math-negp vlow) (Math-negp vhigh)))
X  	    (math-search-root expr deriv low vlow high vhigh)
X--- 20978,21000 ----
X  		     next (math-sub-float guess step))
X  	       (not (math-lessp-float high next))
X  	       (not (math-lessp-float next low)))
X! 	  (progn
X  	    (setq var-DUMMY next
X  		  vnext (math-evaluate-expr expr))
X! 	    (if (or (Math-zerop vnext)
X! 		    (math-nearly-equal next guess))
X! 		(list 'vec next vnext)
X! 	      (if (and better
X! 		       (math-lessp-float (math-abs (or oostep
X! 						       (math-sub-float
X! 							high low)))
X! 					 (math-abs
X! 					  (math-mul-float '(float 2 0)
X! 							  step))))
X! 		  (math-newton-search-root expr deriv nil nil nil ostep
X! 					   low vlow high vhigh)
X! 		(math-newton-search-root expr deriv next vnext step ostep
X! 					 low vlow high vhigh))))
X  	(if (or (and (Math-posp vlow) (Math-posp vhigh))
X  		(and (Math-negp vlow) (Math-negp vhigh)))
X  	    (math-search-root expr deriv low vlow high vhigh)
X***************
X*** 22254,22260 ****
X  	     (progn
X  	       (calc-record-why "Inconsistent units" expr)
X  	       expr)
X! 	   (list '* (math-add (math-remove-units (nth 1 expr)) ratio)
X  		 units))))
X  )
X  
X--- 22392,22399 ----
X  	     (progn
X  	       (calc-record-why "Inconsistent units" expr)
X  	       expr)
X! 	   (list '* (math-add (math-remove-units (nth 1 expr))
X! 			      (if (eq (car expr) '-) (math-neg ratio) ratio))
X  		 units))))
X  )
X  
X***************
X*** 23734,23740 ****
X  (defun math-compose-expr (a prec)
X    (let ((math-compose-level (1+ math-compose-level)))
X      (cond
X!      ((or (eq a math-comp-selected)
X  	  (and math-comp-tagged
X  	       (not (eq math-comp-tagged a))))
X        (let ((math-comp-selected nil))
X--- 23873,23879 ----
X  (defun math-compose-expr (a prec)
X    (let ((math-compose-level (1+ math-compose-level)))
X      (cond
X!      ((or (and (eq a math-comp-selected) a)
X  	  (and math-comp-tagged
X  	       (not (eq math-comp-tagged a))))
X        (let ((math-comp-selected nil))
X***************
X*** 24673,24679 ****
X  	  (delete-region (point-min) (point))
X  	  (if calc-keypad-input
X  	      (insert "Calc: " calc-keypad-input "\n")
X! 	    (insert "----+-----Calc 1.06-----+----"
X  		    (int-to-string (1+ calc-keypad-menu))
X  		    "\n")))))
X    (setq calc-keypad-prev-input calc-keypad-input)
X--- 24812,24818 ----
X  	  (delete-region (point-min) (point))
X  	  (if calc-keypad-input
X  	      (insert "Calc: " calc-keypad-input "\n")
X! 	    (insert "----+-----Calc 1.07-----+----"
X  		    (int-to-string (1+ calc-keypad-menu))
X  		    "\n")))))
X    (setq calc-keypad-prev-input calc-keypad-input)
X***************
X*** 25242,25248 ****
X  		   (setq file-list (cons (list filename) file-list)))
X  	       (setcdr found (cons (intern name) (cdr found)))))))
X      (goto-char autoload-point)
X!     (insert "  (let ((dir \"" directory "\"))\n"
X  	    "    (mapcar (function (lambda (x)\n"
X  	    "      (let ((file (concat dir (car x))))\n"
X  	    "        (mapcar (function (lambda (func)\n"
X--- 25381,25387 ----
X  		   (setq file-list (cons (list filename) file-list)))
X  	       (setcdr found (cons (intern name) (cdr found)))))))
X      (goto-char autoload-point)
X!     (insert "  (let ((dir (or calc-autoload-directory \"" directory "\")))\n"
X  	    "    (mapcar (function (lambda (x)\n"
X  	    "      (let ((file (concat dir (car x))))\n"
X  	    "        (mapcar (function (lambda (func)\n"
X*** calc-INSTALL	Wed Oct 24 02:19:53 1990
X--- ../dist/calc-INSTALL	Tue Oct 30 08:45:09 1990
X***************
X*** 2,8 ****
X  Installation
X  ************
X  
X! Calc 1.06 comes as a pair of Emacs Lisp files, generally called
X  `calc.el' and `calc-ext.el'.  The first contains the basic foundations
X  of the Calculator, and is as small as possible to promote quick loading.
X  The second contains all the more advanced commands and functions.  Calc
X--- 2,8 ----
X  Installation
X  ************
X  
X! Calc 1.07 comes as a pair of Emacs Lisp files, generally called
X  `calc.el' and `calc-ext.el'.  The first contains the basic foundations
X  of the Calculator, and is as small as possible to promote quick loading.
X  The second contains all the more advanced commands and functions.  Calc
X***************
X*** 35,41 ****
X  
X    6. Test your installation as described at the end of these instructions.
X  
X!   7. (Optional.)  To print a hardcopy of the Calc manual (about 300 pages),
X       move to the Calc home directory and type `tex calc.texinfo',
X       then `texindex calc.??', then `tex calc.texinfo' again.
X       Now print the resulting `calc.dvi' file using whatever command
X--- 35,41 ----
X  
X    6. Test your installation as described at the end of these instructions.
X  
X!   7. (Optional.)  To print a hardcopy of the Calc manual (about 350 pages),
X       move to the Calc home directory and type `tex calc.texinfo',
X       then `texindex calc.??', then `tex calc.texinfo' again.
X       Now print the resulting `calc.dvi' file using whatever command
X***************
X*** 87,98 ****
X       (autoload 'calc-grab-region ".../calc-ext.elc" nil t)
X       (autoload 'defmath          ".../calc-ext.elc" nil t t)
X  
X! where `.../calc.elc' represents the full path to the `calc.elc'
X! file, and similarly for `.../calc-ext.elc'.  If you have installed
X  these files in Emacs' main `lisp/' directory, you can just write
X! `"calc.elc"' and `"calc-ext.elc"'.  If you have used the
X! `calc-install' method and the home directory you chose is called,
X! say, `/usr/gnu/src/calc', then you would need to write
X  `"/usr/gnu/src/calc/calc.elc"' and similarly for `calc-ext.elc'.
X  
X  The `autoload' command for `calc' is what loads `calc.elc'
X--- 87,98 ----
X       (autoload 'calc-grab-region ".../calc-ext.elc" nil t)
X       (autoload 'defmath          ".../calc-ext.elc" nil t t)
X  
X! where `.../calc.elc' represents the full path to the `calc.elc' file,
X! and similarly for the file `.../calc-ext.elc'.  If you have installed
X  these files in Emacs' main `lisp/' directory, you can just write
X! `"calc.elc"' and `"calc-ext.elc"'.  If you have used the `calc-install'
X! method and the home directory you chose is called, say,
X! `/usr/gnu/src/calc', then you would need to write
X  `"/usr/gnu/src/calc/calc.elc"' and similarly for `calc-ext.elc'.
X  
X  The `autoload' command for `calc' is what loads `calc.elc'
X***************
X*** 130,142 ****
X  automatically inserts the necessary `autoload' commands into `calc.el'
X  and the `calc-ext.el' to refer to the parts of them that were moved to
X  other files.  These `autoload' commands point to the directory you did
X! your `calc-install' in, so if you move Calc to a new home you'll have to
X! do the `calc-install' over again there.  Note that you will still need
X! to install the `autoload' commands shown above so that Emacs can find
X! the two main Calc files.
X  
X  The `calc-install' command also formats the manual, assuming
X! you have placed `calc.texinfo' in the same directory.
X  
X  If you'd rather split and compile the Calculator from the Unix shell
X  or a Makefile, you can use the command
X--- 130,151 ----
X  automatically inserts the necessary `autoload' commands into `calc.el'
X  and the `calc-ext.el' to refer to the parts of them that were moved to
X  other files.  These `autoload' commands point to the directory you did
X! your `calc-install' in.  Note that you will still need to install the
X! `autoload' commands shown above so that Emacs can find the two main Calc
X! files.
X  
X+ The Lisp variable `calc-autoload-directory' can be set to a
X+ directory name, including the trailing `/', which the `autoload'
X+ commands should use instead of the original installation directory.
X+ Calc examines this variable when it is loaded, so you can set it in
X+ your `.emacs' or `default' file if you move Calc after
X+ you have done your `calc-install'.  Note that this applies
X+ only to the `autoload' commands created by the splitting
X+ procedure; you will have to change the ones you wrote yourself
X+ by hand.
X+ 
X  The `calc-install' command also formats the manual, assuming
X! you have placed the file `calc.texinfo' in the same directory.
X  
X  If you'd rather split and compile the Calculator from the Unix shell
X  or a Makefile, you can use the command
X***************
X*** 239,245 ****
X  to save.  The result will be a collection of files whose names begin
X  with `calc-info'.  The `calc-install' command does this for you.
X  You can also format this into a printable document using TeX,
X! but beware, the manual is almost 300 printed pages!
X  
X  There is a Lisp variable called `calc-info-filename' which holds
X  the name of the Info file containing Calc's on-line documentation.
X--- 248,254 ----
X  to save.  The result will be a collection of files whose names begin
X  with `calc-info'.  The `calc-install' command does this for you.
X  You can also format this into a printable document using TeX,
X! but beware, the manual is over 300 printed pages!
X  
X  There is a Lisp variable called `calc-info-filename' which holds
X  the name of the Info file containing Calc's on-line documentation.
X*** calc.texinfo	Wed Oct 24 02:19:52 1990
X--- ../dist/calc.texinfo	Tue Oct 30 08:34:03 1990
X***************
X*** 1,7 ****
X  \input texinfo                  @c -*-texinfo-*-
X  @comment %**start of header (This is for running Texinfo on a region.)
X  @setfilename calc-info
X! @settitle GNU Emacs Calc 1.06 Manual
X  @setchapternewpage odd
X  @comment %**end of header (This is for running Texinfo on a region.)
X  
X--- 1,7 ----
X  \input texinfo                  @c -*-texinfo-*-
X  @comment %**start of header (This is for running Texinfo on a region.)
X  @setfilename calc-info
X! @settitle GNU Emacs Calc 1.07 Manual
X  @setchapternewpage odd
X  @comment %**end of header (This is for running Texinfo on a region.)
X  
X***************
X*** 38,44 ****
X  @sp 6
X  @center @titlefont{Calc Manual}
X  @sp 4
X! @center GNU Emacs Calc Version 1.06
X  @sp 1
X  @center October 1990
X  @sp 5
X--- 38,44 ----
X  @sp 6
X  @center @titlefont{Calc Manual}
X  @sp 4
X! @center GNU Emacs Calc Version 1.07
X  @sp 1
X  @center October 1990
X  @sp 5
X***************
X*** 76,82 ****
X  @node Top, Quick Overview,, (dir)
X  @ichapter The GNU Emacs Calculator
X  
X! @dfn{Calc 1.06} is an advanced desk calculator and mathematical tool
X  that runs as part of the GNU Emacs environment.
X  
X  This manual is divided into two major parts, the Tutorial and the
X--- 76,82 ----
X  @node Top, Quick Overview,, (dir)
X  @ichapter The GNU Emacs Calculator
X  
X! @dfn{Calc 1.07} is an advanced desk calculator and mathematical tool
X  that runs as part of the GNU Emacs environment.
X  
X  This manual is divided into two major parts, the Tutorial and the
X***************
X*** 587,595 ****
X  complete the @samp{f} sequence; type @kbd{C-g} to cancel the prefix.)
X  
X  Press @kbd{d ?} for a list of commands for changing the display format.
X! Press @kbd{m ?} for a list of other mode-setting commands.  Press @kbd{m m}
X! to save all current mode settings in your @file{.emacs} file.
X! 
X  Other prefixes are @kbd{c} (numeric conversions), @kbd{b} (binary
X  arithmetic), @kbd{a} (algebra), @kbd{j} (selecting sub-formulas),
X  @kbd{v} (vectors and matrices), @kbd{k} (combinatorics, statistics,
X--- 587,593 ----
X  complete the @samp{f} sequence; type @kbd{C-g} to cancel the prefix.)
X  
X  Press @kbd{d ?} for a list of commands for changing the display format.
X! Press @kbd{m ?} for a list of other mode-setting commands.
X  Other prefixes are @kbd{c} (numeric conversions), @kbd{b} (binary
X  arithmetic), @kbd{a} (algebra), @kbd{j} (selecting sub-formulas),
X  @kbd{v} (vectors and matrices), @kbd{k} (combinatorics, statistics,
X***************
X*** 663,669 ****
X  keyboards this means holding down the @key{META} (or @key{ALT}) and
X  @key{SHIFT} keys while typing @kbd{3}.  If you don't have a @key{META}
X  key on your keyboard, you can type @key{ESC} first, then @kbd{#}, to
X! accomplish the same effect.  If you don't even have an @key{ESC} key,
X  you can hold down @key{CTRL} or @key{CONTROL} while typing a left square
X  bracket, denoted here by @kbd{C-[}.@refill
X  
X--- 661,667 ----
X  keyboards this means holding down the @key{META} (or @key{ALT}) and
X  @key{SHIFT} keys while typing @kbd{3}.  If you don't have a @key{META}
X  key on your keyboard, you can type @key{ESC} first, then @kbd{#}, to
X! accomplish the same thing.  If you don't even have an @key{ESC} key,
X  you can hold down @key{CTRL} or @key{CONTROL} while typing a left square
X  bracket, denoted here by @kbd{C-[}.@refill
X  
X***************
X*** 732,738 ****
X  and the @samp{+} is the @dfn{operator}.  In an RPN calculator you always
X  enter the operands first, then the operator.  Each time you type a
X  number, Calc adds or @dfn{pushes} it onto the top of the Stack.
X! When you press an operator key like @kbd{+}, Calc pops the appropriate
X  number of operands from the stack and pushes back the result.
X  
X  Thus we could add the numbers 2 and 3 in an RPN calculator by typing:
X--- 730,736 ----
X  and the @samp{+} is the @dfn{operator}.  In an RPN calculator you always
X  enter the operands first, then the operator.  Each time you type a
X  number, Calc adds or @dfn{pushes} it onto the top of the Stack.
X! When you press an operator key like @kbd{+}, Calc @dfn{pops} the appropriate
X  number of operands from the stack and pushes back the result.
X  
X  Thus we could add the numbers 2 and 3 in an RPN calculator by typing:
X***************
X*** 798,804 ****
X  @end group
X  
X  Here, after pressing @kbd{3} the stack would really show @samp{1:  2}
X! with @samp{Calc: 3} in the minibuffer.  In these situations, you can
X  press the optional @key{RET} to see the stack as the figure shows.
X  
X  (@bullet) @strong{Exercise 1.}  (This tutorial will include exercises
X--- 796,802 ----
X  @end group
X  
X  Here, after pressing @kbd{3} the stack would really show @samp{1:  2}
X! with @samp{Calc:@: 3} in the minibuffer.  In these situations, you can
X  press the optional @key{RET} to see the stack as the figure shows.
X  
X  (@bullet) @strong{Exercise 1.}  (This tutorial will include exercises
X***************
X*** 851,856 ****
X--- 849,855 ----
X  @end example
X  @end group
X  
X+ @noindent
X  (Of course, an easier way to do this would be @kbd{3 @key{RET} 4 ^},
X  to raise 3 to the fourth power.)
X  
X***************
X*** 926,932 ****
X  typing @kbd{q}.  Remember, plain unshifted @kbd{q} is the Quit command.)
X  
X  @cindex Pythagorean Theorem
X! Here we use the Pythagorean Theorem to determine the hypotenuse of a
X  right triangle.  Calc actually has a built-in command for that called
X  @kbd{f h}, but let's suppose we can't remember the necessary keystrokes.
X  We can still enter it by its full name using @kbd{M-x} notation:
X--- 925,931 ----
X  typing @kbd{q}.  Remember, plain unshifted @kbd{q} is the Quit command.)
X  
X  @cindex Pythagorean Theorem
X! Here we've used the Pythagorean Theorem to determine the hypotenuse of a
X  right triangle.  Calc actually has a built-in command for that called
X  @kbd{f h}, but let's suppose we can't remember the necessary keystrokes.
X  We can still enter it by its full name using @kbd{M-x} notation:
X***************
X*** 2139,2148 ****
X  @end example
X  @end group
X  
X! Here we verify the identity @samp{@var{n}! = gamma(@var{n}+1)}.
X  
X  The binomial coefficient @var{n}-choose-@var{m} can be defined as
X! @samp{@var{n}! / @var{m}! (@var{n}-@var{m})!} for all reals @var{n} and
X  @var{m}.  The intermediate results in this formula can become quite
X  large even if the final result is small; the @kbd{k c} command computes
X  a binomial coefficient in a way that avoids large intermediate
X--- 2138,2147 ----
X  @end example
SHAR_EOF
echo "End of part 1, continue with part 2"
echo "2" > s2_seq_.tmp
exit 0
--
Dave Gillespie
  256-80 Caltech Pasadena CA USA 91125
  daveg@csvax.cs.caltech.edu, ...!cit-vax!daveg