[comp.emacs] Correct patch for GNU Emacs Calc, 1.01 -> 1.02

daveg@cit-vax.Caltech.Edu (David Gillespie) (06/27/90)

(The original version of this patch corresponded to a slightly older
"version 1.01" than was actually posted in comp.sources.misc.  Sorry
about that...  Here is a corrected version of that patch.  -- Dave)


The following patches convert Calc version 1.01 into Calc
version 1.02.  To apply them automatically with Patch v2.0,
first cd into your Calc distribution directory, then execute
"patch -p0 <calc.patch", where "calc.patch" is the name of this file.
You will want to re-byte-compile both parts, and re-format the
manual, as explained in the INSTALL file.

These patches do not cover the README and INSTALL files.  The
INSTALL file is just a copy of the "Installation" chapter of
calc.texinfo, which is updated by this patch.  Note that some
patches will add to the list of "autoload" commands recommended
in that chapter.

Patches and complete tar files are also available from anonymous FTP
on csvax.caltech.edu, in the "pub" subdirectory.

Enjoy!
							-- Dave

Dave Gillespie
256-80 Caltech, Pasadena CA 91125
daveg@csvax.caltech.edu, ...!cit-vax!daveg



*** calc.el	Tue Jun 26 16:14:45 1990
--- ../dist/calc.el	Tue Jun 26 16:33:01 1990
***************
*** 1,4 ****
! ;; Calculator for GNU Emacs
  ;; Copyright (C) 1990 Dave Gillespie
  
  ;; This file is part of GNU Emacs.
--- 1,4 ----
! ;; Calculator for GNU Emacs version 1.02
  ;; Copyright (C) 1990 Dave Gillespie
  
  ;; This file is part of GNU Emacs.
***************
*** 60,66 ****
  
  (defmacro calc-record-compilation-date-macro ()
    (` (setq calc-version (concat "Emacs Calc Mode"
! 				" v1.01 by Dave Gillespie"
  				", installed "
  				(, (current-time-string))
  				" by "
--- 60,66 ----
  
  (defmacro calc-record-compilation-date-macro ()
    (` (setq calc-version (concat "Emacs Calc Mode"
! 				" v1.02 by Dave Gillespie"
  				", installed "
  				(, (current-time-string))
  				" by "
***************
*** 92,97 ****
--- 92,99 ----
  ;;;      Together, Apart, Cancel, Factor, GCD, quotient/remainder.
  ;;;   Automatically generate derivatives for functions defined with Z F.
  ;;;   Handle commutativity and associativity among +, -, *, / in rewrite rules.
+ ;;;   Allow more powerful patterns, e.g., generic function names.
+ ;;;   Have a command that distributes function calls over equations.
  ;;;
  ;;;   In no-simplify mode, have a key which executes the top-level call
  ;;;      once, but does not execute any of the arguments' calls.
***************
*** 682,687 ****
--- 684,690 ----
    (if (or (not (eq major-mode 'calc-mode))
  	  (and (boundp 'calc-defs) calc-defs))
        (calc-mode))
+   (setq max-lisp-eval-depth (max max-lisp-eval-depth 1000))
    (if calc-always-load-extensions
        (calc-extensions))
    (if calc-language
***************
*** 690,696 ****
  	(calc-set-language calc-language calc-language-option t)))
  )
  
! (defun calc (&optional arg no-display)
    "The Emacs Calculator.  Full documentation is listed under \"calc-mode\"."
    (interactive "P")
    (or (fboundp 'calc-extensions)
--- 693,699 ----
  	(calc-set-language calc-language calc-language-option t)))
  )
  
! (defun calc (&optional arg full-display)
    "The Emacs Calculator.  Full documentation is listed under \"calc-mode\"."
    (interactive "P")
    (or (fboundp 'calc-extensions)
***************
*** 705,726 ****
  	(calc-quit)
        (let ((oldbuf (current-buffer)))
  	(calc-create-buffer)
! 	(if (get-buffer-window (current-buffer))
! 	    (select-window (get-buffer-window (current-buffer)))
! 	  (if (and (boundp 'calc-window-hook) calc-window-hook)
! 	      (run-hooks 'calc-window-hook)
! 	    (let ((w (get-largest-window)))
! 	      (if (and pop-up-windows
! 		       (> (window-height w)
! 			  (+ window-min-height calc-window-height 2)))
! 		  (progn
! 		    (setq w (split-window w
! 					  (- (window-height w)
! 					     calc-window-height 2)
! 					  nil))
! 		    (set-window-buffer w (current-buffer))
! 		    (select-window w))
! 		(pop-to-buffer (current-buffer))))))
  	(save-excursion
  	  (let ((buf (current-buffer)))
  	    (set-buffer (get-buffer-create "*Calc Trail*"))
--- 708,731 ----
  	(calc-quit)
        (let ((oldbuf (current-buffer)))
  	(calc-create-buffer)
! 	(if full-display
! 	    (switch-to-buffer (current-buffer) t)
! 	  (if (get-buffer-window (current-buffer))
! 	      (select-window (get-buffer-window (current-buffer)))
! 	    (if (and (boundp 'calc-window-hook) calc-window-hook)
! 		(run-hooks 'calc-window-hook)
! 	      (let ((w (get-largest-window)))
! 		(if (and pop-up-windows
! 			 (> (window-height w)
! 			    (+ window-min-height calc-window-height 2)))
! 		    (progn
! 		      (setq w (split-window w
! 					    (- (window-height w)
! 					       calc-window-height 2)
! 					    nil))
! 		      (set-window-buffer w (current-buffer))
! 		      (select-window w))
! 		  (pop-to-buffer (current-buffer)))))))
  	(save-excursion
  	  (let ((buf (current-buffer)))
  	    (set-buffer (get-buffer-create "*Calc Trail*"))
***************
*** 728,735 ****
  	    (and calc-display-trail
  		 (= (window-width) (screen-width))
  		 (calc-trail-display 1 t))))
! 	(setq max-lisp-eval-depth (max max-lisp-eval-depth 1000))
! 	(calc-summary)
  	(and calc-said-hello
  	     (interactive-p)
  	     (progn
--- 733,739 ----
  	    (and calc-display-trail
  		 (= (window-width) (screen-width))
  		 (calc-trail-display 1 t))))
! 	(calc-summary full-display)
  	(and calc-said-hello
  	     (interactive-p)
  	     (progn
***************
*** 739,744 ****
--- 743,754 ----
  	(run-hooks 'calc-start-hook))))
  )
  
+ (defun full-calc ()
+   "Invoke the Calculator and give it a full-sized window."
+   (interactive)
+   (calc nil t)
+ )
+ 
  (defun another-calc ()
    "Create another, independent Calculator buffer."
    (interactive)
***************
*** 783,788 ****
--- 793,799 ----
  			      'flat calc-language))
  	   (calc-dollar-values calc-quick-prev-results)
  	   (calc-dollar-used 0)
+ 	   (enable-recursive-minibuffers t)
  	   (alg-exp (calc-do-alg-entry "" "Quick calc: ")))
        (let ((buf ""))
  	(setq calc-quick-prev-results alg-exp)
***************
*** 797,805 ****
  	(message buf))))
  )
  
! (defun calc-summary ()
    (interactive)
!   (message "Welcome to the GNU Emacs Calculator!  Press ? for help, q to quit.")
  )
  
  (defun calc-info ()
--- 808,818 ----
  	(message buf))))
  )
  
! (defun calc-summary (&optional full)
    (interactive)
!   (if full
!       (message "Welcome to GNU Emacs Calc!  Press `?' or `i' for help, `C-x C-c' to quit.")
!       (message "Welcome to the GNU Emacs Calculator!  Press `?' or `i' for help, `q' to quit."))
  )
  
  (defun calc-info ()
***************
*** 813,820 ****
  (defun calc-help ()
    (interactive)
    (let ((msgs
! 	 '("Letter keys: Help, Info, Why; Xtended cmd; Yank; Quit"
! 	   "Letter keys: Negate; Precision; Store, Recall, Let"
  	   "Letter keys: SHIFT + Undo, reDo, last-X; Inverse, Hyperbolic"
  	   "Letter keys: SHIFT + sQrt; Sin, Cos, Tan; Exp, Ln, logB"
  	   "Letter keys: SHIFT + Floor, Round; Abs, conJ, arG; Pi"
--- 826,833 ----
  (defun calc-help ()
    (interactive)
    (let ((msgs
! 	 '("Letter keys: Help, Info (manual), Why; Xtended cmd; Quit"
! 	   "Letter keys: Negate; Precision; Store, Recall, Let; Yank"
  	   "Letter keys: SHIFT + Undo, reDo, last-X; Inverse, Hyperbolic"
  	   "Letter keys: SHIFT + sQrt; Sin, Cos, Tan; Exp, Ln, logB"
  	   "Letter keys: SHIFT + Floor, Round; Abs, conJ, arG; Pi"
***************
*** 2515,2524 ****
  )
  
  (defun math-div2-bignum (a)   ; [l l]
!   (cond
!    ((null (cdr a)) (list (/ (car a) 2)))
!    (t (cons (+ (/ (car a) 2) (* (% (nth 1 a) 2) 500))
! 	    (math-div2-bignum (cdr a)))))
  )
  
  
--- 2528,2537 ----
  )
  
  (defun math-div2-bignum (a)   ; [l l]
!   (if (cdr a)
!       (cons (+ (/ (car a) 2) (* (% (nth 1 a) 2) 500))
! 	    (math-div2-bignum (cdr a)))
!     (list (/ (car a) 2)))
  )
  
  
***************
*** 2627,2636 ****
  )
  
  (defun math-div10-bignum (a)   ; [l l]
!   (cond
!    ((null (cdr a)) (list (/ (car a) 10)))
!    (t (cons (+ (/ (car a) 10) (* (% (nth 1 a) 10) 100))
! 	    (math-div10-bignum (cdr a)))))
  )
  
  ;;; Coerce A to be a float.  [F N; V V] [Public]
--- 2640,2649 ----
  )
  
  (defun math-div10-bignum (a)   ; [l l]
!   (if (cdr a)
!       (cons (+ (/ (car a) 10) (* (% (nth 1 a) 10) 100))
! 	    (math-div10-bignum (cdr a)))
!     (list (/ (car a) 10)))
  )
  
  ;;; Coerce A to be a float.  [F N; V V] [Public]
***************
*** 3054,3071 ****
  
  ;;; Multiply digit list A by digit D.  [L L D D; l l D D]
  (defun math-mul-bignum-digit (a d c)
!   (and a
!        (if (<= d 1)
! 	   (and (= d 1) a)
! 	 (let* ((a (copy-sequence a)) (aa a) prod)
! 	   (while (progn
! 		    (setcar aa (% (setq prod (+ (* (car aa) d) c)) 1000))
! 		    (cdr aa))
! 	     (setq aa (cdr aa)
! 		   c (/ prod 1000)))
! 	   (if (>= prod 1000)
! 	       (setcdr aa (list (/ prod 1000))))
! 	   a)))
  )
  
  
--- 3067,3086 ----
  
  ;;; Multiply digit list A by digit D.  [L L D D; l l D D]
  (defun math-mul-bignum-digit (a d c)
!   (if a
!       (if (<= d 1)
! 	  (and (= d 1) a)
! 	(let* ((a (copy-sequence a)) (aa a) prod)
! 	  (while (progn
! 		   (setcar aa (% (setq prod (+ (* (car aa) d) c)) 1000))
! 		   (cdr aa))
! 	    (setq aa (cdr aa)
! 		  c (/ prod 1000)))
! 	  (if (>= prod 1000)
! 	      (setcdr aa (list (/ prod 1000))))
! 	  a))
!     (and (> c 0)
! 	 (list c)))
  )
  
  
***************
*** 3132,3161 ****
  ;;; Divide a bignum digit list by another.  [l.l l L]
  ;;; The following division algorithm is borrowed from Knuth vol. II, sec. 4.3.1
  (defun math-div-bignum (a b)
!   (if (null (cdr b))
!       (let ((res (math-div-bignum-digit a (car b))))
! 	(cons (car res) (list (cdr res))))
!     (let* ((alen (length a))
! 	   (blen (length b))
! 	   (d (/ 1000 (1+ (nth (1- blen) b))))
! 	   (res (math-div-bignum-big (math-mul-bignum-digit a d 0)
! 				     (math-mul-bignum-digit b d 0)
! 				     alen blen)))
!       (if (= d 1)
! 	  res
! 	(cons (car res)
! 	      (car (math-div-bignum-digit (cdr res) d))))))
  )
  
  ;;; Divide a bignum digit list by a digit.  [l.D l D]
  (defun math-div-bignum-digit (a b)
!   (if (null a)
!       '(nil . 0)
!     (let* ((res (math-div-bignum-digit (cdr a) b))
! 	   (num (+ (* (cdr res) 1000) (car a))))
!       (cons
!        (cons (/ num b) (car res))
!        (% num b))))
  )
  
  (defun math-div-bignum-big (a b alen blen)   ; [l.l l L]
--- 3147,3176 ----
  ;;; Divide a bignum digit list by another.  [l.l l L]
  ;;; The following division algorithm is borrowed from Knuth vol. II, sec. 4.3.1
  (defun math-div-bignum (a b)
!   (if (cdr b)
!       (let* ((alen (length a))
! 	     (blen (length b))
! 	     (d (/ 1000 (1+ (nth (1- blen) b))))
! 	     (res (math-div-bignum-big (math-mul-bignum-digit a d 0)
! 				       (math-mul-bignum-digit b d 0)
! 				       alen blen)))
! 	(if (= d 1)
! 	    res
! 	  (cons (car res)
! 		(car (math-div-bignum-digit (cdr res) d)))))
!     (let ((res (math-div-bignum-digit a (car b))))
!       (cons (car res) (list (cdr res)))))
  )
  
  ;;; Divide a bignum digit list by a digit.  [l.D l D]
  (defun math-div-bignum-digit (a b)
!   (if a
!       (let* ((res (math-div-bignum-digit (cdr a) b))
! 	     (num (+ (* (cdr res) 1000) (car a))))
! 	(cons
! 	 (cons (/ num b) (car res))
! 	 (% num b)))
!     '(nil . 0))
  )
  
  (defun math-div-bignum-big (a b alen blen)   ; [l.l l L]
***************
*** 4057,4063 ****
    (interactive "sBug Subject: ")
    (mail nil calc-bug-address topic)
    (goto-char (point-max))
!   (insert "\nIn Calc 1.01, Emacs " (emacs-version) "\n\n")
    (message (substitute-command-keys "Type \\[mail-send] to send bug report."))
  )
  
--- 4072,4078 ----
    (interactive "sBug Subject: ")
    (mail nil calc-bug-address topic)
    (goto-char (point-max))
!   (insert "\nIn Calc 1.02, Emacs " (emacs-version) "\n\n")
    (message (substitute-command-keys "Type \\[mail-send] to send bug report."))
  )
  
*** calc-ext.el	Tue Jun 26 16:14:44 1990
--- ../dist/calc-ext.el	Wed Jun 13 11:27:16 1990
***************
*** 88,93 ****
--- 88,94 ----
    (define-key calc-mode-map "\M-w" 'calc-copy-region-as-kill)
    (define-key calc-mode-map "\C-y" 'calc-yank)
    (define-key calc-mode-map "\C-_" 'calc-undo)
+   (define-key calc-mode-map "\C-xu" 'calc-undo)
  
    (define-key calc-mode-map "a" nil)
    (define-key calc-mode-map "a?" 'calc-a-prefix-help)
***************
*** 298,303 ****
--- 299,305 ----
    (define-key calc-mode-map "Ze" 'calc-user-define-edit)
    (define-key calc-mode-map "Zf" 'calc-user-define-formula)
    (define-key calc-mode-map "Zg" 'calc-get-user-defn)
+   (define-key calc-mode-map "Zi" 'calc-insert-variables)
    (define-key calc-mode-map "Zk" 'calc-user-define-kbd-macro)
    (define-key calc-mode-map "Zp" 'calc-user-define-permanent)
    (define-key calc-mode-map "Zu" 'calc-user-undefine)
***************
*** 1212,1217 ****
--- 1214,1221 ----
  	     (set ivar (calc-top 1))
  	   (if (null ival)
  	       (error "No such variable"))
+ 	   (if (stringp ival)
+ 	       (setq ival (math-read-expr ival)))
  	   (setq ival (calc-normalize ival))
  	   (cond ((equal oper "+")
  		  (set ivar (calc-normalize
***************
*** 1294,1299 ****
--- 1298,1307 ----
       (if (not (and (boundp ivar) ivar))
  	 (error "No such variable"))
       (let ((ival (symbol-value ivar)))
+        (if (stringp ival)
+ 	   (setq ival (math-read-expr ival)))
+        (if (eq (car-safe ival) 'error)
+ 	   (error "Bad format in variable contents: %s" (nth 2 ival)))
         (setq ival (calc-normalize ival))
         (calc-record ival (concat "<"
  				 (if (string-match "\\`var-.+\\'" var)
***************
*** 5150,5191 ****
  		    (minibuffer-completion-confirm t)
  		    (oper "r"))
  		(read-from-minibuffer
! 		 "Save variable: " "var-" calc-store-var-map nil)))
  	 pos)
!      (if (equal var "")
! 	 ()
!        (or (and (boundp (intern var)) (intern var))
! 	   (error "No such variable"))
!        (set-buffer (find-file-noselect (substitute-in-file-name
! 					calc-settings-file)))
!        (goto-char (point-min))
!        (if (search-forward (concat "(setq " var " '") nil t)
! 	   (progn
! 	     (setq pos (point-marker))
! 	     (forward-line -1)
! 	     (if (looking-at ";;; Variable .* stored by Calc on ")
! 		 (progn
! 		   (delete-region (match-end 0) (progn (end-of-line) (point)))
! 		   (insert (current-time-string))))
! 	     (goto-char (- pos 8 (length var)))
! 	     (forward-sexp 1)
! 	     (backward-char 1)
! 	     (delete-region pos (point)))
! 	 (goto-char (point-max))
! 	 (insert "\n;;; Variable \""
! 		 var
! 		 "\" stored by Calc on "
! 		 (current-time-string)
! 		 "\n(setq "
! 		 var
! 		 " ')\n")
! 	 (backward-char 2))
!        (insert (prin1-to-string (symbol-value (intern var))))
!        (forward-line 1)
!        (save-buffer))))
  )
  
  
  
  (defun calc-call-last-kbd-macro (arg)
    "Execute the most recent keyboard macro."
--- 5158,5233 ----
  		    (minibuffer-completion-confirm t)
  		    (oper "r"))
  		(read-from-minibuffer
! 		 "Save variable (default=all): " "var-"
! 		 calc-store-var-map nil)))
  	 pos)
!      (or (equal var "") (equal var "var-")
! 	 (and (boundp (intern var)) (intern var))
! 	 (error "No such variable"))
!      (set-buffer (find-file-noselect (substitute-in-file-name
! 				      calc-settings-file)))
!      (if (or (equal var "") (equal var "var-"))
! 	 (mapatoms (function
! 		    (lambda (x)
! 		      (and (string-match "\\`var-" (symbol-name x))
! 			   (boundp x)
! 			   (symbol-value x)
! 			   (not (eq (car-safe (symbol-value x))
! 				    'special-const))
! 			   (calc-insert-permanent-variable x)))))
!        (calc-insert-permanent-variable (intern var)))
!      (save-buffer)))
! )
! 
! (defun calc-insert-permanent-variable (var)
!   (goto-char (point-min))
!   (if (search-forward (concat "(setq " (symbol-name var) " '") nil t)
!       (progn
! 	(setq pos (point-marker))
! 	(forward-line -1)
! 	(if (looking-at ";;; Variable .* stored by Calc on ")
! 	    (progn
! 	      (delete-region (match-end 0) (progn (end-of-line) (point)))
! 	      (insert (current-time-string))))
! 	(goto-char (- pos 8 (length (symbol-name var))))
! 	(forward-sexp 1)
! 	(backward-char 1)
! 	(delete-region pos (point)))
!     (goto-char (point-max))
!     (insert "\n;;; Variable \""
! 	    (symbol-name var)
! 	    "\" stored by Calc on "
! 	    (current-time-string)
! 	    "\n(setq "
! 	    (symbol-name var)
! 	    " ')\n")
!     (backward-char 2))
!   (insert (prin1-to-string (symbol-value var)))
!   (forward-line 1)
  )
  
  
+ (defun calc-insert-variables (buf)
+   "Insert all variables beginning with \"var-\" in the specified buffer."
+   (interactive "bBuffer in which to save variable values: ")
+   (save-excursion
+     (set-buffer buf)
+     (mapatoms (function
+ 	       (lambda (x)
+ 		 (and (string-match "\\`var-" (symbol-name x))
+ 		      (boundp x)
+ 		      (symbol-value x)
+ 		      (not (eq (car-safe (symbol-value x)) 'special-const))
+ 		      (insert "(setq "
+ 			      (symbol-name x)
+ 			      " "
+ 			      (prin1-to-string
+ 			       (if (stringp (symbol-value x))
+ 				   (symbol-value x)
+ 				 (math-format-value (symbol-value x) 1000)))
+ 			      ")\n"))))))
+ )
+ 
  
  (defun calc-call-last-kbd-macro (arg)
    "Execute the most recent keyboard macro."
***************
*** 5236,5241 ****
--- 5278,5286 ----
  		       (insert fmt "\n"))
  		     (setq new-stack (cdr new-stack)))
  		   (calc-renumber-stack))
+ 	       (while new-stack
+ 		 (calc-record-undo (list 'push 1))
+ 		 (setq new-stack (cdr new-stack)))
  	       (calc-refresh))
  	     (calc-record-undo (list 'set 'saved-stack-top 0))))))))
  )
***************
*** 10632,10642 ****
  	       (not (eq (car-safe (symbol-value (nth 2 x)))
  			'incomplete)))
  	  (let ((val (symbol-value (nth 2 x))))
! 	    (if (eq (car-safe val) 'special-const)
! 		(if calc-symbolic-mode
! 		    x
! 		  val)
! 	      val))
  	x)
      x)
  )
--- 10677,10691 ----
  	       (not (eq (car-safe (symbol-value (nth 2 x)))
  			'incomplete)))
  	  (let ((val (symbol-value (nth 2 x))))
! 	    (if (stringp val)
! 		(setq val (math-read-expr val)))
! 	    (if (eq (car-safe val) 'error)
! 		x
! 	      (if (eq (car-safe val) 'special-const)
! 		  (if calc-symbolic-mode
! 		      x
! 		    val)
! 		val)))
  	x)
      x)
  )
***************
*** 12795,12801 ****
       ( Ang     "1e-10 m"	     "Angstrom" )
       
       ;; Area
!      ( hect    "1000 m^2"	     "*Hectare" )
       ( acre    "mi^2 / 640"	     "Acre" )
       ( b       "1e-28 m^2"	     "Barn" )
       
--- 12844,12850 ----
       ( Ang     "1e-10 m"	     "Angstrom" )
       
       ;; Area
!      ( hect    "10000 m^2"	     "*Hectare" )
       ( acre    "mi^2 / 640"	     "Acre" )
       ( b       "1e-28 m^2"	     "Barn" )
       
*** calc.texinfo	Tue Jun 26 16:14:49 1990
--- ../dist/calc.texinfo	Tue Jun 26 16:34:50 1990
***************
*** 1,7 ****
  \input texinfo                  @c -*-texinfo-*-
  @comment %**start of header (This is for running Texinfo on a region.)
  @setfilename calc-info
! @settitle GNU Emacs Calc 1.01 Manual
  @setchapternewpage odd
  @comment %**end of header (This is for running Texinfo on a region.)
  
--- 1,7 ----
  \input texinfo                  @c -*-texinfo-*-
  @comment %**start of header (This is for running Texinfo on a region.)
  @setfilename calc-info
! @settitle GNU Emacs Calc 1.02 Manual
  @setchapternewpage odd
  @comment %**end of header (This is for running Texinfo on a region.)
  
***************
*** 38,46 ****
  @sp 6
  @center @titlefont{Calc Manual}
  @sp 4
! @center GNU Emacs Calc Version 1.01
  @sp 1
! @center May 1990
  @sp 5
  @center Dave Gillespie
  @page
--- 38,46 ----
  @sp 6
  @center @titlefont{Calc Manual}
  @sp 4
! @center GNU Emacs Calc Version 1.02
  @sp 1
! @center June 1990
  @sp 5
  @center Dave Gillespie
  @page
***************
*** 760,770 ****
  automatically enters that number and then does the requested command.
  Thus @kbd{2 @key{RET} 3 +} will work just as well.@refill
  
  The @key{DEL} key is called Backspace on some keyboards.  It is
  whatever key you would use to correct a simple typing error when
  regularly using Emacs.  The @key{DEL} key pops and throws away the
  top value on the stack.  (You can still get that value back from
! the Trail if you should need it later on.)
  
  Since the @kbd{-} key is also an operator (it subtracts the top two
  stack elements), how does one enter a negative number?  Calc uses
--- 760,791 ----
  automatically enters that number and then does the requested command.
  Thus @kbd{2 @key{RET} 3 +} will work just as well.@refill
  
+ Examples in this tutorial will often omit @key{RET} even when the
+ stack displays shown would only happen if you did press @key{RET}:
+ 
+ @group
+ @example
+ 1:  2          2:  2          1:  5
+     .          1:  3              .
+                    .
+ 
+   2 RET            3              +
+ @end example
+ @end group
+ 
+ Here, after pressing @kbd{3} the stack would really show @samp{1:  2}
+ with @samp{Calc: 3} in the minibuffer.  In these situations, you can
+ press the optional @key{RET} to see the stack as the figure shows.
+ 
  The @key{DEL} key is called Backspace on some keyboards.  It is
  whatever key you would use to correct a simple typing error when
  regularly using Emacs.  The @key{DEL} key pops and throws away the
  top value on the stack.  (You can still get that value back from
! the Trail if you should need it later on.)  There are many places
! in this tutorial where we assume you have used @key{DEL} to erase the
! results of the previous example at the beginning of a new example.
! In the few places that it is really important to use @key{DEL} to
! clear away old results, the text will remind you to do so.
  
  Since the @kbd{-} key is also an operator (it subtracts the top two
  stack elements), how does one enter a negative number?  Calc uses
***************
*** 1626,1632 ****
  @end group
  
  The shift-@kbd{S} command computes the sine of an angle.  The sine
! of 45 degrees is @samp{sqrt(2)/2}; squaring this yields {2/4 = 0.5}.
  However, there has been a slight roundoff error because the
  resentation of @samp{sqrt(2)/2} wasn't exact.  The @kbd{c 1}
  command is a handy way to clean up numbers in this case; it
--- 1647,1653 ----
  @end group
  
  The shift-@kbd{S} command computes the sine of an angle.  The sine
! of 45 degrees is @samp{sqrt(2)/2}; squaring this yields @samp{2/4 = 0.5}.
  However, there has been a slight roundoff error because the
  resentation of @samp{sqrt(2)/2} wasn't exact.  The @kbd{c 1}
  command is a handy way to clean up numbers in this case; it
***************
*** 2262,2268 ****
  @end group
  
  The vertical bar @kbd{|} @dfn{concatenates} numbers, vectors, and
! matrices together.  Here we have used it to add a new column onto
  our matrix to make it square.
  
  We can multiply these two matrices in either order to get an identity.
--- 2283,2289 ----
  @end group
  
  The vertical bar @kbd{|} @dfn{concatenates} numbers, vectors, and
! matrices together.  Here we have used it to add a new row onto
  our matrix to make it square.
  
  We can multiply these two matrices in either order to get an identity.
***************
*** 2746,2760 ****
  
  @group
  @example
! 1:  30 +/- 1     2:  30 +/- 1     1:  3.75 +/- 0.156   1:  75.06 +/- 0.594
!     .            1:  8 +/- 0.2        .                    .
                       .
  
!     30 p 1           8 p .2           /                   I T
  @end example
  @end group
  
! This means that the angle is about 75 degrees, and, assuming our
  original error estimates were valid standard deviations, there is about
  a 60% chance that the result is correct within 0.59 degrees.
  
--- 2767,2781 ----
  
  @group
  @example
! 1:  8 +/- 0.2    2:  8 +/- 0.2    1:  0.266 +/- 0.011   1:  14.9 +/- 0.594
!     .            1:  30 +/- 1         .                     .
                       .
  
!     8 p .2           30 p 1           /                     I T
  @end example
  @end group
  
! This means that the angle is about 15 degrees, and, assuming our
  original error estimates were valid standard deviations, there is about
  a 60% chance that the result is correct within 0.59 degrees.
  
***************
*** 2766,2776 ****
  
  @group
  @example
! 1:  [28 .. 31]  2:  [28 .. 31]    1:  [3.45 .. 4.02]  1:  [73.86 .. 76.05]
!     .           1:  [7.7 .. 8.1]      .                   .
!                     .
  
!   [ 28 .. 31 ]    [ 7.7 .. 8.1 ]      /                  I T
  @end example
  @end group
  
--- 2787,2797 ----
  
  @group
  @example
! 1:  [7.7 .. 8.1]  2:  [7.7 .. 8.1]  1:  [0.24 .. 0.28]  1:  [13.9 .. 16.1]
!     .             1:  [28 .. 31]        .                   .
!                       .
  
!   [ 7.7 .. 8.1 ]    [ 28 .. 31 ]        /                   I T
  @end example
  @end group
  
***************
*** 3283,3289 ****
  
  @group
  @example
! 1:  x^6          2:  x^2        1: 360 x^2
      .            1:  4             .
                       .
  
--- 3304,3310 ----
  
  @group
  @example
! 1:  x^6          2:  x^6        1: 360 x^2
      .            1:  4             .
                       .
  
***************
*** 4718,4723 ****
--- 4739,4746 ----
  in the file include everything controlled by the @kbd{m} and @kbd{d}
  prefix keys, the current precision and binary word size, whether or not
  the trail is displayed, and the current height of the Calc window.
+ If there were already saved mode settings in the file, they are replaced.
+ Otherwise, the new mode information is appended to the end of the file.
  (You can change which file this uses; @pxref{Installation}.)@refill
  
  @kindex m x
***************
*** 5822,5828 ****
  @tindex arg
  The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the
  ``argument'' or polar angle of a complex number.  For a number in polar
! notation, this is simply the second component of the pair @samp{(r,theta)}.
  The result is expressed according to the current angular mode and will
  be in the range -180 degrees (exclusive) to +180 degrees (inclusive),
  or the equivalent range in radians.@refill
--- 5845,5851 ----
  @tindex arg
  The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the
  ``argument'' or polar angle of a complex number.  For a number in polar
! notation, this is simply the second component of the pair @samp{(r;theta)}.
  The result is expressed according to the current angular mode and will
  be in the range -180 degrees (exclusive) to +180 degrees (inclusive),
  or the equivalent range in radians.@refill
***************
*** 7915,7920 ****
--- 7938,7956 ----
  by hand.  (The shift-@kbd{Z} prefix key is mainly for defining user
  commands; @pxref{Programming}.)
  
+ If you do not specify the name of a variable to save (i.e.,
+ @kbd{Z V @key{RET}}), all @samp{var-} variables with defined values
+ are saved.
+ 
+ @kindex Z I
+ @pindex calc-insert-variables
+ The shift-@kbd{Z I} (@code{calc-insert-variables}) command writes
+ the values of all @samp{var-} variables into a specified buffer.
+ The variables are written in the form of Lisp @code{setq} commands
+ which store the values in string form.  You can place these commands
+ in your @file{.emacs} buffer if you wish, though in this case it
+ would be easier to use @kbd{Z V @key{RET}}.
+ 
  The only variables with predefined values are the ``special constants''
  @code{var-pi}, @code{var-e}, and @code{var-i}.  You are free to unstore these
  variables or to store a new value over them if you like, although some
***************
*** 8527,8534 ****
  for all mode-setting commands inside the macro.
  
  The contents of the stack and trail, values of non-quick variables, and
! other settings such as the various display modes, are @emph{not}
! affected by @kbd{Z `} and @kbd{Z '}.
  
  @node Queries in Macros, , Local Values in Macros, Keyboard Macros
  @subsection Queries in Keyboard Macros
--- 8563,8570 ----
  for all mode-setting commands inside the macro.
  
  The contents of the stack and trail, values of non-quick variables, and
! other settings such as the language mode and the various display modes,
! are @emph{not} affected by @kbd{Z `} and @kbd{Z '}.
  
  @node Queries in Macros, , Local Values in Macros, Keyboard Macros
  @subsection Queries in Keyboard Macros
***************
*** 9348,9354 ****
  @var{value})} stored in their value cell, where @var{value} is a formula
  which is evaluated when the constant's value is requested.  Variables
  which represent units are not stored in any special way; they are units
! only because their names appear in the units table.@refill
  
  A Lisp list with any other symbol as the first element is a function call.
  The symbols @code{+}, @code{-}, @code{*}, @code{/}, @code{%}, @code{^},
--- 9384,9392 ----
  @var{value})} stored in their value cell, where @var{value} is a formula
  which is evaluated when the constant's value is requested.  Variables
  which represent units are not stored in any special way; they are units
! only because their names appear in the units table.  If the value
! cell contains a string, it is parsed to get the variable's value when
! the variable is used.@refill
  
  A Lisp list with any other symbol as the first element is a function call.
  The symbols @code{+}, @code{-}, @code{*}, @code{/}, @code{%}, @code{^},
***************
*** 9592,9598 ****
  of various types, negative HMS forms, and intervals in which all
  included values are negative.  In @code{defmath}, the expression
  @samp{(< x 0)} will automatically be converted to @samp{(math-negp x)},
! and @samp{(>= x 0)} will be converted to samp{(not (math-negp x))}.
  @end defun
  
  @defun posp x
--- 9630,9636 ----
  of various types, negative HMS forms, and intervals in which all
  included values are negative.  In @code{defmath}, the expression
  @samp{(< x 0)} will automatically be converted to @samp{(math-negp x)},
! and @samp{(>= x 0)} will be converted to @samp{(not (math-negp x))}.
  @end defun
  
  @defun posp x