home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume14 / gmcalc / patch03 next >
Encoding:
Text File  |  1990-08-09  |  53.9 KB  |  1,430 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v14i050: Patch for GNU Emacs Calc, version 1.03 -> 1.04, part 1/2
  3. from: daveg@csvax.cs.caltech.edu (David Gillespie)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 14, Issue 50
  7. Submitted-by: daveg@csvax.cs.caltech.edu (David Gillespie)
  8. Archive-name: gmcalc/patch03
  9.  
  10. The following patches convert Calc version 1.03 into Calc
  11. version 1.04.  To apply them automatically with Patch v2.0,
  12. first cd into your Calc distribution directory, then execute
  13. "patch -p0 <calc.patch", where "calc.patch" is the name of this file.
  14. You will want to re-byte-compile both parts, and re-format the
  15. manual, as explained in the calc-INSTALL file.
  16.  
  17. This is part 1 of 2 patches.  You must apply both in order to
  18. complete the upgrade to version 1.04.
  19.  
  20. These patches do not cover the README file, but the interesting
  21. part of that file (the revision history) is now present near the
  22. top of calc.el.  The INSTALL file is now being included in the
  23. patches under the name calc-INSTALL.
  24.  
  25. Note that some patches will add to the list of "autoload" commands
  26. recommended in the calc-INSTALL file.
  27.  
  28. Patches and complete tar files are also available from anonymous FTP
  29. on csvax.cs.caltech.edu [131.215.131.131], in the "pub" subdirectory.
  30.  
  31. Enjoy!
  32.                             -- Dave
  33.  
  34. Dave Gillespie
  35. 256-80 Caltech, Pasadena CA 91125
  36. daveg@csvax.cs.caltech.edu, ...!cit-vax!daveg
  37.  
  38.  
  39.  
  40. *** calc.el    Tue Jun 26 20:53:26 1990
  41. --- ../dist/calc.el    Mon Aug  6 14:54:39 1990
  42. ***************
  43. *** 1,4 ****
  44. ! ;; Calculator for GNU Emacs version 1.03
  45.   ;; Copyright (C) 1990 Dave Gillespie
  46.   
  47.   ;; This file is part of GNU Emacs.
  48. --- 1,4 ----
  49. ! ;; Calculator for GNU Emacs version 1.04
  50.   ;; Copyright (C) 1990 Dave Gillespie
  51.   
  52.   ;; This file is part of GNU Emacs.
  53. ***************
  54. *** 44,53 ****
  55.   
  56.   ;;; Author's address:
  57.   ;;;   Dave Gillespie, 256-80 Caltech, Pasadena CA 91125.
  58. ! ;;;   daveg@csvax.caltech.edu, ...!cit-vax!daveg.
  59.   ;;;
  60.   ;;; This file and the manual, calc.texinfo, are available from anonymous FTP
  61. ! ;;; on csvax.caltech.edu [192.12.18.1]; look in ~ftp/pub/calc*.
  62.   ;;;
  63.   ;;; Bug reports and suggestions are always welcome!
  64.   
  65. --- 44,56 ----
  66.   
  67.   ;;; Author's address:
  68.   ;;;   Dave Gillespie, 256-80 Caltech, Pasadena CA 91125.
  69. ! ;;;   daveg@csvax.cs.caltech.edu, ...!cit-vax!daveg.
  70.   ;;;
  71. + ;;; Note that csvax's name has changed slightly.  The old name,
  72. + ;;; csvax.caltech.edu, will also still work for a while.
  73. + ;;;
  74.   ;;; This file and the manual, calc.texinfo, are available from anonymous FTP
  75. ! ;;; on csvax.cs.caltech.edu [131.215.131.131]; look in ~ftp/pub/calc*.
  76.   ;;;
  77.   ;;; Bug reports and suggestions are always welcome!
  78.   
  79. ***************
  80. *** 58,69 ****
  81.   ;;; and "defmath".  User-accessible variables begin with "var-".
  82.   
  83.   
  84.   
  85.   (provide 'calc)
  86.   
  87.   (defmacro calc-record-compilation-date-macro ()
  88.     (` (setq calc-version (concat "Emacs Calc Mode"
  89. !                 " v1.03 by Dave Gillespie"
  90.                   ", installed "
  91.                   (, (current-time-string))
  92.                   " by "
  93. --- 61,124 ----
  94.   ;;; and "defmath".  User-accessible variables begin with "var-".
  95.   
  96.   
  97. + ;;; Version 1.04:
  98. + ;;;  * Included a copy of revision history (from README) in calc.el.
  99. + ;;;  * Added the "calc-split" feature to split calc-ext.el into smaller bits.
  100. + ;;;  * Changed calc-unpack to unpack floats and fractions, too.
  101. + ;;;  * Added "mant", "xpon", and "scf" functions for decomposing floats.
  102. + ;;;  * Fixed a bug in the "y" command with positive prefix arguments.
  103. + ;;;  * Rearranged binary shift/rotate command keys to be a bit more convenient.
  104. + ;;;  * Fixed a bug in which simplifying "(0/0) * 2" crashed with a Lisp error.
  105. + ;;;  * Made `H F' [ffloor] and friends faster for very large arguments.
  106. + ;;;  * Made calc-define-del more robust.
  107. + ;;;  * Handled pasting of data into the Calculator using the mouse under X.
  108. + ;;;  * Made overlay-arrow variables buffer-local to avoid interference.
  109. + ;;;  * Fixed a problem in which Calc Trail buffer got stuck after a C-x C-w.
  110. + ;;; 
  111. + ;;; Version 1.03:
  112. + ;;;  * Changed math-choose to compute n-choose-m faster when m is large.
  113. + ;;;  * Fixed some problems with TeX mode.
  114. + ;;;  * Fixed a bug that prevented `b s' from working without a prefix argument.
  115. + ;;;  * Added "calc-eval" function.
  116. + ;;;  * Improved calc-grab-region.
  117. + ;;; 
  118. + ;;; Version 1.02:
  119. + ;;;  * Fixed a bug in Tutorial: telephone pole height/distance were switched!
  120. + ;;;  * Fixed a few other things in the manual.
  121. + ;;;  * Added "full-calc" command.
  122. + ;;;  * Added "calc-insert-variables" (`Z I') command.
  123. + ;;;  * Quick Calc now works even if you are already in the minibuffer.
  124. + ;;;  * Fixed a bug in math-mul-bignum-digit which affected math-and, etc.
  125. + ;;;  * Definition of "Hectares" was wrong in units table.
  126. + ;;;  * Fixed a bug in calc-execute-kbd-macro concerning undo and refresh.
  127. + ;;;  * Bound "calc-undo" to `C-x u' as well as `C-_' and `U'.
  128. + ;;; 
  129. + ;;; Version 1.01:
  130. + ;;;  * Added a tutorial section to the manual.
  131. + ;;;  * Next and Prev for node Strings in the manual were reversed; fixed.
  132. + ;;;  * Changed "'bignum" in calc-isqrt-bignum-iter to "'bigpos".
  133. + ;;;  * Fixed a bug that prevented "$" from working during algebraic entry.
  134. + ;;;  * Fixed a bug caused by an X (last-X) command following a K (macro) cmd.
  135. + ;;;  * Fixed a bug in which K command incorrectly formatted stack in Big mode.
  136. + ;;;  * Added space between unary operators and non-flat compositions.
  137. + ;;;    (Otherwise, "-(a/b)" in Big mode blended the minus sign into the rule!)
  138. + ;;;  * Fixed formatting of (-1)^n in Big mode.
  139. + ;;;  * Fixed some problems relating to "not" operator in Pascal language mode.
  140. + ;;;  * Fixed several bugs relating to V M ' and V M $ sequences.
  141. + ;;;  * Fixed matrix-vector multiplication to produce a vector.
  142. + ;;;  * Introduced Z ` ... Z ' commands; renamed old Z ' to Z #.
  143. + ;;;  * Fixed various other bugs.
  144. + ;;;  * Added calc-settings-file variable suggested by C. Witty.
  145. + ;;; 
  146. + ;;; Version 1.00:
  147. + ;;;  * First official release of Calc.
  148.   
  149.   (provide 'calc)
  150.   
  151.   (defmacro calc-record-compilation-date-macro ()
  152.     (` (setq calc-version (concat "Emacs Calc Mode"
  153. !                 " v1.04 by Dave Gillespie"
  154.                   ", installed "
  155.                   (, (current-time-string))
  156.                   " by "
  157. ***************
  158. *** 85,93 ****
  159.   
  160.   ;;; IDEAS:
  161.   ;;;
  162. - ;;;   Consider breaking calc-ext.el into several extension modules:
  163. - ;;;      Base extensions, algebra/units, scientific, programming
  164. - ;;;
  165.   ;;;   How about putting cursor on an operator or functor in stack window
  166.   ;;;      to indicate the subterm to which a command should apply?
  167.   ;;;   Make math-simplify faster!
  168. --- 140,145 ----
  169. ***************
  170. *** 119,124 ****
  171. --- 171,177 ----
  172.   ;;;   Consider implementing some other special functions.
  173.   ;;;   May as well make continued-fractions stuff available to the user.
  174.   ;;;   Provide date arithmetic a la HP 48.
  175. + ;;;   Consider providing infinities and indeterminate values as a data type.
  176.   ;;;
  177.   ;;;   Implement some more built-in statistical functions:
  178.   ;;;      mean, median, variance, std dev of a list.
  179. ***************
  180. *** 141,146 ****
  181. --- 194,200 ----
  182.   ;;;   Provide more examples in the tutorial section of the manual.
  183.   ;;;   Cover in the tutorial:  language modes, simplification modes,
  184.   ;;;       bitwise stuff, rewrite rules.
  185. + ;;;   Add some exercises to the tutorial.
  186.   ;;;   Provide more Lisp programming examples in the manual.
  187.   ;;;   Finish the Internals section of the manual.
  188.   ;;;
  189. ***************
  190. *** 147,153 ****
  191.   ;;;   Tim suggests adding spreadsheet-like features.
  192.   ;;;   How about ultra-low-resolution plots?  (Probably too slow.)
  193.   ;;;   How about running gnuplot to generate high-res plots?
  194. ! ;;;   Implement language modes for Lisp, Ada, ...?
  195.   ;;;
  196.   
  197.   
  198. --- 201,207 ----
  199.   ;;;   Tim suggests adding spreadsheet-like features.
  200.   ;;;   How about ultra-low-resolution plots?  (Probably too slow.)
  201.   ;;;   How about running gnuplot to generate high-res plots?
  202. ! ;;;   Implement language modes for Eqn, Gnuplot, Lisp, Ada, ...?
  203.   ;;;
  204.   
  205.   
  206. ***************
  207. *** 416,421 ****
  208. --- 470,478 ----
  209.   (defvar calc-executing-macro nil)
  210.   
  211.   
  212. + (defvar calc-trail-buffer nil)
  213.   (defvar calc-other-modes nil
  214.     "List of used-defined strings to append to Calculator mode line.")
  215.   
  216. ***************
  217. *** 450,456 ****
  218.   
  219.   (defun calc-define-del (map func)
  220.     (define-key map "\C-d" func)
  221. !   (mapcar (function (lambda (x) (define-key map x func)))
  222.         (append (where-is-internal 'delete-backward-char global-map)
  223.             (where-is-internal 'backward-delete-char global-map)))
  224.   )
  225. --- 507,515 ----
  226.   
  227.   (defun calc-define-del (map func)
  228.     (define-key map "\C-d" func)
  229. !   (mapcar (function (lambda (x) (condition-case err
  230. !                     (define-key map x func)
  231. !                   (error nil))))
  232.         (append (where-is-internal 'delete-backward-char global-map)
  233.             (where-is-internal 'backward-delete-char global-map)))
  234.   )
  235. ***************
  236. *** 646,651 ****
  237. --- 705,715 ----
  238.         (progn
  239.       (setq calc-loaded-settings-file t)
  240.       (load calc-settings-file t)))   ; t = missing-ok
  241. +   (if (eq window-system 'x)
  242. +       (progn
  243. +     (or (boundp 'calc-old-x-paste-text)
  244. +         (setq calc-old-x-paste-text (symbol-function 'x-paste-text)))
  245. +     (define-key mouse-map x-button-middle 'calc-x-paste-text)))
  246.     (run-hooks 'calc-mode-hook)
  247.     (calc-refresh t)
  248.     (calc-set-mode-line)
  249. ***************
  250. *** 667,672 ****
  251. --- 731,738 ----
  252.     (setq mode-name "Calc Trail")
  253.     (setq truncate-lines nil)
  254.     (setq buffer-read-only t)
  255. +   (make-local-variable 'overlay-arrow-position)
  256. +   (make-local-variable 'overlay-arrow-string)
  257.     (if buf
  258.         (progn
  259.       (make-local-variable 'calc-main-buffer)
  260. ***************
  261. *** 731,742 ****
  262.                 (select-window w))
  263.             (pop-to-buffer (current-buffer)))))))
  264.       (save-excursion
  265. !       (let ((buf (current-buffer)))
  266. !         (set-buffer (get-buffer-create "*Calc Trail*"))
  267. !         (calc-trail-mode buf)
  268. !         (and calc-display-trail
  269. !          (= (window-width) (screen-width))
  270. !          (calc-trail-display 1 t))))
  271.       (calc-summary full-display)
  272.       (and calc-said-hello
  273.            (interactive-p)
  274. --- 797,806 ----
  275.                 (select-window w))
  276.             (pop-to-buffer (current-buffer)))))))
  277.       (save-excursion
  278. !       (set-buffer (calc-trail-buffer))
  279. !       (and calc-display-trail
  280. !            (= (window-width) (screen-width))
  281. !            (calc-trail-display 1 t)))
  282.       (calc-summary full-display)
  283.       (and calc-said-hello
  284.            (interactive-p)
  285. ***************
  286. *** 776,790 ****
  287.     (mapcar (function
  288.          (lambda (v) (set-default v (symbol-value v)))) calc-local-var-list)
  289.     (let ((buf (current-buffer))
  290. -     (tbuf (get-buffer-create "*Calc Trail*"))
  291.       (win (get-buffer-window (current-buffer))))
  292.       (if (and win
  293.            (< (window-height win) (1- (screen-height))))
  294.       (setq calc-window-height (- (window-height win) 2)))
  295.       (delete-windows-on buf)
  296. !     (delete-windows-on tbuf)
  297.       (bury-buffer buf)
  298. !     (bury-buffer tbuf))
  299.   )
  300.   
  301.   (defun quick-calc ()
  302. --- 840,853 ----
  303.     (mapcar (function
  304.          (lambda (v) (set-default v (symbol-value v)))) calc-local-var-list)
  305.     (let ((buf (current-buffer))
  306.       (win (get-buffer-window (current-buffer))))
  307.       (if (and win
  308.            (< (window-height win) (1- (screen-height))))
  309.       (setq calc-window-height (- (window-height win) 2)))
  310.       (delete-windows-on buf)
  311. !     (delete-windows-on calc-trail-buffer)
  312.       (bury-buffer buf)
  313. !     (bury-buffer calc-trail-buffer))
  314.   )
  315.   
  316.   (defun quick-calc ()
  317. ***************
  318. *** 1347,1354 ****
  319. --- 1410,1433 ----
  320.     (calc-wrapper)
  321.   )
  322.   
  323. + (defun calc-x-paste-text (arg)
  324. +   "Move point to mouse position and insert window system cut buffer contents.
  325. + If mouse is pressed in Calc window, push cut buffer contents onto the stack."
  326. +   (x-mouse-select arg)
  327. +   (if (memq major-mode '(calc-mode calc-trail-mode))
  328. +       (progn
  329. +     (calc-wrapper
  330. +      (calc-extensions)
  331. +      (let ((val (math-read-exprs (calc-clean-newlines
  332. +                       (x-get-cut-buffer)))))
  333. +        (if (eq (car-safe val) 'error)
  334. +            (error "%s in yanked data" (nth 2 val))
  335. +          (calc-enter-result 0 "Xynk" val)))))
  336. +     (funcall calc-old-x-paste-text arg))
  337. + )
  338.   
  339.   
  340.   ;;;; The Calc Trail buffer.
  341.   
  342.   (defun calc-check-trail-aligned ()
  343. ***************
  344. *** 1366,1375 ****
  345.       body)
  346.   )
  347.   
  348.   (defun calc-record (val &optional prefix)
  349.     (or calc-executing-macro
  350.         (let* ((mainbuf (current-buffer))
  351. !          (buf (get-buffer-create "*Calc Trail*"))
  352.            (calc-display-raw (eq calc-display-raw t))
  353.            (fval (if val
  354.                  (if (stringp val)
  355. --- 1445,1466 ----
  356.       body)
  357.   )
  358.   
  359. + (defun calc-trail-buffer ()
  360. +   (and (or (null calc-trail-buffer)
  361. +        (null (buffer-name calc-trail-buffer)))
  362. +        (save-excursion
  363. +      (setq calc-trail-buffer (get-buffer-create "*Calc Trail*"))
  364. +      (let ((buf (current-buffer)))
  365. +        (set-buffer calc-trail-buffer)
  366. +        (or (eq major-mode 'calc-trail-mode)
  367. +            (calc-trail-mode (current-buffer))))))
  368. +   calc-trail-buffer
  369. + )
  370.   (defun calc-record (val &optional prefix)
  371.     (or calc-executing-macro
  372.         (let* ((mainbuf (current-buffer))
  373. !          (buf (calc-trail-buffer))
  374.            (calc-display-raw (eq calc-display-raw t))
  375.            (fval (if val
  376.                  (if (stringp val)
  377. ***************
  378. *** 1379,1386 ****
  379.                "")))
  380.       (save-excursion
  381.         (set-buffer buf)
  382. -       (if (not (eq major-mode 'calc-trail-mode))
  383. -           (calc-trail-mode mainbuf))
  384.         (let ((aligned (calc-check-trail-aligned))
  385.           (buffer-read-only nil))
  386.           (goto-char (point-max))
  387. --- 1470,1475 ----
  388. ***************
  389. *** 1409,1416 ****
  390.     "Turn the Trail display on or off.
  391.   With prefix argument 1, turn it on; with argument 0, turn it off."
  392.     (interactive "P")
  393. !   (let* ((trail (get-buffer-create "*Calc Trail*"))
  394. !      (win (get-buffer-window trail)))
  395.       (if (setq calc-display-trail
  396.             (not (if flag (memq flag '(nil 0)) win)))
  397.       (if (null win)
  398. --- 1498,1504 ----
  399.     "Turn the Trail display on or off.
  400.   With prefix argument 1, turn it on; with argument 0, turn it off."
  401.     (interactive "P")
  402. !   (let ((win (get-buffer-window (calc-trail-buffer))))
  403.       (if (setq calc-display-trail
  404.             (not (if flag (memq flag '(nil 0)) win)))
  405.       (if (null win)
  406. ***************
  407. *** 1418,1424 ****
  408.             (if (and (boundp 'calc-trail-window-hook) calc-trail-window-hook)
  409.             (run-hooks 'calc-trail-window-hook)
  410.           (let ((w (split-window nil (/ (* (window-width) 2) 3) t)))
  411. !           (set-window-buffer w trail)))
  412.             (calc-wrapper
  413.              (or no-refresh
  414.              (calc-refresh)))))
  415. --- 1506,1512 ----
  416.             (if (and (boundp 'calc-trail-window-hook) calc-trail-window-hook)
  417.             (run-hooks 'calc-trail-window-hook)
  418.           (let ((w (split-window nil (/ (* (window-width) 2) 3) t)))
  419. !           (set-window-buffer w calc-trail-buffer)))
  420.             (calc-wrapper
  421.              (or no-refresh
  422.              (calc-refresh)))))
  423. ***************
  424. *** 1430,1437 ****
  425.            (calc-refresh)))))
  426.         (if (and (boundp 'overlay-arrow-position)
  427.              (eq overlay-arrow-position calc-trail-pointer))
  428. !       (setq overlay-arrow-position nil)))
  429. !     trail)
  430.   )
  431.   
  432.   (defun calc-trail-here ()
  433. --- 1518,1525 ----
  434.            (calc-refresh)))))
  435.         (if (and (boundp 'overlay-arrow-position)
  436.              (eq overlay-arrow-position calc-trail-pointer))
  437. !       (setq overlay-arrow-position nil))))
  438. !   calc-trail-buffer
  439.   )
  440.   
  441.   (defun calc-trail-here ()
  442. ***************
  443. *** 4106,4112 ****
  444.     (interactive "sBug Subject: ")
  445.     (mail nil calc-bug-address topic)
  446.     (goto-char (point-max))
  447. !   (insert "\nIn Calc 1.03, Emacs " (emacs-version) "\n\n")
  448.     (message (substitute-command-keys "Type \\[mail-send] to send bug report."))
  449.   )
  450.   
  451. --- 4194,4200 ----
  452.     (interactive "sBug Subject: ")
  453.     (mail nil calc-bug-address topic)
  454.     (goto-char (point-max))
  455. !   (insert "\nIn Calc 1.04, Emacs " (emacs-version) "\n\n")
  456.     (message (substitute-command-keys "Type \\[mail-send] to send bug report."))
  457.   )
  458.   
  459. *** calc-INSTALL    Mon Aug  6 15:07:44 1990
  460. --- ../dist/calc-INSTALL    Mon Aug  6 15:04:40 1990
  461. ***************
  462. *** 0 ****
  463. --- 1,185 ----
  464. + Installation
  465. + ************
  466. + Calc 1.04 comes as a pair of Emacs Lisp files, generally called
  467. + `calc.el' and `calc-ext.el'.  The first contains the basic foundations
  468. + of the Calculator, and is as small as possible to promote quick loading.
  469. + The second contains all the more advanced commands and functions.  Calc
  470. + is usually installed so that the `M-x calc' or `M-#' command auto-loads
  471. + only the first part, and the second part is auto-loaded whenever the
  472. + first advanced feature is used.
  473. + Compilation
  474. + ===========
  475. + Calc is written in a way that maximizes performance when its code has been
  476. + byte-compiled; a side effect is that performance is seriously degraded if
  477. + it *isn't* compiled.  Thus, it is essential to compile the Calculator
  478. + before trying to use it.  The Emacs command `M-x byte-compile-file'
  479. + is used to compile an Emacs Lisp file.  Compile each of `calc.el' and
  480. + `calc-ext.el' to obtain byte-code files `calc.elc' and
  481. + `calc-ext.elc'.  You may find you need to do `M-x load-file
  482. + calc.elc' before compiling `calc-ext.el' will work.
  483. + For your convenience, the FTP distribution of Calc, obtainable from
  484. + anonymous FTP on `csvax.cs.caltech.edu', includes already-compiled
  485. + versions of both of these files.
  486. + Auto-loading
  487. + ============
  488. + To teach Emacs how to load in Calc when you type `M-x calc' for the
  489. + first time, include these lines in your `.emacs' file (if you are
  490. + installing Calc just for your own use), or the system's `lisp/default'
  491. + file (if you are installing Calc publicly).
  492. +      (autoload 'calc             ".../calc.elc"     "Calculator Mode" t nil)
  493. +      (autoload 'calc-extensions  ".../calc-ext.elc" nil nil nil)
  494. +      (autoload 'quick-calc       ".../calc.elc"     "Quick Calculator" t nil)
  495. +      (autoload 'full-calc        ".../calc.elc"     "Full-screen Calculator" t nil)
  496. +      (autoload 'calc-eval        ".../calc.elc"     "Call Calculator" nil nil)
  497. +      (autoload 'calc-grab-region ".../calc-ext.elc" nil t nil)
  498. +      (autoload 'defmath          ".../calc-ext.elc" nil t t)
  499. + where `.../calc.elc' represents the full path to the `calc.elc'
  500. + file, and similarly for `.../calc-ext.elc'.  If you have installed
  501. + these files in Emacs' main `lisp/' directory, you can just write
  502. + `"calc.elc"' and `"calc-ext.elc"'.
  503. + The `autoload' command for `calc' is what loads `calc.elc'
  504. + when you type `M-x calc'.  The `autoload' for `calc-extensions'
  505. + brings in the extensions module; Calc takes care to call the
  506. + `calc-extensions' function (which doesn't actually do anything)
  507. + before any operation that requires the extensions to be present.
  508. + The other five `autoload' commands are for functions which might
  509. + reasonably be used before the user has typed `M-x calc' for the
  510. + first time.
  511. + Merging `calc' and `calc-ext'
  512. + =============================
  513. + If you don't want to bother with a split Calculator, you can simply
  514. + concatenate `calc-ext.elc' onto the end of `calc.elc', rewrite
  515. + the above `autoload' commands all to point to the combined file,
  516. + and treat Calc as one big program.  You may need to do this if
  517. + the `autoload' mechanism is giving you problems.
  518. + Splitting `calc-ext'
  519. + ====================
  520. + On the other hand, you may find that `calc-ext.el' is too big to load
  521. + quickly.  You can split the Calculator into still more parts using the
  522. + `calc-split' command.  This command splits the file `calc-ext.el' into
  523. + about 20 small files with names like `calc-cplx.el' and `calc-mode.el'
  524. + in the same directory as `calc-ext.el'.  First, load the file
  525. + `calc-ext.el' with `C-x C-f'.  Move to the end of the buffer and type
  526. + `C-x C-e' at the indicated position.  Now type `M-x calc-split'.  This
  527. + moves most of the text out of `calc-ext.el' and into other files.  All
  528. + necessary `autoload' commands are inserted into `calc-ext.el'.
  529. + The `calc-split' command prompts for a directory name; the new files are
  530. + placed in this directory, and the `autoload' commands are written to
  531. + refer to the directory explicitly.  If you wish you can backspace over
  532. + the default directory name and enter a blank name, in which case the
  533. + `autoload' commands will be written without directory names on the
  534. + assumption that Emacs can find the Calc files in one of the default
  535. + places.  Some people prefer to put the Calc files in a subdirectory by
  536. + themselves.
  537. + The `calc-split' command also offers to byte-compile all Calc files
  538. + automatically.  Note that `calc.el' must have been byte-compiled and
  539. + loaded already, just as if you were compiling `calc-ext' whole.  If you
  540. + choose to compile by hand, you will need to compile `calc.el' first,
  541. + load it, compile the new `calc-ext.el' and load it, then compile each of
  542. + the new component files.  Also, note that the `autoload' commands shown
  543. + above are still correct for use in your startup file.
  544. + If you do decide to use `calc-split', note that when patches are made
  545. + available for new versions of Calc, they will refer to the old, unsplit
  546. + version of the file `calc-ext.el'.  The `calc-split' command makes a
  547. + copy of this under the name `calc-old.el'; be sure to keep it around so
  548. + you can rename it back to `calc-ext.el' before installing new patches.
  549. + You can then use `calc-split' again to re-split your updated version of
  550. + Calc.
  551. + Key Bindings
  552. + ============
  553. + You may wish to bind the `calc' command to a key.  The
  554. + recommended keystroke is `M-#' (i.e., Meta-Shift-3).  To set up
  555. + this key binding, include this command in your `.emacs' or
  556. + `lisp/default' file:
  557. +      (global-set-key "\e#" 'calc)
  558. + There are no standard key assignments for `quick-calc' and
  559. + `calc-grab-region', but you may wish to define some.
  560. + The `macedit' Package
  561. + =====================
  562. + The file `macedit.el' contains another useful Emacs extension
  563. + called `edit-kbd-macro'.  It allows you to edit a keyboard macro
  564. + in human-readable form.  The `Z E' command in Calc knows how to
  565. + use it to edit user commands that have been defined by keyboard macros.
  566. + To autoload it, you will want to include the commands,
  567. +      (autoload 'edit-kbd-macro      ".../macedit.elc" "Edit Keyboard Macro" t nil)
  568. +      (autoload 'edit-last-kbd-macro ".../macedit.elc" "Edit Keyboard Macro" t nil)
  569. + Documentation
  570. + =============
  571. + The documentation for Calc (i.e., this manual) comes in a file
  572. + `calc.texinfo'.  To format this for use as an on-line manual,
  573. + open this file for editing in Emacs and give the command
  574. + `M-x texinfo-format-buffer'.  When this finishes, type `C-x C-s'
  575. + to save.  The result will be a collection of files whose names begin
  576. + with `calc-info'.  You can also format this into a printable
  577. + document using TeX, but beware, the manual is about 170 printed pages!
  578. + There is a Lisp variable called `calc-info-filename' which holds
  579. + the name of the Info file containing Calc's on-line documentation.
  580. + Its default value is `calc-info', which will work correctly if
  581. + the Info files are stored in Emacs' main `info/' directory.  If
  582. + you keep them elsewhere, you will want to put a command of the form,
  583. +      (setq calc-info-filename ".../calc-info")
  584. + in your `.emacs' or `lisp/default' file, where again `...'
  585. + represents the directory containing the Info files.
  586. + Settings File
  587. + =============
  588. + Another variable you might want to set is `calc-settings-file', which
  589. + holds the file name in which commands like `m m' and `Z P' store
  590. + "permanent" definitions.  The default value for this variable is
  591. + `"~/.emacs"'.  If `calc-settings-file' does not contain `".emacs"' as a
  592. + substring, and if the variable `calc-loaded-settings-file' is `nil',
  593. + then Calc will automatically load your settings file (if it exists) the
  594. + first time Calc is invoked.
  595. + Testing the Installation
  596. + ========================
  597. + To test your installation of Calc, start a fresh Emacs and type `M-#'
  598. + to make sure the autoload commands and key bindings work.  Now, type
  599. + `i' to make sure Calc can find its Info documentation.  Press `q'
  600. + to exit the Info system and `M-#' to re-enter the Calculator.
  601. + Type `20 S' to compute the sine of 20 degrees; this will test the
  602. + autoloading of the extensions module.  The result should be 0.342020143326.
  603. + Finally, press `M-#' again to make sure the Calculator can exit.
  604. + (The above text is included in both the Calc documentation and the
  605. + file INSTALL in the Calc distribution directory.)
  606. *** calc.texinfo    Tue Jun 26 20:53:34 1990
  607. --- ../dist/calc.texinfo    Mon Aug  6 15:03:10 1990
  608. ***************
  609. *** 1,7 ****
  610.   \input texinfo                  @c -*-texinfo-*-
  611.   @comment %**start of header (This is for running Texinfo on a region.)
  612.   @setfilename calc-info
  613. ! @settitle GNU Emacs Calc 1.03 Manual
  614.   @setchapternewpage odd
  615.   @comment %**end of header (This is for running Texinfo on a region.)
  616.   
  617. --- 1,7 ----
  618.   \input texinfo                  @c -*-texinfo-*-
  619.   @comment %**start of header (This is for running Texinfo on a region.)
  620.   @setfilename calc-info
  621. ! @settitle GNU Emacs Calc 1.04 Manual
  622.   @setchapternewpage odd
  623.   @comment %**end of header (This is for running Texinfo on a region.)
  624.   
  625. ***************
  626. *** 38,46 ****
  627.   @sp 6
  628.   @center @titlefont{Calc Manual}
  629.   @sp 4
  630. ! @center GNU Emacs Calc Version 1.03
  631.   @sp 1
  632. ! @center June 1990
  633.   @sp 5
  634.   @center Dave Gillespie
  635.   @page
  636. --- 38,46 ----
  637.   @sp 6
  638.   @center @titlefont{Calc Manual}
  639.   @sp 4
  640. ! @center GNU Emacs Calc Version 1.04
  641.   @sp 1
  642. ! @center July 1990
  643.   @sp 5
  644.   @center Dave Gillespie
  645.   @page
  646. ***************
  647. *** 512,518 ****
  648.   Type @kbd{M-x calc} or @kbd{M-#} to start the Calculator; type @kbd{q} to quit.
  649.   Type @kbd{M-x quick-calc} to do one quick calculation in the minibuffer.
  650.   
  651. ! Calc normally uses RPN notation.  @xref{Stack Basics}, for a discussion
  652.   of RPN for the beginner.  The @kbd{RET} or @kbd{SPC} key enters a number
  653.   or duplicates the top number on the stack, @kbd{DEL} removes the top
  654.   number from the stack, and @kbd{TAB} swaps the top two numbers.@refill
  655. --- 512,518 ----
  656.   Type @kbd{M-x calc} or @kbd{M-#} to start the Calculator; type @kbd{q} to quit.
  657.   Type @kbd{M-x quick-calc} to do one quick calculation in the minibuffer.
  658.   
  659. ! Calc normally uses RPN notation.  @xref{RPN Tutorial}, for a discussion
  660.   of RPN for the beginner.  The @kbd{RET} or @kbd{SPC} key enters a number
  661.   or duplicates the top number on the stack, @kbd{DEL} removes the top
  662.   number from the stack, and @kbd{TAB} swaps the top two numbers.@refill
  663. ***************
  664. *** 714,725 ****
  665.   number of operands from the stack and pushes back the result.
  666.   
  667.   Thus we could add the numbers 2 and 3 in an RPN calculator by typing the
  668. ! keys: @kbd{1 @key{RET} 2 @key{RET} +}.  (@key{RET} corresponds to the
  669.   @key{ENTER} key on traditional RPN calculators.)  The first four
  670.   keystrokes ``push'' the numbers 2 and 3 onto the stack.  The @kbd{+} key
  671.   ``pops'' the top two numbers from the stack, adds them, and pushes the
  672.   result (5) back onto the stack.  Here's how the stack will look at
  673. ! various points throughout the calculation:
  674.   
  675.   @group
  676.   @example
  677. --- 714,725 ----
  678.   number of operands from the stack and pushes back the result.
  679.   
  680.   Thus we could add the numbers 2 and 3 in an RPN calculator by typing the
  681. ! keys: @kbd{2 @key{RET} 3 @key{RET} +}.  (@key{RET} corresponds to the
  682.   @key{ENTER} key on traditional RPN calculators.)  The first four
  683.   keystrokes ``push'' the numbers 2 and 3 onto the stack.  The @kbd{+} key
  684.   ``pops'' the top two numbers from the stack, adds them, and pushes the
  685.   result (5) back onto the stack.  Here's how the stack will look at
  686. ! various points throughout the calculation:@refill
  687.   
  688.   @group
  689.   @example
  690. ***************
  691. *** 742,748 ****
  692.   as large as you like, so it uses numbers instead of letters.  Some
  693.   stack-manipulation commands accept a numeric argument which says
  694.   which stack level to work on.  Normal commands like @kbd{+} always
  695. ! work on the top few levels of the stack.
  696.   
  697.   The Stack buffer is just an Emacs buffer, and you can move around in
  698.   it using the regular Emacs motion commands.  But no matter where the
  699. --- 742,748 ----
  700.   as large as you like, so it uses numbers instead of letters.  Some
  701.   stack-manipulation commands accept a numeric argument which says
  702.   which stack level to work on.  Normal commands like @kbd{+} always
  703. ! work on the top few levels of the stack.@refill
  704.   
  705.   The Stack buffer is just an Emacs buffer, and you can move around in
  706.   it using the regular Emacs motion commands.  But no matter where the
  707. ***************
  708. *** 932,938 ****
  709.   
  710.   @group
  711.   @example
  712. ! 1:  ( ...      2:  ( ...      1:  ( 2, ...   1:  ( 2, ...   1:  (2, 3)
  713.       .          1:  2              .              3              .
  714.                                                    .
  715.   
  716. --- 932,938 ----
  717.   
  718.   @group
  719.   @example
  720. ! 1:  ( ...      2:  ( ...      1:  (2, ...    1:  (2, ...    1:  (2, 3)
  721.       .          1:  2              .              3              .
  722.                                                    .
  723.   
  724. ***************
  725. *** 1217,1223 ****
  726.   calls are not evaluated.  In the second call, the logarithm is
  727.   undefined for that value of the argument; in the third, there are
  728.   too many arguments.  In the fourth case, there is no function
  729. ! called @code{foo}.
  730.   
  731.   We will encounter formulas involving variables and functions again
  732.   when we discuss the algebra and calculus features of the Calculator.
  733. --- 1217,1226 ----
  734.   calls are not evaluated.  In the second call, the logarithm is
  735.   undefined for that value of the argument; in the third, there are
  736.   too many arguments.  In the fourth case, there is no function
  737. ! called @code{foo}.  You can press the @kbd{w} key (``why'') to
  738. ! see an explanation of why a function call was left unevaluated.
  739. ! Pressing @kbd{w} the first time will report the too-many-arguments
  740. ! problem; pressing it again will report the logarithm-of-zero problem.
  741.   
  742.   We will encounter formulas involving variables and functions again
  743.   when we discuss the algebra and calculus features of the Calculator.
  744. ***************
  745. *** 1393,1399 ****
  746.   Calc has to stop somewhere.
  747.   
  748.   Of course, calculations are slower the more digits you request.
  749. ! Press @kbd{p 12} to set the precision back down to the default.
  750.   
  751.   Calculations always use the current precision.  For example, even
  752.   though we have a 30-digit value for @samp{1/7} on the stack, if
  753. --- 1396,1402 ----
  754.   Calc has to stop somewhere.
  755.   
  756.   Of course, calculations are slower the more digits you request.
  757. ! Press @kbd{p 12} now to set the precision back down to the default.
  758.   
  759.   Calculations always use the current precision.  For example, even
  760.   though we have a 30-digit value for @samp{1/7} on the stack, if
  761. ***************
  762. *** 1605,1611 ****
  763.   
  764.   You can enter non-decimal numbers using the @kbd{#} symbol, too.
  765.   Let's see what the hexadecimal number @samp{5FE} looks like in
  766. ! binary.  Type @kbd{16#5FE} (the F's can be in upper or lower case).
  767.   It will also help to turn grouping on with @kbd{d g}:
  768.   
  769.   @example
  770. --- 1608,1614 ----
  771.   
  772.   You can enter non-decimal numbers using the @kbd{#} symbol, too.
  773.   Let's see what the hexadecimal number @samp{5FE} looks like in
  774. ! binary.  Type @kbd{16#5FE} (the letters can be in upper or lower case).
  775.   It will also help to turn grouping on with @kbd{d g}:
  776.   
  777.   @example
  778. ***************
  779. *** 1649,1655 ****
  780.   The shift-@kbd{S} command computes the sine of an angle.  The sine
  781.   of 45 degrees is @samp{sqrt(2)/2}; squaring this yields @samp{2/4 = 0.5}.
  782.   However, there has been a slight roundoff error because the
  783. ! resentation of @samp{sqrt(2)/2} wasn't exact.  The @kbd{c 1}
  784.   command is a handy way to clean up numbers in this case; it
  785.   temporarily reduces the precision by one digit while it
  786.   re-rounds the number on the top of the stack.
  787. --- 1652,1658 ----
  788.   The shift-@kbd{S} command computes the sine of an angle.  The sine
  789.   of 45 degrees is @samp{sqrt(2)/2}; squaring this yields @samp{2/4 = 0.5}.
  790.   However, there has been a slight roundoff error because the
  791. ! representation of @samp{sqrt(2)/2} wasn't exact.  The @kbd{c 1}
  792.   command is a handy way to clean up numbers in this case; it
  793.   temporarily reduces the precision by one digit while it
  794.   re-rounds the number on the top of the stack.
  795. ***************
  796. *** 1713,1719 ****
  797.   @end group
  798.   
  799.   In the first case, we get an approximate floating-point result.
  800. ! In the second case, we get an exact fractional result.
  801.   
  802.   You can enter a fraction at any time using @kbd{:} notation.
  803.   (Calc uses @kbd{:} instead of @kbd{/} as the fraction separator
  804. --- 1716,1723 ----
  805.   @end group
  806.   
  807.   In the first case, we get an approximate floating-point result.
  808. ! In the second case, we get an exact fractional result
  809. ! (four-thirds).
  810.   
  811.   You can enter a fraction at any time using @kbd{:} notation.
  812.   (Calc uses @kbd{:} instead of @kbd{/} as the fraction separator
  813. ***************
  814. *** 1794,1804 ****
  815.   @end example
  816.   @end group
  817.   
  818. ! Since dividing-and-flooring is such a common operation, Calc
  819. ! provides a special command for that purpose, the backslash @kbd{\}.
  820. ! Another common arithmetic operator is @kbd{%}, which computes the
  821. ! remainder that would arise from a @kbd{\} operation, i.e., the
  822. ! ``modulo'' of two numbers.  For example,
  823.   
  824.   @group
  825.   @example
  826. --- 1798,1808 ----
  827.   @end example
  828.   @end group
  829.   
  830. ! Since dividing-and-flooring (i.e., ``integer quotient'') is such a
  831. ! common operation, Calc provides a special command for that purpose, the
  832. ! backslash @kbd{\}.  Another common arithmetic operator is @kbd{%}, which
  833. ! computes the remainder that would arise from a @kbd{\} operation, i.e.,
  834. ! the ``modulo'' of two numbers.  For example,
  835.   
  836.   @group
  837.   @example
  838. ***************
  839. *** 2079,2085 ****
  840.   
  841.   Note that we can separate the vector elements with either commas or
  842.   spaces.  This is true whether we are using incomplete vectors or
  843. ! algebraic entry.
  844.   
  845.   If you multiply two vectors, the result is the sum of the products
  846.   of the elements taken pairwise.  This is called the @dfn{dot product}
  847. --- 2083,2090 ----
  848.   
  849.   Note that we can separate the vector elements with either commas or
  850.   spaces.  This is true whether we are using incomplete vectors or
  851. ! algebraic entry.  The @kbd{s 1} and @kbd{s 2} commands save these
  852. ! vectors so we can easily reuse them later.
  853.   
  854.   If you multiply two vectors, the result is the sum of the products
  855.   of the elements taken pairwise.  This is called the @dfn{dot product}
  856. ***************
  857. *** 2335,2341 ****
  858.   @end example
  859.   @end group
  860.   
  861. ! Dividing by a square matrix is equivalent to multiplying by the
  862.   inverse.
  863.   
  864.   Let's verify this solution:
  865. --- 2340,2346 ----
  866.   @end example
  867.   @end group
  868.   
  869. ! Dividing by a square matrix is equivalent to multiplying by its
  870.   inverse.
  871.   
  872.   Let's verify this solution:
  873. ***************
  874. *** 2369,2376 ****
  875.   @end example
  876.   @end group
  877.   
  878. ! You can also build vectors out of consecutive integers, or many
  879. ! copies of a given value:
  880.   
  881.   @group
  882.   @example
  883. --- 2374,2381 ----
  884.   @end example
  885.   @end group
  886.   
  887. ! You can also build vectors out of consecutive integers, or out
  888. ! of many copies of a given value:
  889.   
  890.   @group
  891.   @example
  892. ***************
  893. *** 2767,2777 ****
  894.   
  895.   @group
  896.   @example
  897. ! 1:  8 +/- 0.2    2:  8 +/- 0.2    1:  0.266 +/- 0.011   1:  14.93 +/- 0.594
  898. !     .            1:  30 +/- 1         .                     .
  899.                        .
  900.   
  901. !     8 p .2           30 p 1           /                     I T
  902.   @end example
  903.   @end group
  904.   
  905. --- 2772,2782 ----
  906.   
  907.   @group
  908.   @example
  909. ! 1:  8 +/- 0.2    2:  8 +/- 0.2   1:  0.266 +/- 0.011   1:  14.93 +/- 0.594
  910. !     .            1:  30 +/- 1        .                     .
  911.                        .
  912.   
  913. !     8 p .2           30 p 1          /                     I T
  914.   @end example
  915.   @end group
  916.   
  917. ***************
  918. *** 3177,3183 ****
  919.   1:  [1, 2, ... ]    1:  [10, 11, ... ]    1:  [1, 1.1, ... ]
  920.       .                   .                     .
  921.   
  922. !     v x 10 RET          9 +                   10 /
  923.   @end example
  924.   @end group
  925.   
  926. --- 3182,3188 ----
  927.   1:  [1, 2, ... ]    1:  [10, 11, ... ]    1:  [1, 1.1, ... ]
  928.       .                   .                     .
  929.   
  930. !     v x 10 RET          9 +                   0.1 *
  931.   @end example
  932.   @end group
  933.   
  934. ***************
  935. *** 3461,3467 ****
  936.   
  937.   @group
  938.   @example
  939. ! 3:  []             1:  [0.10132, 0.03079, 0.02340, 0.33197, ...]
  940.   2:  2                  .
  941.   1:  30
  942.       .
  943. --- 3466,3472 ----
  944.   
  945.   @group
  946.   @example
  947. ! 3:  []             1:  [0.10132, 0.03079, 0.02340, 0.033197, ...]
  948.   2:  2                  .
  949.   1:  30
  950.       .
  951. ***************
  952. *** 3508,3514 ****
  953.   Let's edit in a new definition, for computing harmonic numbers.
  954.   First, erase the three lines of the old definition.  Then, type
  955.   in the new definition (or use Emacs @kbd{M-w} and @kbd{C-y} commands
  956. ! to copy it from the Info file).
  957.   
  958.   @example
  959.   calc-kbd-push         # Save local values (Z `)
  960. --- 3513,3519 ----
  961.   Let's edit in a new definition, for computing harmonic numbers.
  962.   First, erase the three lines of the old definition.  Then, type
  963.   in the new definition (or use Emacs @kbd{M-w} and @kbd{C-y} commands
  964. ! to copy it from this page of the Info file).
  965.   
  966.   @example
  967.   calc-kbd-push         # Save local values (Z `)
  968. ***************
  969. *** 4288,4297 ****
  970.   An @dfn{interval} is a subset of consecutive real numbers.  For example,
  971.   the interval @samp{[2 .. 4]} represents all the numbers from 2 to 4,
  972.   inclusive.  If you multiply it by the interval @samp{[0.5 .. 2]} you
  973. ! obtain @samp{[1 .. 6]}.  This calculation represents the fact that if
  974.   you multiply some number in the range @samp{[2 .. 4]} by some other
  975.   number in the range @samp{[0.5 .. 2]}, your result will lie in the range
  976. ! from 1 to 6.  Interval arithmetic is used to get a worst-case estimate
  977.   of the possible range of values a computation will produce, given the
  978.   set of possible values of the input.
  979.   
  980. --- 4293,4302 ----
  981.   An @dfn{interval} is a subset of consecutive real numbers.  For example,
  982.   the interval @samp{[2 .. 4]} represents all the numbers from 2 to 4,
  983.   inclusive.  If you multiply it by the interval @samp{[0.5 .. 2]} you
  984. ! obtain @samp{[1 .. 8]}.  This calculation represents the fact that if
  985.   you multiply some number in the range @samp{[2 .. 4]} by some other
  986.   number in the range @samp{[0.5 .. 2]}, your result will lie in the range
  987. ! from 1 to 8.  Interval arithmetic is used to get a worst-case estimate
  988.   of the possible range of values a computation will produce, given the
  989.   set of possible values of the input.
  990.   
  991. ***************
  992. *** 5693,5699 ****
  993.   The @kbd{\} (@code{calc-idiv}) command divides two numbers on the stack
  994.   to produce an integer result.  It is equivalent to dividing with
  995.   @key{/}, then rounding down with @kbd{F} (@code{calc-floor}), only a bit
  996. ! more convenient and efficient.
  997.   
  998.   @kindex :
  999.   @pindex calc-fdiv
  1000. --- 5698,5706 ----
  1001.   The @kbd{\} (@code{calc-idiv}) command divides two numbers on the stack
  1002.   to produce an integer result.  It is equivalent to dividing with
  1003.   @key{/}, then rounding down with @kbd{F} (@code{calc-floor}), only a bit
  1004. ! more convenient and efficient.  Also, since it is an all-integer
  1005. ! operation when the arguments are integers, it avoids problems that
  1006. ! @kbd{/ F} would have with floating-point roundoff.
  1007.   
  1008.   @kindex :
  1009.   @pindex calc-fdiv
  1010. ***************
  1011. *** 5730,5736 ****
  1012.   The @code{calc-abssqr} [@code{abssqr}] command computes the absolute
  1013.   value squared of a number, vector or matrix, or error form.
  1014.   
  1015. - @pindex calc-sign
  1016.   @tindex sign
  1017.   The @code{sign} algebraic function returns 1 if its argument is positive,
  1018.   -1 if its argument is negative, or 0 if its argument is zero.
  1019. --- 5737,5742 ----
  1020. ***************
  1021. *** 5766,5771 ****
  1022. --- 5772,5801 ----
  1023.   take any number of arguments and return the maximum or minimum among all
  1024.   the arguments.)@refill
  1025.   
  1026. + @pindex calc-mant-part
  1027. + @tindex mant
  1028. + @pindex calc-xpon-part
  1029. + @tindex xpon
  1030. + The @code{calc-mant-part} [@code{mant}] function extracts the ``mantissa''
  1031. + part @var{m} of its floating-point argument; @code{calc-xpon-part}
  1032. + [@code{xpon}] extracts the ``exponent'' part @var{e}.  The original
  1033. + number is equal to @samp{@var{m} * 10^@var{e}}, where @var{m} is in
  1034. + the interval @samp{[1.0 .. 10.0)} except that @samp{@var{m}=@var{e}=0}
  1035. + if the original number is zero.  For integers and fractions,
  1036. + @code{mant} returns the number unchanged and @code{xpon} returns zero.
  1037. + The @kbd{v u} (@code{calc-unpack}) command can also be used to ``unpack''
  1038. + a floating-point number; this produces an integer mantissa and exponent,
  1039. + with the constraint that the mantissa is either zero or a non-multiple
  1040. + of ten.@refill
  1041. + @pindex calc-scale-float
  1042. + @tindex scf
  1043. + The @code{calc-scale-float} [@code{scf}] function scales a number by
  1044. + a given power of ten.  Thus, @samp{scf(mant(x), xpon(x)) = x} for any
  1045. + real @var{x}.  The second argument must be an integer, but the first
  1046. + may actually be any numeric value.  For example, @samp{scf(5,-2) = 0.05}
  1047. + or @samp{1:20} depending on the current Fraction Mode.@refill
  1048.   @node Integer Truncation, Complex Number Functions, Basic Arithmetic, Arithmetic
  1049.   @section Integer Truncation
  1050.   
  1051. ***************
  1052. *** 6491,6512 ****
  1053.   number right by one bit, or by the number of bits specified in the numeric
  1054.   prefix argument:  @samp{rsh(a,n) = lsh(a,-n)}.
  1055.   
  1056. ! @kindex b s
  1057. ! @pindex calc-shift-binary
  1058.   @tindex ash
  1059. ! The @kbd{b s} (@code{calc-shift-binary}) [@code{ash}] command shifts a
  1060. ! number left in the same way as @code{lsh}.  However, if shifting right,
  1061. ! it performs an ``arithmetic'' shift, in which the leftmost bit (according
  1062. ! to the current word size) is duplicated rather than shifting in zeros.
  1063. ! This corresponds to dividing by two where the input is interpreted as a
  1064. ! signed, twos-complement number.  (The distinction between the @samp{lsh}
  1065. ! and @samp{ash} operations is totally independent from whether the word
  1066. ! size is positive or negative.)
  1067.   
  1068.   @kindex b R
  1069.   @pindex calc-rotate-binary
  1070.   @tindex rot
  1071. ! The @kbd{b R} (@code{calc-rotate-binary}) [@code{rot}] command rotates a
  1072.   number one bit to the left.  The leftmost bit (according to the current
  1073.   word size) is dropped off the left and shifted in on the right.  With a
  1074.   numeric prefix argument, the number is rotated the specified number of
  1075. --- 6521,6550 ----
  1076.   number right by one bit, or by the number of bits specified in the numeric
  1077.   prefix argument:  @samp{rsh(a,n) = lsh(a,-n)}.
  1078.   
  1079. ! @kindex b L
  1080. ! @pindex calc-lshift-arith
  1081.   @tindex ash
  1082. ! The @kbd{b L} (@code{calc-lshift-arith}) [@code{ash}] command shifts a
  1083. ! number left.  It is analogous to @code{lsh}, except that if the shift
  1084. ! is rightward (the prefix argument is negative), an arithmetic shift
  1085. ! is performed as described below.
  1086.   
  1087.   @kindex b R
  1088. + @pindex calc-rshift-arith
  1089. + @tindex rash
  1090. + The @kbd{b R} (@code{calc-rshift-arith}) [@code{rash}] command performs
  1091. + an ``arithmetic'' shift to the right, in which the leftmost bit (according
  1092. + to the current word size) is duplicated rather than shifting in zeros.
  1093. + This corresponds to dividing by a power of two where the input is interpreted
  1094. + as a signed, twos-complement number.  (The distinction between the @samp{rsh}
  1095. + and @samp{rash} operations is totally independent from whether the word
  1096. + size is positive or negative.)  With a negative prefix argument, this
  1097. + performs a standard left shift.
  1098. + @kindex b t
  1099.   @pindex calc-rotate-binary
  1100.   @tindex rot
  1101. ! The @kbd{b t} (@code{calc-rotate-binary}) [@code{rot}] command rotates a
  1102.   number one bit to the left.  The leftmost bit (according to the current
  1103.   word size) is dropped off the left and shifted in on the right.  With a
  1104.   numeric prefix argument, the number is rotated the specified number of
  1105. ***************
  1106. *** 7195,7206 ****
  1107.   
  1108.   The @code{calc-substitute} command normally prompts for two formulas,
  1109.   the old one and the new one.  If you enter a blank line for the first
  1110. ! prompt, all three arguments are taken from the stack (old, then new,
  1111.   then target expression).  If you type an old formula but then enter a
  1112.   blank line for the new one, the new formula is taken from top-of-stack
  1113.   and the target from second-to-top.  If you answer both prompts, the
  1114.   target is taken from top-of-stack as usual.
  1115.   
  1116.   @node Rewrite Rules, Logical Operations, Algebraic Manipulation, Algebra
  1117.   @section Rewrite Rules
  1118.   
  1119. --- 7233,7252 ----
  1120.   
  1121.   The @code{calc-substitute} command normally prompts for two formulas,
  1122.   the old one and the new one.  If you enter a blank line for the first
  1123. ! prompt, all three arguments are taken from the stack (new, then old,
  1124.   then target expression).  If you type an old formula but then enter a
  1125.   blank line for the new one, the new formula is taken from top-of-stack
  1126.   and the target from second-to-top.  If you answer both prompts, the
  1127.   target is taken from top-of-stack as usual.
  1128.   
  1129. + Note that @code{calc-substitute} has no understanding of commutativity
  1130. + or associativity.  The pattern @samp{x+y} will not match the formula
  1131. + @samp{y+x}.  Also, @samp{y+z} will not match inside the formula @samp{x+y+z}
  1132. + because the @samp{+} operator is left-associative, so the ``deep
  1133. + structure'' of that formula is @samp{(x+y) + z}.  Use @kbd{d U}
  1134. + (@code{calc-unformatted-language}) mode to see the true structure of
  1135. + a formula.
  1136.   @node Rewrite Rules, Logical Operations, Algebraic Manipulation, Algebra
  1137.   @section Rewrite Rules
  1138.   
  1139. ***************
  1140. *** 7254,7260 ****
  1141.   Pattern-matching is completely structural, not taking the algebraic
  1142.   properties of formulas into account.  Thus @samp{f(x+1)} matches
  1143.   the formula @samp{f(a+1)} but not @samp{f(a)}, @samp{f(a+2)}, or
  1144. ! @samp{f(1+a)}.@refill
  1145.   
  1146.   If the @samp{old} pattern is found to match a given formula, that
  1147.   formula is replaced by @samp{new}, where any occurrences in @samp{new}
  1148. --- 7300,7307 ----
  1149.   Pattern-matching is completely structural, not taking the algebraic
  1150.   properties of formulas into account.  Thus @samp{f(x+1)} matches
  1151.   the formula @samp{f(a+1)} but not @samp{f(a)}, @samp{f(a+2)}, or
  1152. ! @samp{f(1+a)}.  For other examples @pxref{Algebraic Manipulation},
  1153. ! under the discussion of @code{calc-substitute}.@refill
  1154.   
  1155.   If the @samp{old} pattern is found to match a given formula, that
  1156.   formula is replaced by @samp{new}, where any occurrences in @samp{new}
  1157. ***************
  1158. *** 8771,8777 ****
  1159.   @example
  1160.   (defmath myfact (n)
  1161.     (if (> n 0)
  1162. !       (* (myfact (1- n)))
  1163.       (if (= n 0)
  1164.           1
  1165.         nil)))    ; this could be simplified as: (and (= n 0) 1)
  1166. --- 8818,8824 ----
  1167.   @example
  1168.   (defmath myfact (n)
  1169.     (if (> n 0)
  1170. !       (* n (myfact (1- n)))
  1171.       (if (= n 0)
  1172.           1
  1173.         nil)))    ; this could be simplified as: (and (= n 0) 1)
  1174. ***************
  1175. *** 9023,9029 ****
  1176.     "Compute the factorial of the integer at the top of the stack."
  1177.     (interactive 1 "fact")
  1178.     (if (> n 0)
  1179. !       (* (myfact (1- n)))
  1180.       (and (= n 0) 1)))
  1181.   @end example
  1182.   
  1183. --- 9070,9076 ----
  1184.     "Compute the factorial of the integer at the top of the stack."
  1185.     (interactive 1 "fact")
  1186.     (if (> n 0)
  1187. !       (* n (myfact (1- n)))
  1188.       (and (= n 0) 1)))
  1189.   @end example
  1190.   
  1191. ***************
  1192. *** 10900,10906 ****
  1193.   @node Installation, Reporting Bugs, Programming, Top
  1194.   @chapter Installation
  1195.   
  1196. ! Calc comes as a pair of Emacs Lisp files, generally called
  1197.   @file{calc.el} and @file{calc-ext.el}.  The first contains the basic
  1198.   foundations of the Calculator, and is as small as possible to promote
  1199.   quick loading.  The second contains all the more advanced commands and
  1200. --- 10947,10953 ----
  1201.   @node Installation, Reporting Bugs, Programming, Top
  1202.   @chapter Installation
  1203.   
  1204. ! Calc 1.04 comes as a pair of Emacs Lisp files, generally called
  1205.   @file{calc.el} and @file{calc-ext.el}.  The first contains the basic
  1206.   foundations of the Calculator, and is as small as possible to promote
  1207.   quick loading.  The second contains all the more advanced commands and
  1208. ***************
  1209. *** 10908,10913 ****
  1210. --- 10955,10962 ----
  1211.   @kbd{M-#} command auto-loads only the first part, and the second part is
  1212.   auto-loaded whenever the first advanced feature is used.@refill
  1213.   
  1214. + @section Compilation
  1215.   Calc is written in a way that maximizes performance when its code has been
  1216.   byte-compiled; a side effect is that performance is seriously degraded if
  1217.   it @emph{isn't} compiled.  Thus, it is essential to compile the Calculator
  1218. ***************
  1219. *** 10918,10926 ****
  1220.   calc.elc} before compiling @file{calc-ext.el} will work.
  1221.   
  1222.   For your convenience, the FTP distribution of Calc, obtainable from
  1223. ! anonymous FTP on @samp{csvax.caltech.edu}, includes already-compiled
  1224.   versions of both of these files.
  1225.   
  1226.   To teach Emacs how to load in Calc when you type @kbd{M-x calc} for the
  1227.   first time, include these lines in your @file{.emacs} file (if you are
  1228.   installing Calc just for your own use), or the system's @file{lisp/default}
  1229. --- 10967,10977 ----
  1230.   calc.elc} before compiling @file{calc-ext.el} will work.
  1231.   
  1232.   For your convenience, the FTP distribution of Calc, obtainable from
  1233. ! anonymous FTP on @samp{csvax.cs.caltech.edu}, includes already-compiled
  1234.   versions of both of these files.
  1235.   
  1236. + @section Auto-loading
  1237.   To teach Emacs how to load in Calc when you type @kbd{M-x calc} for the
  1238.   first time, include these lines in your @file{.emacs} file (if you are
  1239.   installing Calc just for your own use), or the system's @file{lisp/default}
  1240. ***************
  1241. *** 10950,10962 ****
  1242.   reasonably be used before the user has typed @kbd{M-x calc} for the
  1243.   first time.
  1244.   
  1245.   If you don't want to bother with a split Calculator, you can simply
  1246.   concatenate @code{calc-ext.elc} onto the end of @code{calc.elc}, rewrite
  1247.   the above @code{autoload} commands all to point to the combined file,
  1248.   and treat Calc as one big program.  You may need to do this if
  1249. ! @code{autoload} is giving you problems.
  1250.   
  1251. ! You may also wish to bind the @code{calc} command to a key.  The
  1252.   recommended keystroke is @kbd{M-#} (i.e., Meta-Shift-3).  To set up
  1253.   this key binding, include this command in your @file{.emacs} or
  1254.   @file{lisp/default} file:
  1255. --- 11001,11058 ----
  1256.   reasonably be used before the user has typed @kbd{M-x calc} for the
  1257.   first time.
  1258.   
  1259. + @section Merging @file{calc} and @file{calc-ext}
  1260.   If you don't want to bother with a split Calculator, you can simply
  1261.   concatenate @code{calc-ext.elc} onto the end of @code{calc.elc}, rewrite
  1262.   the above @code{autoload} commands all to point to the combined file,
  1263.   and treat Calc as one big program.  You may need to do this if
  1264. ! the @code{autoload} mechanism is giving you problems.
  1265. ! @section Splitting @file{calc-ext}
  1266. ! On the other hand, you may find that @file{calc-ext.el} is too big to load
  1267. ! quickly.  You can split the Calculator into still more parts using the
  1268. ! @code{calc-split} command.  This command splits the file
  1269. ! @file{calc-ext.el} into about 20 small files with names like
  1270. ! @file{calc-cplx.el} and @file{calc-mode.el} in the same directory
  1271. ! as @file{calc-ext.el}.  First, load the file @file{calc-ext.el} with
  1272. ! @kbd{C-x C-f}.  Move to the end of the buffer and type @kbd{C-x C-e}
  1273. ! at the indicated position.  Now type @kbd{M-x calc-split}.
  1274. ! This moves most of the text out of @file{calc-ext.el} and into
  1275. ! other files.  All necessary @code{autoload} commands are inserted
  1276. ! into @file{calc-ext.el}.@refill
  1277. ! The @code{calc-split} command prompts for a directory name; the new
  1278. ! files are placed in this directory, and the @code{autoload} commands are
  1279. ! written to refer to the directory explicitly.  If you wish you can
  1280. ! backspace over the default directory name and enter a blank name, in
  1281. ! which case the @code{autoload} commands will be written without
  1282. ! directory names on the assumption that Emacs can find the Calc files in
  1283. ! one of the default places.  Some people prefer to put the Calc files in
  1284. ! a subdirectory by themselves.@refill
  1285. ! The @code{calc-split} command also offers to byte-compile all Calc files
  1286. ! automatically.  Note that @file{calc.el} must have been byte-compiled
  1287. ! and loaded already, just as if you were compiling @file{calc-ext} whole.
  1288. ! If you choose to compile by hand, you will need to compile @file{calc.el}
  1289. ! first, load it, compile the new @file{calc-ext.el} and load it, then
  1290. ! compile each of the new component files.  Also, note that the
  1291. ! @code{autoload} commands shown above are still correct for use in
  1292. ! your startup file.@refill
  1293. ! If you do decide to use @code{calc-split}, note that when patches
  1294. ! are made available for new versions of Calc, they will refer to
  1295. ! the old, unsplit version of the file @file{calc-ext.el}.  The
  1296. ! @code{calc-split} command makes a copy of this under the name
  1297. ! @file{calc-old.el}; be sure to keep it around so you can rename
  1298. ! it back to @file{calc-ext.el} before installing new patches.
  1299. ! You can then use @code{calc-split} again to re-split your updated
  1300. ! version of Calc.@refill
  1301. ! @section Key Bindings
  1302.   
  1303. ! You may wish to bind the @code{calc} command to a key.  The
  1304.   recommended keystroke is @kbd{M-#} (i.e., Meta-Shift-3).  To set up
  1305.   this key binding, include this command in your @file{.emacs} or
  1306.   @file{lisp/default} file:
  1307. ***************
  1308. *** 10968,10973 ****
  1309. --- 11064,11071 ----
  1310.   There are no standard key assignments for @code{quick-calc} and
  1311.   @code{calc-grab-region}, but you may wish to define some.
  1312.   
  1313. + @section The @file{macedit} Package
  1314.   The file @file{macedit.el} contains another useful Emacs extension
  1315.   called @code{edit-kbd-macro}.  It allows you to edit a keyboard macro
  1316.   in human-readable form.  The @kbd{Z E} command in Calc knows how to
  1317. ***************
  1318. *** 10979,10984 ****
  1319. --- 11077,11084 ----
  1320.   (autoload 'edit-last-kbd-macro ".../macedit.elc" "Edit Keyboard Macro" t nil)
  1321.   @end example
  1322.   
  1323. + @section Documentation
  1324.   The documentation for Calc (i.e., this manual) comes in a file
  1325.   @file{calc.texinfo}.  To format this for use as an on-line manual,
  1326.   open this file for editing in Emacs and give the command
  1327. ***************
  1328. *** 11002,11007 ****
  1329. --- 11102,11109 ----
  1330.   in your @file{.emacs} or @file{lisp/default} file, where again @file{...}
  1331.   represents the directory containing the Info files.
  1332.   
  1333. + @section Settings File
  1334.   @vindex calc-settings-file
  1335.   Another variable you might want to set is @code{calc-settings-file},
  1336.   which holds the file name in which commands like @kbd{m m} and @kbd{Z P}
  1337. ***************
  1338. *** 11012,11017 ****
  1339. --- 11114,11121 ----
  1340.   automatically load your settings file (if it exists) the first time
  1341.   Calc is invoked.@refill
  1342.   
  1343. + @section Testing the Installation
  1344.   To test your installation of Calc, start a fresh Emacs and type @kbd{M-#}
  1345.   to make sure the autoload commands and key bindings work.  Now, type
  1346.   @kbd{i} to make sure Calc can find its Info documentation.  Press @kbd{q}
  1347. ***************
  1348. *** 11027,11033 ****
  1349.   @chapter Reporting Bugs
  1350.   
  1351.   If you find a bug in Calc, send e-mail to Dave Gillespie,
  1352. ! @samp{daveg@@csvax.caltech.edu}.  While I cannot guarantee that I
  1353.   will have time to work on your bug, I do try to fix bugs quickly
  1354.   whenever I can.
  1355.   
  1356. --- 11131,11137 ----
  1357.   @chapter Reporting Bugs
  1358.   
  1359.   If you find a bug in Calc, send e-mail to Dave Gillespie,
  1360. ! @samp{daveg@@csvax.cs.caltech.edu}.  While I cannot guarantee that I
  1361.   will have time to work on your bug, I do try to fix bugs quickly
  1362.   whenever I can.
  1363.   
  1364.  
  1365.