Mercurial > emacs
annotate lisp/calc/calc.el @ 59061:a7985894de81
Comment change.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Tue, 21 Dec 2004 11:50:52 +0000 |
| parents | a26862f74305 |
| children | 30ee5fc56ad0 fb79180b618d |
| rev | line source |
|---|---|
|
41283
1c09d8ddd155
(toplevel): Add comment and version header.
Colin Walters <walters@gnu.org>
parents:
41270
diff
changeset
|
1 ;;; calc.el --- the GNU Emacs calculator |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
2 |
|
54583
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
4 |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
5 ;; Author: David Gillespie <daveg@synaptics.com> |
|
57118
5105863ead20
(calc-bug-address): Changed email address to send bug reports to.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57117
diff
changeset
|
6 ;; Maintainer: Jay Belanger <belanger@truman.edu> |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
7 ;; Keywords: convenience, extensions |
|
41283
1c09d8ddd155
(toplevel): Add comment and version header.
Colin Walters <walters@gnu.org>
parents:
41270
diff
changeset
|
8 ;; Version: 2.02g |
| 40785 | 9 |
| 10 ;; This file is part of GNU Emacs. | |
| 11 | |
| 12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 13 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
| 14 ;; accepts responsibility to anyone for the consequences of using it | |
| 15 ;; or for whether it serves any particular purpose or works at all, | |
| 16 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
| 17 ;; License for full details. | |
| 18 | |
| 19 ;; Everyone is granted permission to copy, modify and redistribute | |
| 20 ;; GNU Emacs, but only under the conditions described in the | |
| 21 ;; GNU Emacs General Public License. A copy of this license is | |
| 22 ;; supposed to have been given to you along with GNU Emacs so you | |
| 23 ;; can know your rights and responsibilities. It should be in a | |
| 24 ;; file named COPYING. Among other things, the copyright notice | |
| 25 ;; and this notice must be preserved on all copies. | |
| 26 | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
27 ;;; Commentary: |
| 40785 | 28 |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
29 ;; Calc is split into many files. This file is the main entry point. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
30 ;; This file includes autoload commands for various other basic Calc |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
31 ;; facilities. The more advanced features are based in calc-ext, which |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
32 ;; in turn contains autoloads for the rest of the Calc files. This |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
33 ;; odd set of interactions is designed to make Calc's loading time |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
34 ;; be as short as possible when only simple calculations are needed. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
35 |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
36 ;; Original author's address: |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
37 ;; Dave Gillespie, daveg@synaptics.com, uunet!synaptx!daveg. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
38 ;; Synaptics, Inc., 2698 Orchard Parkway, San Jose, CA 95134. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
39 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
40 ;; The old address daveg@csvax.cs.caltech.edu will continue to |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
41 ;; work for the foreseeable future. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
42 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
43 ;; Bug reports and suggestions are always welcome! (Type M-x |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
44 ;; report-calc-bug to send them). |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
45 |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
46 ;; All functions, macros, and Lisp variables defined here begin with one |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
47 ;; of the prefixes "math", "Math", or "calc", with the exceptions of |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
48 ;; "full-calc", "full-calc-keypad", "another-calc", "quick-calc", |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
49 ;; "report-calc-bug", and "defmath". User-accessible variables begin |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
50 ;; with "var-". |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
51 |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
52 ;;; TODO: |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
53 |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
54 ;; Fix rewrite mechanism to do less gratuitous rearrangement of terms. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
55 ;; Implement a pattern-based "refers" predicate. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
56 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
57 ;; Make it possible to Undo a selection command. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
58 ;; Figure out how to allow selecting rows of matrices. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
59 ;; If cursor was in selection before, move it after j n, j p, j L, etc. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
60 ;; Consider reimplementing calc-delete-selection using rewrites. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
61 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
62 ;; Implement line-breaking in non-flat compositions (is this desirable?). |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
63 ;; Implement matrix formatting with multi-line components. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
64 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
65 ;; Have "Z R" define a user command based on a set of rewrite rules. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
66 ;; Support "incf" and "decf" in defmath definitions. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
67 ;; Have defmath generate calls to calc-binary-op or calc-unary-op. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
68 ;; Make some way to define algebraic functions using keyboard macros. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
69 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
70 ;; Allow calc-word-size=0 => Common Lisp-style signed bitwise arithmetic. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
71 ;; Consider digamma function (and thus arb. prec. Euler's gamma constant). |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
72 ;; May as well make continued-fractions stuff available to the user. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
73 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
74 ;; How about matrix eigenvalues, SVD, pseudo-inverse, etc.? |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
75 ;; Should cache matrix inverses as well as decompositions. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
76 ;; If dividing by a non-square matrix, use least-squares automatically. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
77 ;; Consider supporting matrix exponentials. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
78 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
79 ;; Have ninteg detect and work around singularities at the endpoints. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
80 ;; Use an adaptive subdivision algorithm for ninteg. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
81 ;; Provide nsum and nprod to go along with ninteg. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
82 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
83 ;; Handle TeX-mode parsing of \matrix{ ... } where ... contains braces. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
84 ;; Support AmS-TeX's \{d,t,}frac, \{d,t,}binom notations. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
85 ;; Format and parse sums and products in Eqn and Math modes. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
86 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
87 ;; Get math-read-big-expr to read sums, products, etc. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
88 ;; Change calc-grab-region to use math-read-big-expr. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
89 ;; Have a way to define functions using := in Embedded Mode. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
90 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
91 ;; Support polar plotting with GNUPLOT. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
92 ;; Make a calc-graph-histogram function. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
93 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
94 ;; Replace hokey formulas for complex functions with formulas designed |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
95 ;; to minimize roundoff while maintaining the proper branch cuts. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
96 ;; Test accuracy of advanced math functions over whole complex plane. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
97 ;; Extend Bessel functions to provide arbitrary precision. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
98 ;; Extend advanced math functions to handle error forms and intervals. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
99 ;; Provide a better implementation for math-sin-cos-raw. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
100 ;; Provide a better implementation for math-hypot. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
101 ;; Provide a better implementation for math-make-frac. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
102 ;; Provide a better implementation for calcFunc-prfac. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
103 ;; Provide a better implementation for calcFunc-factor. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
104 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
105 ;; Provide more examples in the tutorial section of the manual. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
106 ;; Cover in the tutorial: simplification modes, declarations, |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
107 ;; bitwise stuff, selections, matrix mapping, financial functions. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
108 ;; Provide more Lisp programming examples in the manual. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
109 ;; Finish the Internals section of the manual (and bring it up to date). |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
110 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
111 ;; Tim suggests adding spreadsheet-like features. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
112 ;; Implement language modes for Gnuplot, Lisp, Ada, APL, ...? |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
113 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
114 ;; For atan series, if x > tan(pi/12) (about 0.268) reduce using the identity |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
115 ;; atan(x) = atan((x * sqrt(3) - 1) / (sqrt(3) + x)) + pi/6. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
116 ;; |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
117 ;; A better integration algorithm: |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
118 ;; Use breadth-first instead of depth-first search, as follows: |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
119 ;; The integral cache allows unfinished integrals in symbolic notation |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
120 ;; on the righthand side. An entry with no unfinished integrals on the |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
121 ;; RHS is "complete"; references to it elsewhere are replaced by the |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
122 ;; integrated value. More than one cache entry for the same integral |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
123 ;; may exist, though if one becomes complete, the others may be deleted. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
124 ;; The integrator works by using every applicable rule (such as |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
125 ;; substitution, parts, linearity, etc.) to generate possible righthand |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
126 ;; sides, all of which are entered into the cache. Now, as long as the |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
127 ;; target integral is not complete (and the time limit has not run out) |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
128 ;; choose an incomplete integral from the cache and, for every integral |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
129 ;; appearing in its RHS's, add those integrals to the cache using the |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
130 ;; same substitition, parts, etc. rules. The cache should be organized |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
131 ;; as a priority queue, choosing the "simplest" incomplete integral at |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
132 ;; each step, or choosing randomly among equally simple integrals. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
133 ;; Simplicity equals small size, and few steps removed from the original |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
134 ;; target integral. Note that when the integrator finishes, incomplete |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
135 ;; integrals can be left in the cache, so the algorithm can start where |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
136 ;; it left off if another similar integral is later requested. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
137 ;; Breadth-first search would avoid the nagging problem of, e.g., whether |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
138 ;; to use parts or substitution first, and which decomposition is best. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
139 ;; All are tried, and any path that diverges will quickly be put on the |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
140 ;; back burner by the priority queue. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
141 ;; Note: Probably a good idea to call math-simplify-extended before |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
142 ;; measuring a formula's simplicity. |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
143 |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
144 ;; From: "Robert J. Chassell" <bob@rattlesnake.com> |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
145 ;; Subject: Re: fix for `Cannot open load file: calc-alg-3' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
146 ;; To: walters@debian.org |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
147 ;; Date: Sat, 24 Nov 2001 21:44:21 +0000 (UTC) |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
148 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
149 ;; Could you add logistic curve fitting to the current list? |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
150 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
151 ;; (I guess the key binding for a logistic curve would have to be `s' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
152 ;; since a logistic curve is an `s' curve; both `l' and `L' are already |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
153 ;; taken for logarithms.) |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
154 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
155 ;; Here is the current list for curve fitting; |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
156 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
157 ;; `1' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
158 ;; Linear or multilinear. a + b x + c y + d z. |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
159 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
160 ;; `2-9' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
161 ;; Polynomials. a + b x + c x^2 + d x^3. |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
162 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
163 ;; `e' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
164 ;; Exponential. a exp(b x) exp(c y). |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
165 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
166 ;; `E' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
167 ;; Base-10 exponential. a 10^(b x) 10^(c y). |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
168 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
169 ;; `x' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
170 ;; Exponential (alternate notation). exp(a + b x + c y). |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
171 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
172 ;; `X' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
173 ;; Base-10 exponential (alternate). 10^(a + b x + c y). |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
174 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
175 ;; `l' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
176 ;; Logarithmic. a + b ln(x) + c ln(y). |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
177 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
178 ;; `L' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
179 ;; Base-10 logarithmic. a + b log10(x) + c log10(y). |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
180 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
181 ;; `^' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
182 ;; General exponential. a b^x c^y. |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
183 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
184 ;; `p' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
185 ;; Power law. a x^b y^c. |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
186 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
187 ;; `q' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
188 ;; Quadratic. a + b (x-c)^2 + d (x-e)^2. |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
189 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
190 ;; `g' |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
191 ;; Gaussian. (a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2). |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
192 ;; |
|
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
193 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
194 ;; Logistic curves are used a great deal in ecology, and in predicting |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
195 ;; human actions, such as use of different kinds of energy in a country |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
196 ;; (wood, coal, oil, natural gas, etc.) or the number of scientific |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
197 ;; papers a person publishes, or the number of movies made. |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
198 ;; |
|
41455
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
199 ;; (The less information on which to base the curve, the higher the error |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
200 ;; rate. Theodore Modis ran some Monte Carlo simulations and produced |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
201 ;; what may be useful set of confidence levels for different amounts of |
|
ede347046135
(Commentary): Cleanup, and add logistic curve fitting suggestion from
Colin Walters <walters@gnu.org>
parents:
41283
diff
changeset
|
202 ;; initial information.) |
| 40785 | 203 |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
204 ;;; Code: |
| 40785 | 205 |
|
40911
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
206 (require 'calc-macs) |
| 40785 | 207 |
| 208 ;;;###autoload | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
209 (defvar calc-settings-file user-init-file |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
210 "*File in which to record permanent settings; default is `user-init-file'.") |
| 40785 | 211 |
|
57118
5105863ead20
(calc-bug-address): Changed email address to send bug reports to.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57117
diff
changeset
|
212 (defvar calc-bug-address "belanger@truman.edu" |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
213 "Address of the author of Calc, for use by `report-calc-bug'.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
214 |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
215 (defvar calc-scan-for-dels t |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
216 "If t, scan keymaps to find all DEL-like keys. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
217 if nil, only DEL itself is mapped to calc-pop.") |
| 40785 | 218 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
219 (defvar calc-stack '((top-of-stack 1 nil)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
220 "Calculator stack. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
221 Entries are 3-lists: Formula, Height (in lines), Selection (or nil).") |
| 40785 | 222 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
223 (defvar calc-stack-top 1 |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
224 "Index into `calc-stack' of \"top\" of stack. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
225 This is 1 unless `calc-truncate-stack' has been used.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
226 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
227 (defvar calc-display-sci-high 0 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
228 "Floating-point numbers with this positive exponent or higher above the |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
229 current precision are displayed in scientific notation in calc-mode.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
230 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
231 (defvar calc-display-sci-low -3 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
232 "Floating-point numbers with this negative exponent or lower are displayed |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
233 scientific notation in calc-mode.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
234 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
235 (defvar calc-other-modes nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
236 "List of used-defined strings to append to Calculator mode line.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
237 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
238 (defvar calc-Y-help-msgs nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
239 "List of strings for Y prefix help.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
240 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
241 (defvar calc-loaded-settings-file nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
242 "t if `calc-settings-file' has been loaded yet.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
243 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
244 (defvar calc-always-load-extensions) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
245 (defvar calc-line-numbering) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
246 (defvar calc-line-breaking) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
247 (defvar calc-display-just) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
248 (defvar calc-display-origin) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
249 (defvar calc-number-radix) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
250 (defvar calc-leading-zeros) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
251 (defvar calc-group-digits) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
252 (defvar calc-group-char) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
253 (defvar calc-point-char) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
254 (defvar calc-frac-format) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
255 (defvar calc-prefer-frac) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
256 (defvar calc-hms-format) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
257 (defvar calc-date-format) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
258 (defvar calc-float-format) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
259 (defvar calc-full-float-format) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
260 (defvar calc-complex-format) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
261 (defvar calc-complex-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
262 (defvar calc-infinite-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
263 (defvar calc-display-strings) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
264 (defvar calc-matrix-just) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
265 (defvar calc-break-vectors) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
266 (defvar calc-full-vectors) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
267 (defvar calc-full-trail-vectors) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
268 (defvar calc-vector-commas) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
269 (defvar calc-vector-brackets) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
270 (defvar calc-matrix-brackets) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
271 (defvar calc-language) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
272 (defvar calc-language-option) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
273 (defvar calc-left-label) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
274 (defvar calc-right-label) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
275 (defvar calc-word-size) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
276 (defvar calc-previous-modulo) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
277 (defvar calc-simplify-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
278 (defvar calc-auto-recompute) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
279 (defvar calc-display-raw) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
280 (defvar calc-internal-prec) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
281 (defvar calc-angle-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
282 (defvar calc-algebraic-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
283 (defvar calc-incomplete-algebraic-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
284 (defvar calc-symbolic-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
285 (defvar calc-matrix-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
286 (defvar calc-shift-prefix) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
287 (defvar calc-window-height) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
288 (defvar calc-display-trail) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
289 (defvar calc-show-selections) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
290 (defvar calc-use-selections) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
291 (defvar calc-assoc-selections) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
292 (defvar calc-display-working-message) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
293 (defvar calc-auto-why) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
294 (defvar calc-timing) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
295 (defvar calc-mode-save-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
296 (defvar calc-standard-date-formats) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
297 (defvar calc-autorange-units) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
298 (defvar calc-was-keypad-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
299 (defvar calc-full-mode) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
300 (defvar calc-user-parse-tables) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
301 (defvar calc-gnuplot-default-device) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
302 (defvar calc-gnuplot-default-output) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
303 (defvar calc-gnuplot-print-device) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
304 (defvar calc-gnuplot-print-output) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
305 (defvar calc-gnuplot-geometry) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
306 (defvar calc-graph-default-resolution) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
307 (defvar calc-graph-default-resolution-3d) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
308 (defvar calc-invocation-macro) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
309 (defvar calc-show-banner) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
310 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
311 (defconst calc-mode-var-list '( |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
312 (calc-always-load-extensions nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
313 "If non-nil, load the calc-ext module automatically when calc is loaded.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
314 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
315 (calc-line-numbering t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
316 "If non-nil, display line numbers in Calculator stack.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
317 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
318 (calc-line-breaking t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
319 "If non-nil, break long values across multiple lines in Calculator stack.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
320 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
321 (calc-display-just nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
322 "If nil, stack display is left-justified. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
323 If `right', stack display is right-justified. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
324 If `center', stack display is centered.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
325 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
326 (calc-display-origin nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
327 "Horizontal origin of displayed stack entries. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
328 In left-justified mode, this is effectively indentation. (Default 0). |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
329 In right-justified mode, this is effectively window width. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
330 In centered mode, center of stack entry is placed here.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
331 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
332 (calc-number-radix 10 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
333 "Radix for entry and display of numbers in calc-mode, 2-36.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
334 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
335 (calc-leading-zeros nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
336 "If non-nil, leading zeros are provided to pad integers to calc-word-size.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
337 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
338 (calc-group-digits nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
339 "If non-nil, group digits in large displayed integers by inserting spaces. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
340 If an integer, group that many digits at a time. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
341 If t, use 4 for binary and hex, 3 otherwise.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
342 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
343 (calc-group-char "," |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
344 "The character (in the form of a string) to be used for grouping digits. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
345 This is used only when calc-group-digits mode is on.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
346 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
347 (calc-point-char "." |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
348 "The character (in the form of a string) to be used as a decimal point.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
349 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
350 (calc-frac-format (":" nil) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
351 "Format of displayed fractions; a string of one or two of \":\" or \"/\".") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
352 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
353 (calc-prefer-frac nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
354 "If non-nil, prefer fractional over floating-point results.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
355 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
356 (calc-hms-format "%s@ %s' %s\"" |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
357 "Format of displayed hours-minutes-seconds angles, a format string. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
358 String must contain three %s marks for hours, minutes, seconds respectively.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
359 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
360 (calc-date-format ((H ":" mm C SS pp " ") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
361 Www " " Mmm " " D ", " YYYY) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
362 "Format of displayed date forms.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
363 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
364 (calc-float-format (float 0) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
365 "Format to use for display of floating-point numbers in calc-mode. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
366 Must be a list of one of the following forms: |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
367 (float 0) Floating point format, display full precision. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
368 (float N) N > 0: Floating point format, at most N significant figures. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
369 (float -N) -N < 0: Floating point format, calc-internal-prec - N figs. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
370 (fix N) N >= 0: Fixed point format, N places after decimal point. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
371 (sci 0) Scientific notation, full precision. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
372 (sci N) N > 0: Scientific notation, N significant figures. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
373 (sci -N) -N < 0: Scientific notation, calc-internal-prec - N figs. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
374 (eng 0) Engineering notation, full precision. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
375 (eng N) N > 0: Engineering notation, N significant figures. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
376 (eng -N) -N < 0: Engineering notation, calc-internal-prec - N figs.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
377 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
378 (calc-full-float-format (float 0) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
379 "Format to use when full precision must be displayed.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
380 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
381 (calc-complex-format nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
382 "Format to use for display of complex numbers in calc-mode. Must be one of: |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
383 nil Use (x, y) form. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
384 i Use x + yi form. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
385 j Use x + yj form.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
386 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
387 (calc-complex-mode cplx |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
388 "Preferred form, either `cplx' or `polar', for complex numbers.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
389 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
390 (calc-infinite-mode nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
391 "If nil, 1 / 0 is left unsimplified. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
392 If 0, 1 / 0 is changed to inf (zeros are considered positive). |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
393 Otherwise, 1 / 0 is changed to uinf (undirected infinity).") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
394 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
395 (calc-display-strings nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
396 "If non-nil, display vectors of byte-sized integers as strings.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
397 |
|
57170
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
398 (calc-matrix-just center |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
399 "If nil, vector elements are left-justified. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
400 If `right', vector elements are right-justified. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
401 If `center', vector elements are centered.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
402 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
403 (calc-break-vectors nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
404 "If non-nil, display vectors one element per line.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
405 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
406 (calc-full-vectors t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
407 "If non-nil, display long vectors in full. If nil, use abbreviated form.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
408 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
409 (calc-full-trail-vectors t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
410 "If non-nil, display long vectors in full in the trail.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
411 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
412 (calc-vector-commas "," |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
413 "If non-nil, separate elements of displayed vectors with this string.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
414 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
415 (calc-vector-brackets "[]" |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
416 "If non-nil, surround displayed vectors with these characters.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
417 |
|
57121
e7e9f0ab8734
(calc-mode-var-list): Fixed the value of `calc-matrix-brackets'.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57118
diff
changeset
|
418 (calc-matrix-brackets (R O) |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
419 "A list of code-letter symbols that control \"big\" matrix display. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
420 If `R' is present, display inner brackets for matrices. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
421 If `O' is present, display outer brackets for matrices (above/below). |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
422 If `C' is present, display outer brackets for matrices (centered).") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
423 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
424 (calc-language nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
425 "Language or format for entry and display of stack values. Must be one of: |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
426 nil Use standard Calc notation. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
427 flat Use standard Calc notation, one-line format. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
428 big Display formulas in 2-d notation (enter w/std notation). |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
429 unform Use unformatted display: add(a, mul(b,c)). |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
430 c Use C language notation. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
431 pascal Use Pascal language notation. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
432 fortran Use Fortran language notation. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
433 tex Use TeX notation. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
434 eqn Use eqn notation. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
435 math Use Mathematica(tm) notation. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
436 maple Use Maple notation.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
437 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
438 (calc-language-option nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
439 "Numeric prefix argument for the command that set `calc-language'.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
440 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
441 (calc-left-label "" |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
442 "Label to display at left of formula.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
443 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
444 (calc-right-label "" |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
445 "Label to display at right of formula.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
446 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
447 (calc-word-size 32 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
448 "Minimum number of bits per word, if any, for binary operations in calc-mode.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
449 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
450 (calc-previous-modulo nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
451 "Most recently used value of M in a modulo form.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
452 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
453 (calc-simplify-mode nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
454 "Type of simplification applied to results. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
455 If `none', results are not simplified when pushed on the stack. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
456 If `num', functions are simplified only when args are constant. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
457 If nil, only fast simplifications are applied. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
458 If `binary', `math-clip' is applied if appropriate. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
459 If `alg', `math-simplify' is applied. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
460 If `ext', `math-simplify-extended' is applied. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
461 If `units', `math-simplify-units' is applied.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
462 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
463 (calc-auto-recompute t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
464 "If non-nil, recompute evalto's automatically when necessary.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
465 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
466 (calc-display-raw nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
467 "If non-nil, display shows unformatted Lisp exprs. (For debugging)") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
468 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
469 (calc-internal-prec 12 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
470 "Number of digits of internal precision for calc-mode calculations.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
471 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
472 (calc-angle-mode deg |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
473 "If deg, angles are in degrees; if rad, angles are in radians. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
474 If hms, angles are in degrees-minutes-seconds.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
475 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
476 (calc-algebraic-mode nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
477 "If non-nil, numeric entry accepts whole algebraic expressions. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
478 If nil, algebraic expressions must be preceded by \"'\".") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
479 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
480 (calc-incomplete-algebraic-mode nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
481 "Like calc-algebraic-mode except only affects ( and [ keys.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
482 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
483 (calc-symbolic-mode nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
484 "If non-nil, inexact numeric computations like sqrt(2) are postponed. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
485 If nil, computations on numbers always yield numbers where possible.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
486 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
487 (calc-matrix-mode nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
488 "If `matrix', variables are assumed to be matrix-valued. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
489 If a number, variables are assumed to be NxN matrices. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
490 If `scalar', variables are assumed to be scalar-valued. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
491 If nil, symbolic math routines make no assumptions about variables.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
492 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
493 (calc-shift-prefix nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
494 "If non-nil, shifted letter keys are prefix keys rather than normal meanings.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
495 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
496 (calc-window-height 7 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
497 "Initial height of Calculator window.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
498 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
499 (calc-display-trail t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
500 "If non-nil, M-x calc creates a window to display Calculator trail.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
501 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
502 (calc-show-selections t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
503 "If non-nil, selected sub-formulas are shown by obscuring rest of formula. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
504 If nil, selected sub-formulas are highlighted by obscuring the sub-formulas.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
505 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
506 (calc-use-selections t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
507 "If non-nil, commands operate only on selected portions of formulas. |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
508 If nil, selections displayed but ignored.") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
509 |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
510 (calc-assoc-selections t |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
511 "If non-nil, selection hides deep structure of associative formulas.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
512 |
|
57170
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
513 (calc-display-working-message lots |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
514 "If non-nil, display \"Working...\" for potentially slow Calculator commands.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
515 |
|
57170
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
516 (calc-auto-why maybe |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
517 "If non-nil, automatically execute a \"why\" command to explain odd results.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
518 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
519 (calc-timing nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
520 "If non-nil, display timing information on each slow command.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
521 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
522 (calc-mode-save-mode local) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
523 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
524 (calc-standard-date-formats |
|
57170
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
525 ("N" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
526 "<H:mm:SSpp >Www Mmm D, YYYY" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
527 "D Mmm YYYY<, h:mm:SS>" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
528 "Www Mmm BD< hh:mm:ss> YYYY" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
529 "M/D/Y< H:mm:SSpp>" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
530 "D.M.Y< h:mm:SS>" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
531 "M-D-Y< H:mm:SSpp>" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
532 "D-M-Y< h:mm:SS>" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
533 "j<, h:mm:SS>" |
|
01f54f65a36b
(calc-mode-var-list): Removed unnecessary quotes.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57121
diff
changeset
|
534 "YYddd< hh:mm:ss>")) |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
535 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
536 (calc-autorange-units nil) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
537 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
538 (calc-was-keypad-mode nil) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
539 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
540 (calc-full-mode nil) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
541 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
542 (calc-user-parse-tables nil) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
543 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
544 (calc-gnuplot-default-device "default") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
545 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
546 (calc-gnuplot-default-output "STDOUT") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
547 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
548 (calc-gnuplot-print-device "postscript") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
549 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
550 (calc-gnuplot-print-output "auto") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
551 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
552 (calc-gnuplot-geometry nil) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
553 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
554 (calc-graph-default-resolution 15) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
555 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
556 (calc-graph-default-resolution-3d 5) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
557 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
558 (calc-invocation-macro nil) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
559 |
|
58477
f7508bb6a284
(calc-embedded-active): Removed unnecessary declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58467
diff
changeset
|
560 (calc-show-banner t |
|
f7508bb6a284
(calc-embedded-active): Removed unnecessary declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58467
diff
changeset
|
561 "*If non-nil, show a friendly greeting above the stack.")) |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
562 "List of variables (and default values) used in customizing GNU Calc.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
563 |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
564 (mapcar (function (lambda (v) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
565 (or (boundp (car v)) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
566 (set (car v) (nth 1 v))) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
567 (if (nth 2 v) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
568 (put (car v) 'variable-documentation (nth 2 v))))) |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
569 calc-mode-var-list) |
| 40785 | 570 |
| 571 (defconst calc-local-var-list '(calc-stack | |
| 572 calc-stack-top | |
| 573 calc-undo-list | |
| 574 calc-redo-list | |
| 575 calc-always-load-extensions | |
| 576 calc-mode-save-mode | |
| 577 calc-display-raw | |
| 578 calc-line-numbering | |
| 579 calc-line-breaking | |
| 580 calc-display-just | |
| 581 calc-display-origin | |
| 582 calc-left-label | |
| 583 calc-right-label | |
| 584 calc-auto-why | |
| 585 calc-algebraic-mode | |
| 586 calc-incomplete-algebraic-mode | |
| 587 calc-symbolic-mode | |
| 588 calc-matrix-mode | |
| 589 calc-inverse-flag | |
| 590 calc-hyperbolic-flag | |
| 591 calc-keep-args-flag | |
| 592 calc-angle-mode | |
| 593 calc-number-radix | |
| 594 calc-leading-zeros | |
| 595 calc-group-digits | |
| 596 calc-group-char | |
| 597 calc-point-char | |
| 598 calc-frac-format | |
| 599 calc-prefer-frac | |
| 600 calc-hms-format | |
| 601 calc-date-format | |
| 602 calc-standard-date-formats | |
| 603 calc-float-format | |
| 604 calc-full-float-format | |
| 605 calc-complex-format | |
| 606 calc-matrix-just | |
| 607 calc-full-vectors | |
| 608 calc-full-trail-vectors | |
| 609 calc-break-vectors | |
| 610 calc-vector-commas | |
| 611 calc-vector-brackets | |
| 612 calc-matrix-brackets | |
| 613 calc-complex-mode | |
| 614 calc-infinite-mode | |
| 615 calc-display-strings | |
| 616 calc-simplify-mode | |
| 617 calc-auto-recompute | |
| 618 calc-autorange-units | |
| 619 calc-show-plain | |
| 620 calc-show-selections | |
| 621 calc-use-selections | |
| 622 calc-assoc-selections | |
| 623 calc-word-size | |
| 624 calc-internal-prec)) | |
| 625 | |
|
58061
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
626 (defvar calc-mode-hook nil |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
627 "Hook run when entering calc-mode.") |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
628 |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
629 (defvar calc-trail-mode-hook nil |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
630 "Hook run when entering calc-trail-mode.") |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
631 |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
632 (defvar calc-start-hook nil |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
633 "Hook run when calc is started.") |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
634 |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
635 (defvar calc-end-hook nil |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
636 "Hook run when calc is quit.") |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
637 |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
638 (defvar calc-load-hook nil |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
639 "Hook run when calc.el is loaded.") |
| 40785 | 640 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
641 ;; Verify that Calc is running on the right kind of system. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
642 (defvar calc-emacs-type-lucid (not (not (string-match "Lucid" emacs-version)))) |
| 40785 | 643 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
644 ;; Set up the standard keystroke (M-#) to run the Calculator, if that key |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
645 ;; has not yet been bound to anything. For best results, the user should |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
646 ;; do this before Calc is even loaded, so that M-# can auto-load Calc. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
647 (or (global-key-binding "\e#") (global-set-key "\e#" 'calc-dispatch)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
648 |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
649 ;; Set up the autoloading linkage. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
650 (let ((name (and (fboundp 'calc-dispatch) |
| 40785 | 651 (eq (car-safe (symbol-function 'calc-dispatch)) 'autoload) |
| 652 (nth 1 (symbol-function 'calc-dispatch)))) | |
| 653 (p load-path)) | |
| 654 | |
| 655 ;; If Calc files exist on the load-path, we're all set. | |
| 656 (while (and p (not (file-exists-p | |
| 657 (expand-file-name "calc-misc.elc" (car p))))) | |
| 658 (setq p (cdr p))) | |
| 659 (or p | |
| 660 | |
| 661 ;; If Calc is autoloaded using a path name, look there for Calc files. | |
| 662 ;; This works for both relative ("calc/calc.elc") and absolute paths. | |
| 663 (and name (file-name-directory name) | |
| 664 (let ((p2 load-path) | |
| 665 (name2 (concat (file-name-directory name) | |
| 666 "calc-misc.elc"))) | |
| 667 (while (and p2 (not (file-exists-p | |
| 668 (expand-file-name name2 (car p2))))) | |
| 669 (setq p2 (cdr p2))) | |
| 45769 | 670 (when p2 |
| 671 (setq load-path (nconc load-path | |
| 672 (list | |
| 673 (directory-file-name | |
| 674 (file-name-directory | |
| 675 (expand-file-name | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
676 name (car p2)))))))))))) |
| 40785 | 677 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
678 ;; The following modes use specially-formatted data. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
679 (put 'calc-mode 'mode-class 'special) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
680 (put 'calc-trail-mode 'mode-class 'special) |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
681 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
682 ;; Define "inexact-result" as an e-lisp error symbol. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
683 (put 'inexact-result 'error-conditions '(error inexact-result calc-error)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
684 (put 'inexact-result 'error-message "Calc internal error (inexact-result)") |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
685 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
686 ;; Define "math-overflow" and "math-underflow" as e-lisp error symbols. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
687 (put 'math-overflow 'error-conditions '(error math-overflow calc-error)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
688 (put 'math-overflow 'error-message "Floating-point overflow occurred") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
689 (put 'math-underflow 'error-conditions '(error math-underflow calc-error)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
690 (put 'math-underflow 'error-message "Floating-point underflow occurred") |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
691 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
692 (defconst calc-version "2.02g") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
693 (defconst calc-version-date "Mon Nov 19 2001") |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
694 (defvar calc-trail-pointer nil) ; "Current" entry in trail buffer. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
695 (defvar calc-trail-overlay nil) ; Value of overlay-arrow-string. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
696 (defvar calc-undo-list nil) ; List of previous operations for undo. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
697 (defvar calc-redo-list nil) ; List of recent undo operations. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
698 (defvar calc-main-buffer nil) ; Pointer to Calculator buffer. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
699 (defvar calc-trail-buffer nil) ; Pointer to Calc Trail buffer. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
700 (defvar calc-why nil) ; Explanations of most recent errors. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
701 (defvar calc-next-why nil) |
|
57115
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
702 (defvar calc-inverse-flag nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
703 "If non-nil, next operation is Inverse.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
704 (defvar calc-hyperbolic-flag nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
705 "If non-nil, next operation is Hyperbolic.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
706 (defvar calc-keep-args-flag nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
707 "If non-nil, next operation should not remove its arguments from stack.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
708 (defvar calc-function-open "(" |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
709 "Open-parenthesis string for function call notation.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
710 (defvar calc-function-close ")" |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
711 "Close-parenthesis string for function call notation.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
712 (defvar calc-language-output-filter nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
713 "Function through which to pass strings after formatting.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
714 (defvar calc-language-input-filter nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
715 "Function through which to pass strings before parsing.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
716 (defvar calc-radix-formatter nil |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
717 "Formatting function used for non-decimal numbers.") |
|
abc0e9beaacd
calc/calc.el (calc-mode-var-list): Define this variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
54583
diff
changeset
|
718 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
719 (defvar calc-last-kill nil) ; Last number killed in calc-mode. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
720 (defvar calc-previous-alg-entry nil) ; Previous algebraic entry. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
721 (defvar calc-dollar-values nil) ; Values to be used for '$'. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
722 (defvar calc-dollar-used nil) ; Highest order of '$' that occurred. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
723 (defvar calc-hashes-used nil) ; Highest order of '#' that occurred. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
724 (defvar calc-quick-prev-results nil) ; Previous results from Quick Calc. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
725 (defvar calc-said-hello nil) ; Has welcome message been said yet? |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
726 (defvar calc-executing-macro nil) ; Kbd macro executing from "K" key. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
727 (defvar calc-any-selections nil) ; Nil means no selections present. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
728 (defvar calc-help-phase 0) ; Count of consecutive "?" keystrokes. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
729 (defvar calc-full-help-flag nil) ; Executing calc-full-help? |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
730 (defvar calc-refresh-count 0) ; Count of calc-refresh calls. |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
731 (defvar calc-display-dirty nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
732 (defvar calc-prepared-composition nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
733 (defvar calc-selection-cache-default-entry nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
734 (defvar calc-embedded-info nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
735 (defvar calc-embedded-active nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
736 (defvar calc-standalone-flag nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
737 (defvar var-EvalRules nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
738 (defvar math-eval-rules-cache-tag t) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
739 (defvar math-radix-explicit-format t) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
740 (defvar math-expr-function-mapping nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
741 (defvar math-expr-variable-mapping nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
742 (defvar math-read-expr-quotes nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
743 (defvar math-working-step nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
744 (defvar math-working-step-2 nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
745 (defvar var-i '(special-const (math-imaginary 1))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
746 (defvar var-pi '(special-const (math-pi))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
747 (defvar var-e '(special-const (math-e))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
748 (defvar var-phi '(special-const (math-phi))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
749 (defvar var-gamma '(special-const (math-gamma-const))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
750 (defvar var-Modes '(special-const (math-get-modes-vec))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
751 |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
752 (mapcar (lambda (v) (or (boundp v) (set v nil))) |
| 40785 | 753 calc-local-var-list) |
| 754 | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
755 (defvar calc-mode-map |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
756 (let ((map (make-keymap))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
757 (suppress-keymap map t) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
758 (define-key map "+" 'calc-plus) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
759 (define-key map "-" 'calc-minus) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
760 (define-key map "*" 'calc-times) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
761 (define-key map "/" 'calc-divide) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
762 (define-key map "%" 'calc-mod) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
763 (define-key map "&" 'calc-inv) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
764 (define-key map "^" 'calc-power) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
765 (define-key map "\M-%" 'calc-percent) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
766 (define-key map "e" 'calcDigit-start) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
767 (define-key map "i" 'calc-info) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
768 (define-key map "n" 'calc-change-sign) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
769 (define-key map "q" 'calc-quit) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
770 (define-key map "Y" 'nil) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
771 (define-key map "Y?" 'calc-shift-Y-prefix-help) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
772 (define-key map "?" 'calc-help) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
773 (define-key map " " 'calc-enter) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
774 (define-key map "'" 'calc-algebraic-entry) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
775 (define-key map "$" 'calc-auto-algebraic-entry) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
776 (define-key map "\"" 'calc-auto-algebraic-entry) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
777 (define-key map "\t" 'calc-roll-down) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
778 (define-key map "\M-\t" 'calc-roll-up) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
779 (define-key map "\C-m" 'calc-enter) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
780 (define-key map "\M-\C-m" 'calc-last-args-stub) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
781 (define-key map "\C-j" 'calc-over) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
782 |
|
54583
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
783 (mapc (lambda (x) (define-key map (char-to-string x) 'undefined)) |
|
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
784 "lOW") |
|
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
785 (mapc (lambda (x) (define-key map (char-to-string x) 'calc-missing-key)) |
|
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
786 (concat "ABCDEFGHIJKLMNPQRSTUVXZabcdfghjkmoprstuvwxyz" |
|
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
787 ":\\|!()[]<>{},;=~`\C-k\M-k\C-w\M-w\C-y\C-_")) |
|
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
788 (mapc (lambda (x) (define-key map (char-to-string x) 'calcDigit-start)) |
|
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
789 "_0123456789.#@") |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
790 map)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
791 |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
792 (defvar calc-digit-map |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
793 (let ((map (make-keymap))) |
| 40785 | 794 (if calc-emacs-type-lucid |
| 795 (map-keymap (function | |
| 796 (lambda (keys bind) | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
797 (define-key map keys |
| 40785 | 798 (if (eq bind 'undefined) |
| 799 'undefined 'calcDigit-nondigit)))) | |
| 800 calc-mode-map) | |
|
57591
98d755565607
(calc-emacs-type-19, calc-emacs-type-epoch, calc-emacs-type-gnu19):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57429
diff
changeset
|
801 (let ((cmap (nth 1 calc-mode-map)) |
|
98d755565607
(calc-emacs-type-19, calc-emacs-type-epoch, calc-emacs-type-gnu19):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57429
diff
changeset
|
802 (dmap (nth 1 map)) |
| 40785 | 803 (i 0)) |
| 804 (while (< i 128) | |
| 805 (aset dmap i | |
| 806 (if (eq (aref cmap i) 'undefined) | |
| 807 'undefined 'calcDigit-nondigit)) | |
| 808 (setq i (1+ i))))) | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
809 (mapcar (lambda (x) (define-key map (char-to-string x) 'calcDigit-key)) |
| 40785 | 810 "_0123456789.e+-:n#@oh'\"mspM") |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
811 (mapcar (lambda (x) (define-key map (char-to-string x) 'calcDigit-letter)) |
| 40785 | 812 "abcdfgijklqrtuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ") |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
813 (define-key map "'" 'calcDigit-algebraic) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
814 (define-key map "`" 'calcDigit-edit) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
815 (define-key map "\C-g" 'abort-recursive-edit) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
816 map)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
817 |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
818 (mapcar (lambda (x) |
| 40785 | 819 (condition-case err |
| 820 (progn | |
| 821 (define-key calc-digit-map x 'calcDigit-backspace) | |
| 822 (define-key calc-mode-map x 'calc-pop) | |
| 823 (define-key calc-mode-map | |
| 824 (if (vectorp x) | |
| 825 (if calc-emacs-type-lucid | |
| 826 (if (= (length x) 1) | |
| 827 (vector (if (consp (aref x 0)) | |
| 828 (cons 'meta (aref x 0)) | |
| 829 (list 'meta (aref x 0)))) | |
| 830 "\e\C-d") | |
| 831 (vconcat "\e" x)) | |
| 832 (concat "\e" x)) | |
| 833 'calc-pop-above)) | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
834 (error nil))) |
| 40785 | 835 (if calc-scan-for-dels |
| 836 (append (where-is-internal 'delete-backward-char global-map) | |
| 837 (where-is-internal 'backward-delete-char global-map) | |
| 838 '("\C-d")) | |
| 839 '("\177" "\C-d"))) | |
| 840 | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
841 (defvar calc-dispatch-map |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
842 (let ((map (make-keymap))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
843 (mapcar (lambda (x) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
844 (define-key map (char-to-string (car x)) (cdr x)) |
| 45769 | 845 (when (string-match "abcdefhijklnopqrstuwxyz" |
| 846 (char-to-string (car x))) | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
847 (define-key map (char-to-string (- (car x) ?a -1)) (cdr x))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
848 (define-key map (format "\e%c" (car x)) (cdr x))) |
| 40785 | 849 '( ( ?a . calc-embedded-activate ) |
| 850 ( ?b . calc-big-or-small ) | |
| 851 ( ?c . calc ) | |
| 852 ( ?d . calc-embedded-duplicate ) | |
| 853 ( ?e . calc-embedded ) | |
| 854 ( ?f . calc-embedded-new-formula ) | |
| 855 ( ?g . calc-grab-region ) | |
| 856 ( ?h . calc-dispatch-help ) | |
| 857 ( ?i . calc-info ) | |
| 858 ( ?j . calc-embedded-select ) | |
| 859 ( ?k . calc-keypad ) | |
| 860 ( ?l . calc-load-everything ) | |
| 861 ( ?m . read-kbd-macro ) | |
| 862 ( ?n . calc-embedded-next ) | |
| 863 ( ?o . calc-other-window ) | |
| 864 ( ?p . calc-embedded-previous ) | |
| 865 ( ?q . quick-calc ) | |
| 866 ( ?r . calc-grab-rectangle ) | |
| 867 ( ?s . calc-info-summary ) | |
| 868 ( ?t . calc-tutorial ) | |
| 869 ( ?u . calc-embedded-update-formula ) | |
| 870 ( ?w . calc-embedded-word ) | |
| 871 ( ?x . calc-quit ) | |
| 872 ( ?y . calc-copy-to-buffer ) | |
| 873 ( ?z . calc-user-invocation ) | |
| 874 ( ?= . calc-embedded-update-formula ) | |
| 875 ( ?\' . calc-embedded-new-formula ) | |
| 876 ( ?\` . calc-embedded-edit ) | |
| 877 ( ?: . calc-grab-sum-down ) | |
| 878 ( ?_ . calc-grab-sum-across ) | |
| 879 ( ?0 . calc-reset ) | |
| 880 ( ?# . calc-same-interface ) | |
|
47682
7932474eac63
(calc-dispatch-map): Actually set to keymap.
Colin Walters <walters@gnu.org>
parents:
47641
diff
changeset
|
881 ( ?? . calc-dispatch-help ) )) |
|
7932474eac63
(calc-dispatch-map): Actually set to keymap.
Colin Walters <walters@gnu.org>
parents:
47641
diff
changeset
|
882 map)) |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
883 |
| 40785 | 884 ;;;; (Autoloads here) |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
885 (mapcar |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
886 (lambda (x) (dolist (func (cdr x)) (autoload func (car x)))) |
| 40785 | 887 '( |
| 888 | |
|
58680
fccfcd7c10f3
Remove calc-Need-calc-aent and calc-Need-calc-misc from autoloads.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58615
diff
changeset
|
889 ("calc-aent" calc-alg-digit-entry calc-alg-entry |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
890 calc-check-user-syntax calc-do-alg-entry calc-do-calc-eval |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
891 calc-do-quick-calc calc-match-user-syntax math-build-parse-table |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
892 math-find-user-tokens math-read-expr-list math-read-exprs math-read-if |
|
58842
a26862f74305
Add math-read-preprocess-string to autoloads.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58730
diff
changeset
|
893 math-read-token math-remove-dashes math-read-preprocess-string) |
| 40785 | 894 |
|
58680
fccfcd7c10f3
Remove calc-Need-calc-aent and calc-Need-calc-misc from autoloads.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58615
diff
changeset
|
895 ("calc-embed" calc-do-embedded-activate) |
|
fccfcd7c10f3
Remove calc-Need-calc-aent and calc-Need-calc-misc from autoloads.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58615
diff
changeset
|
896 |
|
fccfcd7c10f3
Remove calc-Need-calc-aent and calc-Need-calc-misc from autoloads.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58615
diff
changeset
|
897 ("calc-misc" |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
898 calc-do-handle-whys calc-do-refresh calc-num-prefix-name |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
899 calc-record-list calc-record-why calc-report-bug calc-roll-down-stack |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
900 calc-roll-up-stack calc-temp-minibuffer-message calcFunc-floor |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
901 calcFunc-inv calcFunc-trunc math-concat math-constp math-div2 |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
902 math-div2-bignum math-do-working math-evenp math-fixnatnump |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
903 math-fixnump math-floor math-imod math-ipow math-looks-negp math-mod |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
904 math-negp math-posp math-pow math-read-radix-digit math-reject-arg |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
905 math-trunc math-zerop))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
906 |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
907 (mapcar |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
908 (lambda (x) (dolist (cmd (cdr x)) (autoload cmd (car x) nil t))) |
| 40785 | 909 '( |
| 910 | |
| 911 ("calc-aent" calc-algebraic-entry calc-auto-algebraic-entry | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
912 calcDigit-algebraic calcDigit-edit) |
| 40785 | 913 |
| 914 ("calc-misc" another-calc calc-big-or-small calc-dispatch-help | |
|
57429
fa2eebf665a8
Added `calc-info-goto-node' to autoloads.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57170
diff
changeset
|
915 calc-help calc-info calc-info-goto-node calc-info-summary calc-inv |
|
fa2eebf665a8
Added `calc-info-goto-node' to autoloads.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57170
diff
changeset
|
916 calc-last-args-stub |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
917 calc-missing-key calc-mod calc-other-window calc-over calc-percent |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
918 calc-pop-above calc-power calc-roll-down calc-roll-up |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
919 calc-shift-Y-prefix-help calc-tutorial calcDigit-letter |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
920 report-calc-bug))) |
| 40785 | 921 |
| 922 | |
| 923 ;;;###autoload (global-set-key "\e#" 'calc-dispatch) | |
| 924 | |
| 925 ;;;###autoload | |
| 926 (defun calc-dispatch (&optional arg) | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
927 "Invoke the GNU Emacs Calculator. See `calc-dispatch-help' for details." |
| 40785 | 928 (interactive "P") |
| 929 (sit-for echo-keystrokes) | |
| 930 (condition-case err ; look for other keys bound to calc-dispatch | |
| 931 (let ((keys (this-command-keys))) | |
| 45769 | 932 (unless (or (not (stringp keys)) |
| 933 (string-match "\\`\C-u\\|\\`\e[-0-9#]\\|`[\M--\M-0-\M-9]" keys) | |
| 934 (eq (lookup-key calc-dispatch-map keys) 'calc-same-interface)) | |
| 935 (when (and (string-match "\\`[\C-@-\C-_]" keys) | |
| 936 (symbolp | |
| 937 (lookup-key calc-dispatch-map (substring keys 0 1)))) | |
| 938 (define-key calc-dispatch-map (substring keys 0 1) nil)) | |
| 939 (define-key calc-dispatch-map keys 'calc-same-interface))) | |
| 40785 | 940 (error nil)) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
941 (calc-do-dispatch arg)) |
| 40785 | 942 |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
943 (defvar calc-dispatch-help nil) |
| 40785 | 944 (defun calc-do-dispatch (arg) |
| 945 (let ((key (calc-read-key-sequence | |
| 946 (if calc-dispatch-help | |
| 947 "Calc options: Calc, Keypad, Quick, Embed; eXit; Info, Tutorial; Grab; ?=more" | |
| 948 (format "%s (Type ? for a list of Calc options)" | |
| 949 (key-description (this-command-keys)))) | |
| 950 calc-dispatch-map))) | |
| 951 (setq key (lookup-key calc-dispatch-map key)) | |
| 952 (message "") | |
| 953 (if key | |
| 954 (progn | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
955 (or (commandp key) (require 'calc-ext)) |
| 40785 | 956 (call-interactively key)) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
957 (beep)))) |
| 40785 | 958 |
| 959 (defun calc-read-key-sequence (prompt map) | |
| 960 (let ((prompt2 (format "%s " (key-description (this-command-keys)))) | |
| 961 (glob (current-global-map)) | |
| 962 (loc (current-local-map))) | |
| 963 (or (input-pending-p) (message prompt)) | |
| 964 (let ((key (calc-read-key t))) | |
| 965 (calc-unread-command (cdr key)) | |
| 966 (unwind-protect | |
| 967 (progn | |
| 968 (use-global-map map) | |
| 969 (use-local-map nil) | |
|
58730
58d50d1b56ac
(calc-read-key-sequence): Leave message visible.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58680
diff
changeset
|
970 (read-key-sequence nil)) |
| 40785 | 971 (use-global-map glob) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
972 (use-local-map loc))))) |
| 40785 | 973 |
| 974 | |
| 975 | |
| 976 (defun calc-mode () | |
| 977 "Calculator major mode. | |
| 978 | |
| 979 This is an RPN calculator featuring arbitrary-precision integer, rational, | |
| 980 floating-point, complex, matrix, and symbolic arithmetic. | |
| 981 | |
| 982 RPN calculation: 2 RET 3 + produces 5. | |
| 983 Algebraic style: ' 2+3 RET produces 5. | |
| 984 | |
| 985 Basic operators are +, -, *, /, ^, & (reciprocal), % (modulo), n (change-sign). | |
| 986 | |
| 987 Press ? repeatedly for more complete help. Press `h i' to read the | |
| 988 Calc manual on-line, `h s' to read the summary, or `h t' for the tutorial. | |
| 989 | |
| 990 Notations: 3.14e6 3.14 * 10^6 | |
| 991 _23 negative number -23 (or type `23 n') | |
| 992 17:3 the fraction 17/3 | |
| 993 5:2:3 the fraction 5 and 2/3 | |
| 994 16#12C the integer 12C base 16 = 300 base 10 | |
| 995 8#177:100 the fraction 177:100 base 8 = 127:64 base 10 | |
| 996 (2, 4) complex number 2 + 4i | |
| 997 (2; 4) polar complex number (r; theta) | |
| 998 [1, 2, 3] vector ([[1, 2], [3, 4]] is a matrix) | |
| 999 [1 .. 4) semi-open interval, 1 <= x < 4 | |
| 1000 2 +/- 3 (p key) number with mean 2, standard deviation 3 | |
| 1001 2 mod 3 (M key) number 2 computed modulo 3 | |
| 1002 <1 jan 91> Date form (enter using ' key) | |
| 1003 | |
| 1004 | |
| 1005 \\{calc-mode-map} | |
| 1006 " | |
| 1007 (interactive) | |
| 1008 (mapcar (function | |
| 1009 (lambda (v) (set-default v (symbol-value v)))) calc-local-var-list) | |
| 1010 (kill-all-local-variables) | |
| 1011 (use-local-map (if (eq calc-algebraic-mode 'total) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1012 (progn (require 'calc-ext) calc-alg-map) calc-mode-map)) |
| 40785 | 1013 (mapcar (function (lambda (v) (make-local-variable v))) calc-local-var-list) |
| 1014 (make-local-variable 'overlay-arrow-position) | |
| 1015 (make-local-variable 'overlay-arrow-string) | |
|
47539
663c306c80c6
(calc-mode): Add font-lock-defontify to change-major-mode-hook.
Colin Walters <walters@gnu.org>
parents:
46807
diff
changeset
|
1016 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) |
| 40785 | 1017 (setq truncate-lines t) |
| 1018 (setq buffer-read-only t) | |
| 1019 (setq major-mode 'calc-mode) | |
| 1020 (setq mode-name "Calculator") | |
| 1021 (setq calc-stack-top (length (or (memq (assq 'top-of-stack calc-stack) | |
| 1022 calc-stack) | |
| 1023 (setq calc-stack (list (list 'top-of-stack | |
| 1024 1 nil)))))) | |
| 1025 (setq calc-stack-top (- (length calc-stack) calc-stack-top -1)) | |
| 1026 (or calc-loaded-settings-file | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1027 (null calc-settings-file) |
|
57117
d2ffbe58525c
(calc-mode): Compare `calc-settings-file' to `user-init-file' rather
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57115
diff
changeset
|
1028 (equal calc-settings-file user-init-file) |
| 40785 | 1029 (progn |
| 1030 (setq calc-loaded-settings-file t) | |
| 1031 (load calc-settings-file t))) ; t = missing-ok | |
| 1032 (let ((p command-line-args)) | |
| 1033 (while p | |
| 1034 (and (equal (car p) "-f") | |
| 1035 (string-match "calc" (nth 1 p)) | |
| 1036 (string-match "full" (nth 1 p)) | |
| 1037 (setq calc-standalone-flag t)) | |
| 1038 (setq p (cdr p)))) | |
| 1039 (run-hooks 'calc-mode-hook) | |
| 1040 (calc-refresh t) | |
| 1041 (calc-set-mode-line) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1042 (calc-check-defines)) |
| 40785 | 1043 |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1044 (defvar calc-check-defines 'calc-check-defines) ; suitable for run-hooks |
| 40785 | 1045 (defun calc-check-defines () |
| 1046 (if (symbol-plist 'calc-define) | |
| 1047 (let ((plist (copy-sequence (symbol-plist 'calc-define)))) | |
| 1048 (while (and plist (null (nth 1 plist))) | |
| 1049 (setq plist (cdr (cdr plist)))) | |
| 1050 (if plist | |
| 1051 (save-excursion | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1052 (require 'calc-ext) |
|
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1053 (require 'calc-macs) |
| 40785 | 1054 (set-buffer "*Calculator*") |
| 1055 (while plist | |
| 1056 (put 'calc-define (car plist) nil) | |
| 1057 (eval (nth 1 plist)) | |
| 1058 (setq plist (cdr (cdr plist)))) | |
| 1059 ;; See if this has added any more calc-define properties. | |
| 1060 (calc-check-defines)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1061 (setplist 'calc-define nil))))) |
| 40785 | 1062 |
| 1063 (defun calc-trail-mode (&optional buf) | |
| 1064 "Calc Trail mode. | |
| 1065 This mode is used by the *Calc Trail* buffer, which records all results | |
| 1066 obtained by the GNU Emacs Calculator. | |
| 1067 | |
| 1068 Calculator commands beginning with the `t' key are used to manipulate | |
| 1069 the Trail. | |
| 1070 | |
| 1071 This buffer uses the same key map as the *Calculator* buffer; calculator | |
| 1072 commands given here will actually operate on the *Calculator* stack." | |
| 1073 (interactive) | |
| 1074 (fundamental-mode) | |
| 1075 (use-local-map calc-mode-map) | |
| 1076 (setq major-mode 'calc-trail-mode) | |
| 1077 (setq mode-name "Calc Trail") | |
| 1078 (setq truncate-lines t) | |
| 1079 (setq buffer-read-only t) | |
| 1080 (make-local-variable 'overlay-arrow-position) | |
| 1081 (make-local-variable 'overlay-arrow-string) | |
| 45769 | 1082 (set (make-local-variable 'font-lock-defaults) |
| 1083 '(nil t nil nil nil (font-lock-core-only . t))) | |
| 1084 (when buf | |
| 1085 (set (make-local-variable 'calc-main-buffer) buf)) | |
| 1086 (when (= (buffer-size) 0) | |
| 1087 (let ((buffer-read-only nil)) | |
| 1088 (insert (propertize (concat "Emacs Calculator v" calc-version | |
| 1089 " by Dave Gillespie\n") | |
| 1090 'font-lock-face 'italic)))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1091 (run-hooks 'calc-trail-mode-hook)) |
| 40785 | 1092 |
| 1093 (defun calc-create-buffer () | |
| 1094 (set-buffer (get-buffer-create "*Calculator*")) | |
| 1095 (or (eq major-mode 'calc-mode) | |
| 1096 (calc-mode)) | |
| 1097 (setq max-lisp-eval-depth (max max-lisp-eval-depth 1000)) | |
| 45769 | 1098 (when calc-always-load-extensions |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1099 (require 'calc-ext)) |
| 45769 | 1100 (when calc-language |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1101 (require 'calc-ext) |
| 45769 | 1102 (calc-set-language calc-language calc-language-option t))) |
| 40785 | 1103 |
| 1104 ;;;###autoload | |
| 1105 (defun calc (&optional arg full-display interactive) | |
| 1106 "The Emacs Calculator. Full documentation is listed under \"calc-mode\"." | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1107 (interactive "P\ni\np") |
| 40785 | 1108 (if arg |
| 45769 | 1109 (unless (eq arg 0) |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1110 (require 'calc-ext) |
| 45769 | 1111 (if (= (prefix-numeric-value arg) -1) |
| 1112 (calc-grab-region (region-beginning) (region-end) nil) | |
| 1113 (when (= (prefix-numeric-value arg) -2) | |
| 1114 (calc-keypad)))) | |
| 1115 (when (get-buffer-window "*Calc Keypad*") | |
| 1116 (calc-keypad) | |
| 1117 (set-buffer (window-buffer (selected-window)))) | |
| 40785 | 1118 (if (eq major-mode 'calc-mode) |
| 1119 (calc-quit) | |
| 1120 (let ((oldbuf (current-buffer))) | |
| 1121 (calc-create-buffer) | |
| 1122 (setq calc-was-keypad-mode nil) | |
| 1123 (if (or (eq full-display t) | |
| 1124 (and (null full-display) calc-full-mode)) | |
| 1125 (switch-to-buffer (current-buffer) t) | |
| 1126 (if (get-buffer-window (current-buffer)) | |
| 1127 (select-window (get-buffer-window (current-buffer))) | |
|
58061
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1128 (let ((w (get-largest-window))) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1129 (if (and pop-up-windows |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1130 (> (window-height w) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1131 (+ window-min-height calc-window-height 2))) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1132 (progn |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1133 (setq w (split-window w |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1134 (- (window-height w) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1135 calc-window-height 2) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1136 nil)) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1137 (set-window-buffer w (current-buffer)) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1138 (select-window w)) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1139 (pop-to-buffer (current-buffer)))))) |
| 40785 | 1140 (save-excursion |
| 1141 (set-buffer (calc-trail-buffer)) | |
| 1142 (and calc-display-trail | |
|
40999
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
1143 (= (window-width) (frame-width)) |
| 40785 | 1144 (calc-trail-display 1 t))) |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1145 (message "Welcome to the GNU Emacs Calculator! Press `?' or `h' for help, `q' to quit") |
| 40785 | 1146 (run-hooks 'calc-start-hook) |
| 1147 (and (windowp full-display) | |
| 1148 (window-point full-display) | |
| 1149 (select-window full-display)) | |
| 1150 (calc-check-defines) | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1151 (when (and calc-said-hello interactive) |
| 45769 | 1152 (sit-for 2) |
| 1153 (message "")) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1154 (setq calc-said-hello t))))) |
| 40785 | 1155 |
| 1156 ;;;###autoload | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1157 (defun full-calc (&optional interactive) |
| 40785 | 1158 "Invoke the Calculator and give it a full-sized window." |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1159 (interactive "p") |
|
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1160 (calc nil t interactive)) |
| 40785 | 1161 |
| 1162 (defun calc-same-interface (arg) | |
| 1163 "Invoke the Calculator using the most recent interface (calc or calc-keypad)." | |
| 1164 (interactive "P") | |
| 1165 (if (and (equal (buffer-name) "*Gnuplot Trail*") | |
| 1166 (> (recursion-depth) 0)) | |
| 1167 (exit-recursive-edit) | |
| 1168 (if (eq major-mode 'calc-edit-mode) | |
| 1169 (calc-edit-finish arg) | |
| 1170 (if (eq major-mode 'MacEdit-mode) | |
| 1171 (MacEdit-finish-edit) | |
| 1172 (if calc-was-keypad-mode | |
| 1173 (calc-keypad) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1174 (calc arg calc-full-mode t)))))) |
| 40785 | 1175 |
| 1176 | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1177 (defun calc-quit (&optional non-fatal interactive) |
|
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1178 (interactive "i\np") |
| 40785 | 1179 (and calc-standalone-flag (not non-fatal) |
| 1180 (save-buffers-kill-emacs nil)) | |
| 1181 (if (and (equal (buffer-name) "*Gnuplot Trail*") | |
| 1182 (> (recursion-depth) 0)) | |
| 1183 (exit-recursive-edit)) | |
| 1184 (if (eq major-mode 'calc-edit-mode) | |
| 1185 (calc-edit-cancel) | |
| 1186 (if (eq major-mode 'MacEdit-mode) | |
| 1187 (MacEdit-cancel-edit) | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1188 (if (and interactive |
| 40785 | 1189 calc-embedded-info |
| 1190 (eq (current-buffer) (aref calc-embedded-info 0))) | |
| 1191 (calc-embedded nil) | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1192 (unless (eq major-mode 'calc-mode) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1193 (calc-create-buffer)) |
| 40785 | 1194 (run-hooks 'calc-end-hook) |
| 1195 (setq calc-undo-list nil calc-redo-list nil) | |
| 1196 (mapcar (function (lambda (v) (set-default v (symbol-value v)))) | |
| 1197 calc-local-var-list) | |
| 1198 (let ((buf (current-buffer)) | |
| 1199 (win (get-buffer-window (current-buffer))) | |
| 1200 (kbuf (get-buffer "*Calc Keypad*"))) | |
| 1201 (delete-windows-on (calc-trail-buffer)) | |
| 1202 (if (and win | |
|
40999
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
1203 (< (window-height win) (1- (frame-height))) |
|
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
1204 (= (window-width win) (frame-width)) ; avoid calc-keypad |
| 40785 | 1205 (not (get-buffer-window "*Calc Keypad*"))) |
| 1206 (setq calc-window-height (- (window-height win) 2))) | |
|
44247
b50c25ecef92
(calc-was-split): Var deleted.
Colin Walters <walters@gnu.org>
parents:
43185
diff
changeset
|
1207 (progn |
| 40785 | 1208 (delete-windows-on buf) |
| 1209 (delete-windows-on kbuf)) | |
| 1210 (bury-buffer buf) | |
| 1211 (bury-buffer calc-trail-buffer) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1212 (and kbuf (bury-buffer kbuf))))))) |
| 40785 | 1213 |
| 1214 ;;;###autoload | |
| 1215 (defun quick-calc () | |
| 1216 "Do a quick calculation in the minibuffer without invoking full Calculator." | |
| 1217 (interactive) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1218 (calc-do-quick-calc)) |
| 40785 | 1219 |
| 1220 ;;;###autoload | |
| 1221 (defun calc-eval (str &optional separator &rest args) | |
| 1222 "Do a quick calculation and return the result as a string. | |
| 1223 Return value will either be the formatted result in string form, | |
| 1224 or a list containing a character position and an error message in string form." | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1225 (calc-do-calc-eval str separator args)) |
| 40785 | 1226 |
| 1227 ;;;###autoload | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1228 (defun calc-keypad (&optional interactive) |
| 40785 | 1229 "Invoke the Calculator in \"visual keypad\" mode. |
| 1230 This is most useful in the X window system. | |
| 1231 In this mode, click on the Calc \"buttons\" using the left mouse button. | |
| 1232 Or, position the cursor manually and do M-x calc-keypad-press." | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1233 (interactive "p") |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1234 (require 'calc-ext) |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1235 (calc-do-keypad calc-full-mode interactive)) |
| 40785 | 1236 |
| 1237 ;;;###autoload | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1238 (defun full-calc-keypad (&optional interactive) |
| 40785 | 1239 "Invoke the Calculator in full-screen \"visual keypad\" mode. |
| 1240 See calc-keypad for details." | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1241 (interactive "p") |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1242 (require 'calc-ext) |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1243 (calc-do-keypad t interactive)) |
| 40785 | 1244 |
| 1245 | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1246 (defvar calc-aborted-prefix nil) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1247 (defvar calc-start-time nil) |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1248 (defvar calc-command-flags) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1249 (defvar calc-final-point-line) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1250 (defvar calc-final-point-column) |
| 40785 | 1251 ;;; Note that modifications to this function may break calc-pass-errors. |
| 1252 (defun calc-do (do-body &optional do-slow) | |
| 1253 (calc-check-defines) | |
| 1254 (let* ((calc-command-flags nil) | |
| 1255 (calc-start-time (and calc-timing (not calc-start-time) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1256 (require 'calc-ext) |
| 40785 | 1257 (current-time-string))) |
| 1258 (gc-cons-threshold (max gc-cons-threshold | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1259 (if calc-timing 2000000 100000))) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1260 calc-final-point-line calc-final-point-column) |
| 40785 | 1261 (setq calc-aborted-prefix "") |
| 1262 (unwind-protect | |
| 1263 (condition-case err | |
| 1264 (save-excursion | |
| 1265 (if calc-embedded-info | |
| 1266 (calc-embedded-select-buffer) | |
| 1267 (calc-select-buffer)) | |
| 1268 (and (eq calc-algebraic-mode 'total) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1269 (require 'calc-ext) |
| 40785 | 1270 (use-local-map calc-alg-map)) |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1271 (when (and do-slow calc-display-working-message) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1272 (message "Working...") |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1273 (calc-set-command-flag 'clear-message)) |
| 40785 | 1274 (funcall do-body) |
| 1275 (setq calc-aborted-prefix nil) | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1276 (when (memq 'renum-stack calc-command-flags) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1277 (calc-renumber-stack)) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1278 (when (memq 'clear-message calc-command-flags) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1279 (message ""))) |
| 40785 | 1280 (error |
| 1281 (if (and (eq (car err) 'error) | |
| 1282 (stringp (nth 1 err)) | |
| 1283 (string-match "max-specpdl-size\\|max-lisp-eval-depth" | |
| 1284 (nth 1 err))) | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1285 (error "Computation got stuck or ran too long. Type `M' to increase the limit") |
| 40785 | 1286 (setq calc-aborted-prefix nil) |
| 1287 (signal (car err) (cdr err))))) | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1288 (when calc-aborted-prefix |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1289 (calc-record "<Aborted>" calc-aborted-prefix)) |
| 40785 | 1290 (and calc-start-time |
| 1291 (let* ((calc-internal-prec 12) | |
| 1292 (calc-date-format nil) | |
| 1293 (end-time (current-time-string)) | |
| 1294 (time (if (equal calc-start-time end-time) | |
| 1295 0 | |
| 1296 (math-sub | |
| 1297 (calcFunc-unixtime (math-parse-date end-time) 0) | |
| 1298 (calcFunc-unixtime (math-parse-date calc-start-time) | |
| 1299 0))))) | |
| 1300 (if (math-lessp 1 time) | |
| 1301 (calc-record time "(t)")))) | |
| 1302 (or (memq 'no-align calc-command-flags) | |
| 1303 (eq major-mode 'calc-trail-mode) | |
| 1304 (calc-align-stack-window)) | |
| 1305 (and (memq 'position-point calc-command-flags) | |
| 1306 (if (eq major-mode 'calc-mode) | |
| 1307 (progn | |
| 1308 (goto-line calc-final-point-line) | |
| 1309 (move-to-column calc-final-point-column)) | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1310 (save-current-buffer |
| 40785 | 1311 (calc-select-buffer) |
| 1312 (goto-line calc-final-point-line) | |
| 1313 (move-to-column calc-final-point-column)))) | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1314 (unless (memq 'keep-flags calc-command-flags) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1315 (save-excursion |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1316 (calc-select-buffer) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1317 (setq calc-inverse-flag nil |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1318 calc-hyperbolic-flag nil |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1319 calc-keep-args-flag nil))) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1320 (when (memq 'do-edit calc-command-flags) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1321 (switch-to-buffer (get-buffer-create "*Calc Edit*"))) |
| 40785 | 1322 (calc-set-mode-line) |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1323 (when calc-embedded-info |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1324 (calc-embedded-finish-command)))) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1325 (identity nil)) ; allow a GC after timing is done |
|
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1326 |
| 40785 | 1327 |
| 1328 (defun calc-set-command-flag (f) | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1329 (unless (memq f calc-command-flags) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1330 (setq calc-command-flags (cons f calc-command-flags)))) |
| 40785 | 1331 |
| 1332 (defun calc-select-buffer () | |
| 1333 (or (eq major-mode 'calc-mode) | |
| 1334 (if calc-main-buffer | |
| 1335 (set-buffer calc-main-buffer) | |
| 1336 (let ((buf (get-buffer "*Calculator*"))) | |
| 1337 (if buf | |
| 1338 (set-buffer buf) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1339 (error "Calculator buffer not available")))))) |
| 40785 | 1340 |
| 1341 (defun calc-cursor-stack-index (&optional index) | |
| 1342 (goto-char (point-max)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1343 (forward-line (- (calc-substack-height (or index 1))))) |
| 40785 | 1344 |
| 1345 (defun calc-stack-size () | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1346 (- (length calc-stack) calc-stack-top)) |
| 40785 | 1347 |
| 1348 (defun calc-substack-height (n) | |
| 1349 (let ((sum 0) | |
| 1350 (stack calc-stack)) | |
| 1351 (setq n (+ n calc-stack-top)) | |
| 1352 (while (and (> n 0) stack) | |
| 1353 (setq sum (+ sum (nth 1 (car stack))) | |
| 1354 n (1- n) | |
| 1355 stack (cdr stack))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1356 sum)) |
| 40785 | 1357 |
| 1358 (defun calc-set-mode-line () | |
| 1359 (save-excursion | |
| 1360 (calc-select-buffer) | |
| 1361 (let* ((fmt (car calc-float-format)) | |
| 1362 (figs (nth 1 calc-float-format)) | |
| 1363 (new-mode-string | |
| 1364 (format "Calc%s%s: %d %s %-14s" | |
| 1365 (if calc-embedded-info "Embed" "") | |
| 1366 (if (and (> (length (buffer-name)) 12) | |
| 1367 (equal (substring (buffer-name) 0 12) | |
| 1368 "*Calculator*")) | |
| 1369 (substring (buffer-name) 12) | |
| 1370 "") | |
| 1371 calc-internal-prec | |
| 1372 (capitalize (symbol-name calc-angle-mode)) | |
| 1373 (concat | |
| 1374 | |
| 1375 ;; Input-related modes | |
| 1376 (if (eq calc-algebraic-mode 'total) "Alg* " | |
| 1377 (if calc-algebraic-mode "Alg " | |
| 1378 (if calc-incomplete-algebraic-mode "Alg[( " ""))) | |
| 1379 | |
| 1380 ;; Computational modes | |
| 1381 (if calc-symbolic-mode "Symb " "") | |
| 1382 (cond ((eq calc-matrix-mode 'matrix) "Matrix ") | |
| 1383 ((integerp calc-matrix-mode) | |
| 1384 (format "Matrix%d " calc-matrix-mode)) | |
| 1385 ((eq calc-matrix-mode 'scalar) "Scalar ") | |
| 1386 (t "")) | |
| 1387 (if (eq calc-complex-mode 'polar) "Polar " "") | |
| 1388 (if calc-prefer-frac "Frac " "") | |
| 1389 (cond ((null calc-infinite-mode) "") | |
| 1390 ((eq calc-infinite-mode 1) "+Inf ") | |
| 1391 (t "Inf ")) | |
| 1392 (cond ((eq calc-simplify-mode 'none) "NoSimp ") | |
| 1393 ((eq calc-simplify-mode 'num) "NumSimp ") | |
| 1394 ((eq calc-simplify-mode 'binary) | |
| 1395 (format "BinSimp%d " calc-word-size)) | |
| 1396 ((eq calc-simplify-mode 'alg) "AlgSimp ") | |
| 1397 ((eq calc-simplify-mode 'ext) "ExtSimp ") | |
| 1398 ((eq calc-simplify-mode 'units) "UnitSimp ") | |
| 1399 (t "")) | |
| 1400 | |
| 1401 ;; Display modes | |
| 1402 (cond ((= calc-number-radix 10) "") | |
| 1403 ((= calc-number-radix 2) "Bin ") | |
| 1404 ((= calc-number-radix 8) "Oct ") | |
| 1405 ((= calc-number-radix 16) "Hex ") | |
| 1406 (t (format "Radix%d " calc-number-radix))) | |
| 1407 (if calc-leading-zeros "Zero " "") | |
| 1408 (cond ((null calc-language) "") | |
| 1409 ((eq calc-language 'tex) "TeX ") | |
| 1410 (t (concat | |
| 1411 (capitalize (symbol-name calc-language)) | |
| 1412 " "))) | |
| 1413 (cond ((eq fmt 'float) | |
| 1414 (if (zerop figs) "" (format "Norm%d " figs))) | |
| 1415 ((eq fmt 'fix) (format "Fix%d " figs)) | |
| 1416 ((eq fmt 'sci) | |
| 1417 (if (zerop figs) "Sci " (format "Sci%d " figs))) | |
| 1418 ((eq fmt 'eng) | |
| 1419 (if (zerop figs) "Eng " (format "Eng%d " figs)))) | |
| 1420 (cond ((not calc-display-just) | |
| 1421 (if calc-display-origin | |
| 1422 (format "Left%d " calc-display-origin) "")) | |
| 1423 ((eq calc-display-just 'right) | |
| 1424 (if calc-display-origin | |
| 1425 (format "Right%d " calc-display-origin) | |
| 1426 "Right ")) | |
| 1427 (t | |
| 1428 (if calc-display-origin | |
| 1429 (format "Center%d " calc-display-origin) | |
| 1430 "Center "))) | |
| 1431 (cond ((integerp calc-line-breaking) | |
| 1432 (format "Wid%d " calc-line-breaking)) | |
| 1433 (calc-line-breaking "") | |
| 1434 (t "Wide ")) | |
| 1435 | |
| 1436 ;; Miscellaneous other modes/indicators | |
| 1437 (if calc-assoc-selections "" "Break ") | |
| 1438 (cond ((eq calc-mode-save-mode 'save) "Save ") | |
| 1439 ((not calc-embedded-info) "") | |
| 1440 ((eq calc-mode-save-mode 'local) "Local ") | |
| 1441 ((eq calc-mode-save-mode 'edit) "LocEdit ") | |
| 1442 ((eq calc-mode-save-mode 'perm) "LocPerm ") | |
| 1443 ((eq calc-mode-save-mode 'global) "Global ") | |
| 1444 (t "")) | |
| 1445 (if calc-auto-recompute "" "Manual ") | |
| 1446 (if (and (fboundp 'calc-gnuplot-alive) | |
| 1447 (calc-gnuplot-alive)) "Graph " "") | |
| 1448 (if (and calc-embedded-info | |
| 1449 (> (calc-stack-size) 0) | |
| 1450 (calc-top 1 'sel)) "Sel " "") | |
| 1451 (if calc-display-dirty "Dirty " "") | |
| 1452 (if calc-inverse-flag "Inv " "") | |
| 1453 (if calc-hyperbolic-flag "Hyp " "") | |
| 1454 (if calc-keep-args-flag "Keep " "") | |
| 1455 (if (/= calc-stack-top 1) "Narrow " "") | |
| 1456 (apply 'concat calc-other-modes))))) | |
| 1457 (if (equal new-mode-string mode-line-buffer-identification) | |
| 1458 nil | |
| 1459 (setq mode-line-buffer-identification new-mode-string) | |
| 1460 (set-buffer-modified-p (buffer-modified-p)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1461 (and calc-embedded-info (calc-embedded-mode-line-change)))))) |
| 40785 | 1462 |
| 1463 (defun calc-align-stack-window () | |
| 1464 (if (eq major-mode 'calc-mode) | |
| 1465 (progn | |
| 1466 (let ((win (get-buffer-window (current-buffer)))) | |
| 1467 (if win | |
| 1468 (progn | |
| 1469 (calc-cursor-stack-index 0) | |
| 1470 (vertical-motion (- 2 (window-height win))) | |
| 1471 (set-window-start win (point))))) | |
| 1472 (calc-cursor-stack-index 0) | |
| 1473 (if (looking-at " *\\.$") | |
| 1474 (goto-char (1- (match-end 0))))) | |
| 1475 (save-excursion | |
| 1476 (calc-select-buffer) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1477 (calc-align-stack-window)))) |
| 40785 | 1478 |
| 1479 (defun calc-check-stack (n) | |
| 1480 (if (> n (calc-stack-size)) | |
| 1481 (error "Too few elements on stack")) | |
| 1482 (if (< n 0) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1483 (error "Invalid argument"))) |
| 40785 | 1484 |
| 1485 (defun calc-push-list (vals &optional m sels) | |
| 1486 (while vals | |
| 1487 (if calc-executing-macro | |
| 1488 (calc-push-list-in-macro vals m sels) | |
| 1489 (save-excursion | |
| 1490 (calc-select-buffer) | |
| 1491 (let* ((val (car vals)) | |
| 1492 (entry (list val 1 (car sels))) | |
| 1493 (mm (+ (or m 1) calc-stack-top))) | |
| 1494 (calc-cursor-stack-index (1- (or m 1))) | |
| 1495 (if (> mm 1) | |
| 1496 (setcdr (nthcdr (- mm 2) calc-stack) | |
| 1497 (cons entry (nthcdr (1- mm) calc-stack))) | |
| 1498 (setq calc-stack (cons entry calc-stack))) | |
| 1499 (let ((buffer-read-only nil)) | |
| 1500 (insert (math-format-stack-value entry) "\n")) | |
| 1501 (calc-record-undo (list 'push mm)) | |
| 1502 (calc-set-command-flag 'renum-stack)))) | |
| 1503 (setq vals (cdr vals) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1504 sels (cdr sels)))) |
| 40785 | 1505 |
| 1506 (defun calc-pop-push-list (n vals &optional m sels) | |
| 1507 (if (and calc-any-selections (null sels)) | |
| 1508 (calc-replace-selections n vals m) | |
| 1509 (calc-pop-stack n m sels) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1510 (calc-push-list vals m sels))) |
| 40785 | 1511 |
| 1512 (defun calc-pop-push-record-list (n prefix vals &optional m sels) | |
| 1513 (or (and (consp vals) | |
| 1514 (or (integerp (car vals)) | |
| 1515 (consp (car vals)))) | |
| 1516 (and vals (setq vals (list vals) | |
| 1517 sels (and sels (list sels))))) | |
| 1518 (calc-check-stack (+ n (or m 1) -1)) | |
| 1519 (if prefix | |
| 1520 (if (cdr vals) | |
| 1521 (calc-record-list vals prefix) | |
| 1522 (calc-record (car vals) prefix))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1523 (calc-pop-push-list n vals m sels)) |
| 40785 | 1524 |
| 1525 (defun calc-enter-result (n prefix vals &optional m) | |
| 1526 (setq calc-aborted-prefix prefix) | |
| 1527 (if (and (consp vals) | |
| 1528 (or (integerp (car vals)) | |
| 1529 (consp (car vals)))) | |
| 1530 (setq vals (mapcar 'calc-normalize vals)) | |
| 1531 (setq vals (calc-normalize vals))) | |
| 1532 (or (and (consp vals) | |
| 1533 (or (integerp (car vals)) | |
| 1534 (consp (car vals)))) | |
| 1535 (setq vals (list vals))) | |
| 1536 (if (equal vals '((nil))) | |
| 1537 (setq vals nil)) | |
| 1538 (calc-pop-push-record-list n prefix vals m) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1539 (calc-handle-whys)) |
| 40785 | 1540 |
| 1541 (defun calc-normalize (val) | |
| 1542 (if (memq calc-simplify-mode '(nil none num)) | |
| 1543 (math-normalize val) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1544 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1545 (calc-normalize-fancy val))) |
| 40785 | 1546 |
| 1547 (defun calc-handle-whys () | |
| 1548 (if calc-next-why | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1549 (calc-do-handle-whys))) |
| 40785 | 1550 |
| 1551 | |
| 1552 (defun calc-pop-stack (&optional n m sel-ok) ; pop N objs at level M of stack. | |
| 1553 (or n (setq n 1)) | |
| 1554 (or m (setq m 1)) | |
| 1555 (or calc-keep-args-flag | |
| 1556 (let ((mm (+ m calc-stack-top))) | |
| 1557 (if (and calc-any-selections (not sel-ok) | |
| 1558 (calc-top-selected n m)) | |
| 1559 (calc-sel-error)) | |
| 1560 (if calc-executing-macro | |
| 1561 (calc-pop-stack-in-macro n mm) | |
| 1562 (calc-record-undo (list 'pop mm (calc-top-list n m 'full))) | |
| 1563 (save-excursion | |
| 1564 (calc-select-buffer) | |
| 1565 (let ((buffer-read-only nil)) | |
| 1566 (if (> mm 1) | |
| 1567 (progn | |
| 1568 (calc-cursor-stack-index (1- m)) | |
| 1569 (let ((bot (point))) | |
| 1570 (calc-cursor-stack-index (+ n m -1)) | |
| 1571 (delete-region (point) bot)) | |
| 1572 (setcdr (nthcdr (- mm 2) calc-stack) | |
| 1573 (nthcdr (+ n mm -1) calc-stack))) | |
| 1574 (calc-cursor-stack-index n) | |
| 1575 (setq calc-stack (nthcdr n calc-stack)) | |
| 1576 (delete-region (point) (point-max)))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1577 (calc-set-command-flag 'renum-stack)))))) |
| 40785 | 1578 |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1579 (defvar sel-mode) |
| 40785 | 1580 (defun calc-get-stack-element (x) |
| 1581 (cond ((eq sel-mode 'entry) | |
| 1582 x) | |
| 1583 ((eq sel-mode 'sel) | |
| 1584 (nth 2 x)) | |
| 1585 ((or (null (nth 2 x)) | |
| 1586 (eq sel-mode 'full) | |
| 1587 (not calc-use-selections)) | |
| 1588 (car x)) | |
| 1589 (sel-mode | |
| 1590 (calc-sel-error)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1591 (t (nth 2 x)))) |
| 40785 | 1592 |
| 1593 ;; Get the Nth element of the stack (N=1 is the top element). | |
| 1594 (defun calc-top (&optional n sel-mode) | |
| 1595 (or n (setq n 1)) | |
| 1596 (calc-check-stack n) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1597 (calc-get-stack-element (nth (+ n calc-stack-top -1) calc-stack))) |
| 40785 | 1598 |
| 1599 (defun calc-top-n (&optional n sel-mode) ; in case precision has changed | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1600 (math-check-complete (calc-normalize (calc-top n sel-mode)))) |
| 40785 | 1601 |
| 1602 (defun calc-top-list (&optional n m sel-mode) | |
| 1603 (or n (setq n 1)) | |
| 1604 (or m (setq m 1)) | |
| 1605 (calc-check-stack (+ n m -1)) | |
| 1606 (and (> n 0) | |
| 1607 (let ((top (copy-sequence (nthcdr (+ m calc-stack-top -1) | |
| 1608 calc-stack)))) | |
| 1609 (setcdr (nthcdr (1- n) top) nil) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1610 (nreverse (mapcar 'calc-get-stack-element top))))) |
| 40785 | 1611 |
| 1612 (defun calc-top-list-n (&optional n m sel-mode) | |
| 1613 (mapcar 'math-check-complete | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1614 (mapcar 'calc-normalize (calc-top-list n m sel-mode)))) |
| 40785 | 1615 |
| 1616 | |
| 1617 (defun calc-renumber-stack () | |
| 1618 (if calc-line-numbering | |
| 1619 (save-excursion | |
| 1620 (calc-cursor-stack-index 0) | |
| 1621 (let ((lnum 1) | |
| 1622 (buffer-read-only nil) | |
| 1623 (stack (nthcdr calc-stack-top calc-stack))) | |
| 1624 (if (re-search-forward "^[0-9]+[:*]" nil t) | |
| 1625 (progn | |
| 1626 (beginning-of-line) | |
| 1627 (while (re-search-forward "^[0-9]+[:*]" nil t) | |
| 1628 (let ((buffer-read-only nil)) | |
| 1629 (beginning-of-line) | |
| 1630 (delete-char 4) | |
| 1631 (insert " "))) | |
| 1632 (calc-cursor-stack-index 0))) | |
| 1633 (while (re-search-backward "^[0-9]+[:*]" nil t) | |
| 1634 (delete-char 4) | |
| 1635 (if (> lnum 999) | |
| 1636 (insert (format "%03d%s" (% lnum 1000) | |
| 1637 (if (and (nth 2 (car stack)) | |
| 1638 calc-use-selections) "*" ":"))) | |
| 1639 (let ((prefix (int-to-string lnum))) | |
| 1640 (insert prefix (if (and (nth 2 (car stack)) | |
| 1641 calc-use-selections) "*" ":") | |
| 1642 (make-string (- 3 (length prefix)) 32)))) | |
| 1643 (beginning-of-line) | |
| 1644 (setq lnum (1+ lnum) | |
| 1645 stack (cdr stack)))))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1646 (and calc-embedded-info (calc-embedded-stack-change))) |
| 40785 | 1647 |
|
48055
dd72f9547abd
(calc-any-evaltos): Initialize to nil, since
David Kastrup <dak@gnu.org>
parents:
47682
diff
changeset
|
1648 (defvar calc-any-evaltos nil) |
| 40785 | 1649 (defun calc-refresh (&optional align) |
| 1650 (interactive) | |
| 1651 (and (eq major-mode 'calc-mode) | |
| 1652 (not calc-executing-macro) | |
| 1653 (let* ((buffer-read-only nil) | |
| 1654 (save-point (point)) | |
| 1655 (save-mark (condition-case err (mark) (error nil))) | |
| 1656 (save-aligned (looking-at "\\.$")) | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1657 (thing calc-stack) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1658 (calc-any-evaltos nil)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1659 (setq calc-any-selections nil) |
| 40785 | 1660 (erase-buffer) |
|
45578
73f6b3b88ae9
(calc-show-banner): New variable.
Miles Bader <miles@gnu.org>
parents:
44574
diff
changeset
|
1661 (when calc-show-banner |
| 45769 | 1662 (insert (propertize "--- Emacs Calculator Mode ---\n" |
| 1663 'font-lock-face 'italic))) | |
| 40785 | 1664 (while thing |
| 1665 (goto-char (point-min)) | |
|
45578
73f6b3b88ae9
(calc-show-banner): New variable.
Miles Bader <miles@gnu.org>
parents:
44574
diff
changeset
|
1666 (when calc-show-banner |
|
73f6b3b88ae9
(calc-show-banner): New variable.
Miles Bader <miles@gnu.org>
parents:
44574
diff
changeset
|
1667 (forward-line 1)) |
| 40785 | 1668 (insert (math-format-stack-value (car thing)) "\n") |
| 1669 (setq thing (cdr thing))) | |
| 1670 (calc-renumber-stack) | |
| 1671 (if calc-display-dirty | |
| 1672 (calc-wrapper (setq calc-display-dirty nil))) | |
| 1673 (and calc-any-evaltos calc-auto-recompute | |
| 1674 (calc-wrapper (calc-refresh-evaltos))) | |
| 1675 (if (or align save-aligned) | |
| 1676 (calc-align-stack-window) | |
| 1677 (goto-char save-point)) | |
| 1678 (if save-mark (set-mark save-mark)))) | |
| 1679 (and calc-embedded-info (not (eq major-mode 'calc-mode)) | |
| 1680 (save-excursion | |
| 1681 (set-buffer (aref calc-embedded-info 1)) | |
| 1682 (calc-refresh align))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1683 (setq calc-refresh-count (1+ calc-refresh-count))) |
| 40785 | 1684 |
| 1685 ;;;; The Calc Trail buffer. | |
| 1686 | |
| 1687 (defun calc-check-trail-aligned () | |
| 1688 (save-excursion | |
| 1689 (let ((win (get-buffer-window (current-buffer)))) | |
| 1690 (and win | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1691 (pos-visible-in-window-p (1- (point-max)) win))))) |
| 40785 | 1692 |
| 1693 (defun calc-trail-buffer () | |
| 1694 (and (or (null calc-trail-buffer) | |
| 1695 (null (buffer-name calc-trail-buffer))) | |
| 1696 (save-excursion | |
| 1697 (setq calc-trail-buffer (get-buffer-create "*Calc Trail*")) | |
| 1698 (let ((buf (or (and (not (eq major-mode 'calc-mode)) | |
| 1699 (get-buffer "*Calculator*")) | |
| 1700 (current-buffer)))) | |
| 1701 (set-buffer calc-trail-buffer) | |
| 1702 (or (eq major-mode 'calc-trail-mode) | |
| 1703 (calc-trail-mode buf))))) | |
| 1704 (or (and calc-trail-pointer | |
| 1705 (eq (marker-buffer calc-trail-pointer) calc-trail-buffer)) | |
| 1706 (save-excursion | |
| 1707 (set-buffer calc-trail-buffer) | |
| 1708 (goto-line 2) | |
| 1709 (setq calc-trail-pointer (point-marker)))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1710 calc-trail-buffer) |
| 40785 | 1711 |
| 1712 (defun calc-record (val &optional prefix) | |
| 1713 (setq calc-aborted-prefix nil) | |
| 1714 (or calc-executing-macro | |
| 1715 (let* ((mainbuf (current-buffer)) | |
| 1716 (buf (calc-trail-buffer)) | |
| 1717 (calc-display-raw nil) | |
| 1718 (calc-can-abbrev-vectors t) | |
| 1719 (fval (if val | |
| 1720 (if (stringp val) | |
| 1721 val | |
| 1722 (math-showing-full-precision | |
| 1723 (math-format-flat-expr val 0))) | |
| 1724 ""))) | |
| 1725 (save-excursion | |
| 1726 (set-buffer buf) | |
| 1727 (let ((aligned (calc-check-trail-aligned)) | |
| 1728 (buffer-read-only nil)) | |
| 1729 (goto-char (point-max)) | |
| 1730 (cond ((null prefix) (insert " ")) | |
| 1731 ((and (> (length prefix) 4) | |
| 1732 (string-match " " prefix 4)) | |
| 1733 (insert (substring prefix 0 4) " ")) | |
| 1734 (t (insert (format "%4s " prefix)))) | |
| 1735 (insert fval "\n") | |
| 1736 (let ((win (get-buffer-window buf))) | |
| 1737 (if (and aligned win (not (memq 'hold-trail calc-command-flags))) | |
| 1738 (calc-trail-here)) | |
| 1739 (goto-char (1- (point-max)))))))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1740 val) |
| 40785 | 1741 |
| 1742 | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1743 (defun calc-trail-display (flag &optional no-refresh interactive) |
|
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1744 (interactive "P\ni\np") |
| 40785 | 1745 (let ((win (get-buffer-window (calc-trail-buffer)))) |
| 1746 (if (setq calc-display-trail | |
| 1747 (not (if flag (memq flag '(nil 0)) win))) | |
| 1748 (if (null win) | |
| 1749 (progn | |
|
58061
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1750 (let ((w (split-window nil (/ (* (window-width) 2) 3) t))) |
|
3f48c4fde605
(calc-mode-hook, calc-trail-mode-hook, calc-start-hook, calc-end-hook)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57710
diff
changeset
|
1751 (set-window-buffer w calc-trail-buffer)) |
| 40785 | 1752 (calc-wrapper |
| 1753 (setq overlay-arrow-string calc-trail-overlay | |
| 1754 overlay-arrow-position calc-trail-pointer) | |
| 1755 (or no-refresh | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1756 (if interactive |
| 40785 | 1757 (calc-do-refresh) |
| 1758 (calc-refresh)))))) | |
| 1759 (if win | |
| 1760 (progn | |
| 1761 (delete-window win) | |
| 1762 (calc-wrapper | |
| 1763 (or no-refresh | |
|
57710
a18ff071e655
(calc,full-calc, calc-quit, calc-keypad, full-calc-keypad)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57591
diff
changeset
|
1764 (if interactive |
| 40785 | 1765 (calc-do-refresh) |
| 1766 (calc-refresh)))))))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1767 calc-trail-buffer) |
| 40785 | 1768 |
| 1769 (defun calc-trail-here () | |
| 1770 (interactive) | |
| 1771 (if (eq major-mode 'calc-trail-mode) | |
| 1772 (progn | |
| 1773 (beginning-of-line) | |
| 1774 (if (bobp) | |
| 1775 (forward-line 1) | |
| 1776 (if (eobp) | |
| 1777 (forward-line -1))) | |
| 1778 (if (or (bobp) (eobp)) | |
| 1779 (setq overlay-arrow-position nil) ; trail is empty | |
| 1780 (set-marker calc-trail-pointer (point) (current-buffer)) | |
| 1781 (setq calc-trail-overlay (concat (buffer-substring (point) | |
| 1782 (+ (point) 4)) | |
| 1783 ">") | |
| 1784 overlay-arrow-string calc-trail-overlay | |
| 1785 overlay-arrow-position calc-trail-pointer) | |
| 1786 (forward-char 4) | |
| 1787 (let ((win (get-buffer-window (current-buffer)))) | |
| 1788 (if win | |
| 1789 (save-excursion | |
| 1790 (forward-line (/ (window-height win) 2)) | |
| 1791 (forward-line (- 1 (window-height win))) | |
| 1792 (set-window-start win (point)) | |
| 1793 (set-window-point win (+ calc-trail-pointer 4)) | |
| 1794 (set-buffer calc-main-buffer) | |
| 1795 (setq overlay-arrow-string calc-trail-overlay | |
| 1796 overlay-arrow-position calc-trail-pointer)))))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1797 (error "Not in Calc Trail buffer"))) |
| 40785 | 1798 |
| 1799 | |
| 1800 | |
| 1801 | |
| 1802 ;;;; The Undo list. | |
| 1803 | |
| 1804 (defun calc-record-undo (rec) | |
| 1805 (or calc-executing-macro | |
| 1806 (if (memq 'undo calc-command-flags) | |
| 1807 (setq calc-undo-list (cons (cons rec (car calc-undo-list)) | |
| 1808 (cdr calc-undo-list))) | |
| 1809 (setq calc-undo-list (cons (list rec) calc-undo-list) | |
| 1810 calc-redo-list nil) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1811 (calc-set-command-flag 'undo)))) |
| 40785 | 1812 |
| 1813 | |
| 1814 | |
| 1815 | |
| 1816 ;;; Arithmetic commands. | |
| 1817 | |
| 1818 (defun calc-binary-op (name func arg &optional ident unary func2) | |
| 1819 (setq calc-aborted-prefix name) | |
| 1820 (if (null arg) | |
| 1821 (calc-enter-result 2 name (cons (or func2 func) | |
| 1822 (mapcar 'math-check-complete | |
| 1823 (calc-top-list 2)))) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1824 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1825 (calc-binary-op-fancy name func arg ident unary))) |
| 40785 | 1826 |
| 1827 (defun calc-unary-op (name func arg &optional func2) | |
| 1828 (setq calc-aborted-prefix name) | |
| 1829 (if (null arg) | |
| 1830 (calc-enter-result 1 name (list (or func2 func) | |
| 1831 (math-check-complete (calc-top 1)))) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1832 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1833 (calc-unary-op-fancy name func arg))) |
| 40785 | 1834 |
| 1835 | |
| 1836 (defun calc-plus (arg) | |
| 1837 (interactive "P") | |
| 1838 (calc-slow-wrapper | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1839 (calc-binary-op "+" 'calcFunc-add arg 0 nil '+))) |
| 40785 | 1840 |
| 1841 (defun calc-minus (arg) | |
| 1842 (interactive "P") | |
| 1843 (calc-slow-wrapper | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1844 (calc-binary-op "-" 'calcFunc-sub arg 0 'neg '-))) |
| 40785 | 1845 |
| 1846 (defun calc-times (arg) | |
| 1847 (interactive "P") | |
| 1848 (calc-slow-wrapper | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1849 (calc-binary-op "*" 'calcFunc-mul arg 1 nil '*))) |
| 40785 | 1850 |
| 1851 (defun calc-divide (arg) | |
| 1852 (interactive "P") | |
| 1853 (calc-slow-wrapper | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1854 (calc-binary-op "/" 'calcFunc-div arg 0 'calcFunc-inv '/))) |
| 40785 | 1855 |
| 1856 | |
| 1857 (defun calc-change-sign (arg) | |
| 1858 (interactive "P") | |
| 1859 (calc-wrapper | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1860 (calc-unary-op "chs" 'neg arg))) |
| 40785 | 1861 |
| 1862 | |
| 1863 | |
| 1864 ;;; Stack management commands. | |
| 1865 | |
| 1866 (defun calc-enter (n) | |
| 1867 (interactive "p") | |
| 1868 (calc-wrapper | |
| 1869 (cond ((< n 0) | |
| 1870 (calc-push-list (calc-top-list 1 (- n)))) | |
| 1871 ((= n 0) | |
| 1872 (calc-push-list (calc-top-list (calc-stack-size)))) | |
| 1873 (t | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1874 (calc-push-list (calc-top-list n)))))) |
| 40785 | 1875 |
| 1876 | |
| 1877 (defun calc-pop (n) | |
| 1878 (interactive "P") | |
| 1879 (calc-wrapper | |
| 1880 (let* ((nn (prefix-numeric-value n)) | |
| 1881 (top (and (null n) (calc-top 1)))) | |
| 1882 (cond ((and (null n) | |
| 1883 (eq (car-safe top) 'incomplete) | |
| 1884 (> (length top) (if (eq (nth 1 top) 'intv) 3 2))) | |
| 1885 (calc-pop-push-list 1 (let ((tt (copy-sequence top))) | |
| 1886 (setcdr (nthcdr (- (length tt) 2) tt) nil) | |
| 1887 (list tt)))) | |
| 1888 ((< nn 0) | |
| 1889 (if (and calc-any-selections | |
| 1890 (calc-top-selected 1 (- nn))) | |
| 1891 (calc-delete-selection (- nn)) | |
| 1892 (calc-pop-stack 1 (- nn) t))) | |
| 1893 ((= nn 0) | |
| 1894 (calc-pop-stack (calc-stack-size) 1 t)) | |
| 1895 (t | |
| 1896 (if (and calc-any-selections | |
| 1897 (= nn 1) | |
| 1898 (calc-top-selected 1 1)) | |
| 1899 (calc-delete-selection 1) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1900 (calc-pop-stack nn))))))) |
| 40785 | 1901 |
| 1902 | |
| 1903 | |
| 1904 | |
| 1905 ;;;; Reading a number using the minibuffer. | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1906 (defvar calc-buffer) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1907 (defvar calc-prev-char) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1908 (defvar calc-prev-prev-char) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
1909 (defvar calc-digit-value) |
| 40785 | 1910 (defun calcDigit-start () |
| 1911 (interactive) | |
| 1912 (calc-wrapper | |
| 1913 (if (or calc-algebraic-mode | |
| 1914 (and (> calc-number-radix 14) (eq last-command-char ?e))) | |
| 1915 (calc-alg-digit-entry) | |
| 1916 (calc-unread-command) | |
| 1917 (setq calc-aborted-prefix nil) | |
| 1918 (let* ((calc-digit-value nil) | |
| 1919 (calc-prev-char nil) | |
| 1920 (calc-prev-prev-char nil) | |
| 1921 (calc-buffer (current-buffer)) | |
| 1922 (buf (if calc-emacs-type-lucid | |
| 1923 (catch 'calc-foo | |
| 1924 (catch 'execute-kbd-macro | |
| 1925 (throw 'calc-foo | |
| 1926 (read-from-minibuffer | |
| 1927 "Calc: " "" calc-digit-map))) | |
| 1928 (error "Lucid Emacs requires RET after %s" | |
| 1929 "digit entry in kbd macro")) | |
| 1930 (let ((old-esc (lookup-key global-map "\e"))) | |
| 1931 (unwind-protect | |
| 1932 (progn | |
| 1933 (define-key global-map "\e" nil) | |
| 1934 (read-from-minibuffer "Calc: " "" calc-digit-map)) | |
| 1935 (define-key global-map "\e" old-esc)))))) | |
| 1936 (or calc-digit-value (setq calc-digit-value (math-read-number buf))) | |
| 1937 (if (stringp calc-digit-value) | |
| 1938 (calc-alg-entry calc-digit-value) | |
| 1939 (if calc-digit-value | |
| 1940 (calc-push-list (list (calc-record (calc-normalize | |
| 1941 calc-digit-value)))))) | |
| 1942 (if (eq calc-prev-char 'dots) | |
| 1943 (progn | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
1944 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1945 (calc-dots))))))) |
| 40785 | 1946 |
|
40911
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
1947 (defsubst calc-minibuffer-size () |
|
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
1948 (- (point-max) (minibuffer-prompt-end))) |
|
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
1949 |
| 40785 | 1950 (defun calcDigit-nondigit () |
| 1951 (interactive) | |
| 1952 ;; Exercise for the reader: Figure out why this is a good precaution! | |
| 1953 (or (boundp 'calc-buffer) | |
| 1954 (use-local-map minibuffer-local-map)) | |
|
40911
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
1955 (let ((str (minibuffer-contents))) |
| 40785 | 1956 (setq calc-digit-value (save-excursion |
| 1957 (set-buffer calc-buffer) | |
| 1958 (math-read-number str)))) | |
|
40911
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
1959 (if (and (null calc-digit-value) (> (calc-minibuffer-size) 0)) |
| 40785 | 1960 (progn |
| 1961 (beep) | |
| 1962 (calc-temp-minibuffer-message " [Bad format]")) | |
| 1963 (or (memq last-command-char '(32 13)) | |
| 1964 (progn (setq prefix-arg current-prefix-arg) | |
| 1965 (calc-unread-command (if (and (eq last-command-char 27) | |
| 1966 (>= last-input-char 128)) | |
| 1967 last-input-char | |
| 1968 nil)))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1969 (exit-minibuffer))) |
| 40785 | 1970 |
| 1971 | |
| 1972 (defun calc-minibuffer-contains (rex) | |
| 1973 (save-excursion | |
|
40911
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
1974 (goto-char (minibuffer-prompt-end)) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
1975 (looking-at rex))) |
| 40785 | 1976 |
| 1977 (defun calcDigit-key () | |
| 1978 (interactive) | |
| 1979 (goto-char (point-max)) | |
| 1980 (if (or (and (memq last-command-char '(?+ ?-)) | |
| 1981 (> (buffer-size) 0) | |
| 1982 (/= (preceding-char) ?e)) | |
| 1983 (and (memq last-command-char '(?m ?s)) | |
| 1984 (not (calc-minibuffer-contains "[-+]?[0-9]+\\.?0*[@oh].*")) | |
| 1985 (not (calc-minibuffer-contains "[-+]?\\(1[1-9]\\|[2-9][0-9]\\)#.*")))) | |
| 1986 (calcDigit-nondigit) | |
| 1987 (if (calc-minibuffer-contains "\\([-+]?\\|.* \\)\\'") | |
| 1988 (cond ((memq last-command-char '(?. ?@)) (insert "0")) | |
| 1989 ((and (memq last-command-char '(?o ?h ?m)) | |
| 1990 (not (calc-minibuffer-contains ".*#.*"))) (insert "0")) | |
| 1991 ((memq last-command-char '(?: ?e)) (insert "1")) | |
| 1992 ((eq last-command-char ?#) | |
| 1993 (insert (int-to-string calc-number-radix))))) | |
| 1994 (if (and (calc-minibuffer-contains "\\([-+]?[0-9]+#\\|[^:]*:\\)\\'") | |
| 1995 (eq last-command-char ?:)) | |
| 1996 (insert "1")) | |
| 1997 (if (and (calc-minibuffer-contains "[-+]?[0-9]+#\\'") | |
| 1998 (eq last-command-char ?.)) | |
| 1999 (insert "0")) | |
| 2000 (if (and (calc-minibuffer-contains "[-+]?0*\\([2-9]\\|1[0-4]\\)#\\'") | |
| 2001 (eq last-command-char ?e)) | |
| 2002 (insert "1")) | |
| 2003 (if (or (and (memq last-command-char '(?h ?o ?m ?s ?p)) | |
| 2004 (calc-minibuffer-contains ".*#.*")) | |
| 2005 (and (eq last-command-char ?e) | |
| 2006 (calc-minibuffer-contains "[-+]?\\(1[5-9]\\|[2-9][0-9]\\)#.*")) | |
| 2007 (and (eq last-command-char ?n) | |
| 2008 (calc-minibuffer-contains "[-+]?\\(2[4-9]\\|[3-9][0-9]\\)#.*"))) | |
| 2009 (setq last-command-char (upcase last-command-char))) | |
| 2010 (cond | |
| 2011 ((memq last-command-char '(?_ ?n)) | |
|
43185
e38061462de6
(calcDigit-key): Use minibuffer-prompt-end instead of point-min.
Andreas Schwab <schwab@suse.de>
parents:
42205
diff
changeset
|
2012 (goto-char (minibuffer-prompt-end)) |
| 40785 | 2013 (if (and (search-forward " +/- " nil t) |
| 2014 (not (search-forward "e" nil t))) | |
| 2015 (beep) | |
| 2016 (and (not (calc-minibuffer-contains "[-+]?\\(1[5-9]\\|[2-9][0-9]\\)#.*")) | |
| 2017 (search-forward "e" nil t)) | |
| 2018 (if (looking-at "+") | |
| 2019 (delete-char 1)) | |
| 2020 (if (looking-at "-") | |
| 2021 (delete-char 1) | |
| 2022 (insert "-"))) | |
| 2023 (goto-char (point-max))) | |
| 2024 ((eq last-command-char ?p) | |
| 2025 (if (or (calc-minibuffer-contains ".*\\+/-.*") | |
| 2026 (calc-minibuffer-contains ".*mod.*") | |
| 2027 (calc-minibuffer-contains ".*#.*") | |
| 2028 (calc-minibuffer-contains ".*[-+e:]\\'")) | |
| 2029 (beep) | |
| 2030 (if (not (calc-minibuffer-contains ".* \\'")) | |
| 2031 (insert " ")) | |
| 2032 (insert "+/- "))) | |
| 2033 ((and (eq last-command-char ?M) | |
| 2034 (not (calc-minibuffer-contains | |
| 2035 "[-+]?\\(2[3-9]\\|[3-9][0-9]\\)#.*"))) | |
| 2036 (if (or (calc-minibuffer-contains ".*\\+/-.*") | |
| 2037 (calc-minibuffer-contains ".*mod *[^ ]+") | |
| 2038 (calc-minibuffer-contains ".*[-+e:]\\'")) | |
| 2039 (beep) | |
| 2040 (if (calc-minibuffer-contains ".*mod \\'") | |
| 2041 (if calc-previous-modulo | |
| 2042 (insert (math-format-flat-expr calc-previous-modulo 0)) | |
| 2043 (beep)) | |
| 2044 (if (not (calc-minibuffer-contains ".* \\'")) | |
| 2045 (insert " ")) | |
| 2046 (insert "mod ")))) | |
| 2047 (t | |
| 2048 (insert (char-to-string last-command-char)) | |
| 2049 (if (or (and (calc-minibuffer-contains "[-+]?\\(.*\\+/- *\\|.*mod *\\)?\\([0-9][0-9]?\\)#[0-9a-zA-Z]*\\(:[0-9a-zA-Z]*\\(:[0-9a-zA-Z]*\\)?\\|.[0-9a-zA-Z]*\\(e[-+]?[0-9]*\\)?\\)?\\'") | |
| 2050 (let ((radix (string-to-int | |
| 2051 (buffer-substring | |
| 2052 (match-beginning 2) (match-end 2))))) | |
| 2053 (and (>= radix 2) | |
| 2054 (<= radix 36) | |
| 2055 (or (memq last-command-char '(?# ?: ?. ?e ?+ ?-)) | |
| 2056 (let ((dig (math-read-radix-digit | |
| 2057 (upcase last-command-char)))) | |
| 2058 (and dig | |
| 2059 (< dig radix))))))) | |
|
40911
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
2060 (calc-minibuffer-contains |
|
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
2061 "[-+]?\\(.*\\+/- *\\|.*mod *\\)?\\([0-9]+\\.?0*[@oh] *\\)?\\([0-9]+\\.?0*['m] *\\)?[0-9]*\\(\\.?[0-9]*\\(e[-+]?[0-3]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?\\)?\\|[0-9]:\\([0-9]+:\\)?[0-9]*\\)?[\"s]?\\'")) |
| 40785 | 2062 (if (and (memq last-command-char '(?@ ?o ?h ?\' ?m)) |
| 2063 (string-match " " calc-hms-format)) | |
| 2064 (insert " ")) | |
| 2065 (if (and (eq this-command last-command) | |
| 2066 (eq last-command-char ?.)) | |
| 2067 (progn | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2068 (require 'calc-ext) |
| 40785 | 2069 (calc-digit-dots)) |
| 2070 (delete-backward-char 1) | |
| 2071 (beep) | |
| 2072 (calc-temp-minibuffer-message " [Bad format]")))))) | |
| 2073 (setq calc-prev-prev-char calc-prev-char | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2074 calc-prev-char last-command-char)) |
| 40785 | 2075 |
| 2076 | |
| 2077 (defun calcDigit-backspace () | |
| 2078 (interactive) | |
| 2079 (goto-char (point-max)) | |
| 2080 (cond ((calc-minibuffer-contains ".* \\+/- \\'") | |
| 2081 (backward-delete-char 5)) | |
| 2082 ((calc-minibuffer-contains ".* mod \\'") | |
| 2083 (backward-delete-char 5)) | |
| 2084 ((calc-minibuffer-contains ".* \\'") | |
| 2085 (backward-delete-char 2)) | |
| 2086 ((eq last-command 'calcDigit-start) | |
| 2087 (erase-buffer)) | |
| 2088 (t (backward-delete-char 1))) | |
|
40911
df97a382ad43
(toplevel): Require calc-macs.
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
2089 (if (= (calc-minibuffer-size) 0) |
| 40785 | 2090 (progn |
| 2091 (setq last-command-char 13) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2092 (calcDigit-nondigit)))) |
| 40785 | 2093 |
| 2094 | |
| 2095 | |
| 2096 | |
| 2097 | |
| 2098 | |
| 2099 | |
| 2100 ;;;; Arithmetic routines. | |
| 2101 ;;; | |
| 2102 ;;; An object as manipulated by one of these routines may take any of the | |
| 2103 ;;; following forms: | |
| 2104 ;;; | |
| 2105 ;;; integer An integer. For normalized numbers, this format | |
| 2106 ;;; is used only for -999999 ... 999999. | |
| 2107 ;;; | |
| 2108 ;;; (bigpos N0 N1 N2 ...) A big positive integer, N0 + N1*1000 + N2*10^6 ... | |
| 2109 ;;; (bigneg N0 N1 N2 ...) A big negative integer, - N0 - N1*1000 ... | |
| 2110 ;;; Each digit N is in the range 0 ... 999. | |
| 2111 ;;; Normalized, always at least three N present, | |
| 2112 ;;; and the most significant N is nonzero. | |
| 2113 ;;; | |
| 2114 ;;; (frac NUM DEN) A fraction. NUM and DEN are small or big integers. | |
| 2115 ;;; Normalized, DEN > 1. | |
| 2116 ;;; | |
| 2117 ;;; (float NUM EXP) A floating-point number, NUM * 10^EXP; | |
| 2118 ;;; NUM is a small or big integer, EXP is a small int. | |
| 2119 ;;; Normalized, NUM is not a multiple of 10, and | |
| 2120 ;;; abs(NUM) < 10^calc-internal-prec. | |
| 2121 ;;; Normalized zero is stored as (float 0 0). | |
| 2122 ;;; | |
| 2123 ;;; (cplx REAL IMAG) A complex number; REAL and IMAG are any of above. | |
| 2124 ;;; Normalized, IMAG is nonzero. | |
| 2125 ;;; | |
| 2126 ;;; (polar R THETA) Polar complex number. Normalized, R > 0 and THETA | |
| 2127 ;;; is neither zero nor 180 degrees (pi radians). | |
| 2128 ;;; | |
| 2129 ;;; (vec A B C ...) Vector of objects A, B, C, ... A matrix is a | |
| 2130 ;;; vector of vectors. | |
| 2131 ;;; | |
| 2132 ;;; (hms H M S) Angle in hours-minutes-seconds form. All three | |
| 2133 ;;; components have the same sign; H and M must be | |
| 2134 ;;; numerically integers; M and S are expected to | |
| 2135 ;;; lie in the range [0,60). | |
| 2136 ;;; | |
| 2137 ;;; (date N) A date or date/time object. N is an integer to | |
| 2138 ;;; store a date only, or a fraction or float to | |
| 2139 ;;; store a date and time. | |
| 2140 ;;; | |
| 2141 ;;; (sdev X SIGMA) Error form, X +/- SIGMA. When normalized, | |
| 2142 ;;; SIGMA > 0. X is any complex number and SIGMA | |
| 2143 ;;; is real numbers; or these may be symbolic | |
| 2144 ;;; expressions where SIGMA is assumed real. | |
| 2145 ;;; | |
| 2146 ;;; (intv MASK LO HI) Interval form. MASK is 0=(), 1=(], 2=[), or 3=[]. | |
| 2147 ;;; LO and HI are any real numbers, or symbolic | |
| 2148 ;;; expressions which are assumed real, and LO < HI. | |
| 2149 ;;; For [LO..HI], if LO = HI normalization produces LO, | |
| 2150 ;;; and if LO > HI normalization produces [LO..LO). | |
| 2151 ;;; For other intervals, if LO > HI normalization | |
| 2152 ;;; sets HI equal to LO. | |
| 2153 ;;; | |
| 2154 ;;; (mod N M) Number modulo M. When normalized, 0 <= N < M. | |
| 2155 ;;; N and M are real numbers. | |
| 2156 ;;; | |
| 2157 ;;; (var V S) Symbolic variable. V is a Lisp symbol which | |
| 2158 ;;; represents the variable's visible name. S is | |
| 2159 ;;; the symbol which actually stores the variable's | |
| 2160 ;;; value: (var pi var-pi). | |
| 2161 ;;; | |
| 2162 ;;; In general, combining rational numbers in a calculation always produces | |
| 2163 ;;; a rational result, but if either argument is a float, result is a float. | |
| 2164 | |
| 2165 ;;; In the following comments, [x y z] means result is x, args must be y, z, | |
| 2166 ;;; respectively, where the code letters are: | |
| 2167 ;;; | |
| 2168 ;;; O Normalized object (vector or number) | |
| 2169 ;;; V Normalized vector | |
| 2170 ;;; N Normalized number of any type | |
| 2171 ;;; N Normalized complex number | |
| 2172 ;;; R Normalized real number (float or rational) | |
| 2173 ;;; F Normalized floating-point number | |
| 2174 ;;; T Normalized rational number | |
| 2175 ;;; I Normalized integer | |
| 2176 ;;; B Normalized big integer | |
| 2177 ;;; S Normalized small integer | |
| 2178 ;;; D Digit (small integer, 0..999) | |
| 2179 ;;; L Normalized bignum digit list (without "bigpos" or "bigneg" symbol) | |
| 2180 ;;; or normalized vector element list (without "vec") | |
| 2181 ;;; P Predicate (truth value) | |
| 2182 ;;; X Any Lisp object | |
| 2183 ;;; Z "nil" | |
| 2184 ;;; | |
| 2185 ;;; Lower-case letters signify possibly un-normalized values. | |
| 2186 ;;; "L.D" means a cons of an L and a D. | |
| 2187 ;;; [N N; n n] means result will be normalized if argument is. | |
| 2188 ;;; Also, [Public] marks routines intended to be called from outside. | |
| 2189 ;;; [This notation has been neglected in many recent routines.] | |
| 2190 | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
2191 (defvar math-eval-rules-cache) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
2192 (defvar math-eval-rules-cache-other) |
| 40785 | 2193 ;;; Reduce an object to canonical (normalized) form. [O o; Z Z] [Public] |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2194 |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2195 (defvar math-normalize-a) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2196 (defun math-normalize (math-normalize-a) |
| 40785 | 2197 (cond |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2198 ((not (consp math-normalize-a)) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2199 (if (integerp math-normalize-a) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2200 (if (or (>= math-normalize-a 1000000) (<= math-normalize-a -1000000)) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2201 (math-bignum math-normalize-a) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2202 math-normalize-a) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2203 math-normalize-a)) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2204 ((eq (car math-normalize-a) 'bigpos) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2205 (if (eq (nth (1- (length math-normalize-a)) math-normalize-a) 0) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2206 (let* ((last (setq math-normalize-a |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2207 (copy-sequence math-normalize-a))) (digs math-normalize-a)) |
| 40785 | 2208 (while (setq digs (cdr digs)) |
| 2209 (or (eq (car digs) 0) (setq last digs))) | |
| 2210 (setcdr last nil))) | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2211 (if (cdr (cdr (cdr math-normalize-a))) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2212 math-normalize-a |
| 40785 | 2213 (cond |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2214 ((cdr (cdr math-normalize-a)) (+ (nth 1 math-normalize-a) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2215 (* (nth 2 math-normalize-a) 1000))) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2216 ((cdr math-normalize-a) (nth 1 math-normalize-a)) |
| 40785 | 2217 (t 0)))) |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2218 ((eq (car math-normalize-a) 'bigneg) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2219 (if (eq (nth (1- (length math-normalize-a)) math-normalize-a) 0) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2220 (let* ((last (setq math-normalize-a (copy-sequence math-normalize-a))) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2221 (digs math-normalize-a)) |
| 40785 | 2222 (while (setq digs (cdr digs)) |
| 2223 (or (eq (car digs) 0) (setq last digs))) | |
| 2224 (setcdr last nil))) | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2225 (if (cdr (cdr (cdr math-normalize-a))) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2226 math-normalize-a |
| 40785 | 2227 (cond |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2228 ((cdr (cdr math-normalize-a)) (- (+ (nth 1 math-normalize-a) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2229 (* (nth 2 math-normalize-a) 1000)))) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2230 ((cdr math-normalize-a) (- (nth 1 math-normalize-a))) |
| 40785 | 2231 (t 0)))) |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2232 ((eq (car math-normalize-a) 'float) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2233 (math-make-float (math-normalize (nth 1 math-normalize-a)) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2234 (nth 2 math-normalize-a))) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2235 ((or (memq (car math-normalize-a) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2236 '(frac cplx polar hms date mod sdev intv vec var quote |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2237 special-const calcFunc-if calcFunc-lambda |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2238 calcFunc-quote calcFunc-condition |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2239 calcFunc-evalto)) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2240 (integerp (car math-normalize-a)) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2241 (and (consp (car math-normalize-a)) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2242 (not (eq (car (car math-normalize-a)) 'lambda)))) |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2243 (require 'calc-ext) |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2244 (math-normalize-fancy math-normalize-a)) |
| 40785 | 2245 (t |
| 2246 (or (and calc-simplify-mode | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2247 (require 'calc-ext) |
| 40785 | 2248 (math-normalize-nonstandard)) |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2249 (let ((args (mapcar 'math-normalize (cdr math-normalize-a)))) |
| 40785 | 2250 (or (condition-case err |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2251 (let ((func |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2252 (assq (car math-normalize-a) '( ( + . math-add ) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2253 ( - . math-sub ) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2254 ( * . math-mul ) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2255 ( / . math-div ) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2256 ( % . math-mod ) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2257 ( ^ . math-pow ) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2258 ( neg . math-neg ) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2259 ( | . math-concat ) )))) |
| 40785 | 2260 (or (and var-EvalRules |
| 2261 (progn | |
| 2262 (or (eq var-EvalRules math-eval-rules-cache-tag) | |
| 2263 (progn | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2264 (require 'calc-ext) |
| 40785 | 2265 (math-recompile-eval-rules))) |
| 2266 (and (or math-eval-rules-cache-other | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2267 (assq (car math-normalize-a) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2268 math-eval-rules-cache)) |
| 40785 | 2269 (math-apply-rewrites |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2270 (cons (car math-normalize-a) args) |
| 40785 | 2271 (cdr math-eval-rules-cache) |
| 2272 nil math-eval-rules-cache)))) | |
| 2273 (if func | |
| 2274 (apply (cdr func) args) | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2275 (and (or (consp (car math-normalize-a)) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2276 (fboundp (car math-normalize-a)) |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2277 (and (not (featurep 'calc-ext)) |
|
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2278 (require 'calc-ext) |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2279 (fboundp (car math-normalize-a)))) |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2280 (apply (car math-normalize-a) args))))) |
| 40785 | 2281 (wrong-number-of-arguments |
| 2282 (calc-record-why "*Wrong number of arguments" | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2283 (cons (car math-normalize-a) args)) |
| 40785 | 2284 nil) |
| 2285 (wrong-type-argument | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2286 (or calc-next-why |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2287 (calc-record-why "Wrong type of argument" |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2288 (cons (car math-normalize-a) args))) |
| 40785 | 2289 nil) |
| 2290 (args-out-of-range | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2291 (calc-record-why "*Argument out of range" |
|
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2292 (cons (car math-normalize-a) args)) |
| 40785 | 2293 nil) |
| 2294 (inexact-result | |
| 2295 (calc-record-why "No exact representation for result" | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2296 (cons (car math-normalize-a) args)) |
| 40785 | 2297 nil) |
| 2298 (math-overflow | |
| 2299 (calc-record-why "*Floating-point overflow occurred" | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2300 (cons (car math-normalize-a) args)) |
| 40785 | 2301 nil) |
| 2302 (math-underflow | |
| 2303 (calc-record-why "*Floating-point underflow occurred" | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2304 (cons (car math-normalize-a) args)) |
| 40785 | 2305 nil) |
| 2306 (void-variable | |
| 2307 (if (eq (nth 1 err) 'var-EvalRules) | |
| 2308 (progn | |
| 2309 (setq var-EvalRules nil) | |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2310 (math-normalize (cons (car math-normalize-a) args))) |
| 40785 | 2311 (calc-record-why "*Variable is void" (nth 1 err))))) |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2312 (if (consp (car math-normalize-a)) |
| 40785 | 2313 (math-dimension-error) |
|
58103
5fb84c291168
(math-normalize-a): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58061
diff
changeset
|
2314 (cons (car math-normalize-a) args)))))))) |
| 40785 | 2315 |
| 2316 | |
| 2317 | |
| 2318 ;;; True if A is a floating-point real or complex number. [P x] [Public] | |
| 2319 (defun math-floatp (a) | |
| 2320 (cond ((eq (car-safe a) 'float) t) | |
| 2321 ((memq (car-safe a) '(cplx polar mod sdev intv)) | |
| 2322 (or (math-floatp (nth 1 a)) | |
| 2323 (math-floatp (nth 2 a)) | |
| 2324 (and (eq (car a) 'intv) (math-floatp (nth 3 a))))) | |
| 2325 ((eq (car-safe a) 'date) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2326 (math-floatp (nth 1 a))))) |
| 40785 | 2327 |
| 2328 | |
| 2329 | |
| 2330 ;;; Verify that A is a complete object and return A. [x x] [Public] | |
| 2331 (defun math-check-complete (a) | |
| 2332 (cond ((integerp a) a) | |
| 2333 ((eq (car-safe a) 'incomplete) | |
| 2334 (calc-incomplete-error a)) | |
| 2335 ((consp a) a) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2336 (t (error "Invalid data object encountered")))) |
| 40785 | 2337 |
| 2338 | |
| 2339 | |
| 2340 ;;; Coerce integer A to be a bignum. [B S] | |
| 2341 (defun math-bignum (a) | |
| 2342 (if (>= a 0) | |
| 2343 (cons 'bigpos (math-bignum-big a)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2344 (cons 'bigneg (math-bignum-big (- a))))) |
| 40785 | 2345 |
| 2346 (defun math-bignum-big (a) ; [L s] | |
| 2347 (if (= a 0) | |
| 2348 nil | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2349 (cons (% a 1000) (math-bignum-big (/ a 1000))))) |
| 40785 | 2350 |
| 2351 | |
| 2352 ;;; Build a normalized floating-point number. [F I S] | |
| 2353 (defun math-make-float (mant exp) | |
| 2354 (if (eq mant 0) | |
| 2355 '(float 0 0) | |
| 2356 (let* ((ldiff (- calc-internal-prec (math-numdigs mant)))) | |
| 2357 (if (< ldiff 0) | |
| 2358 (setq mant (math-scale-rounding mant ldiff) | |
| 2359 exp (- exp ldiff)))) | |
| 2360 (if (consp mant) | |
| 2361 (let ((digs (cdr mant))) | |
| 2362 (if (= (% (car digs) 10) 0) | |
| 2363 (progn | |
| 2364 (while (= (car digs) 0) | |
| 2365 (setq digs (cdr digs) | |
| 2366 exp (+ exp 3))) | |
| 2367 (while (= (% (car digs) 10) 0) | |
| 2368 (setq digs (math-div10-bignum digs) | |
| 2369 exp (1+ exp))) | |
| 2370 (setq mant (math-normalize (cons (car mant) digs)))))) | |
| 2371 (while (= (% mant 10) 0) | |
| 2372 (setq mant (/ mant 10) | |
| 2373 exp (1+ exp)))) | |
| 2374 (if (and (<= exp -4000000) | |
| 2375 (<= (+ exp (math-numdigs mant) -1) -4000000)) | |
| 2376 (signal 'math-underflow nil) | |
| 2377 (if (and (>= exp 3000000) | |
| 2378 (>= (+ exp (math-numdigs mant) -1) 4000000)) | |
| 2379 (signal 'math-overflow nil) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2380 (list 'float mant exp))))) |
| 40785 | 2381 |
| 2382 (defun math-div10-bignum (a) ; [l l] | |
| 2383 (if (cdr a) | |
| 2384 (cons (+ (/ (car a) 10) (* (% (nth 1 a) 10) 100)) | |
| 2385 (math-div10-bignum (cdr a))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2386 (list (/ (car a) 10)))) |
| 40785 | 2387 |
| 2388 ;;; Coerce A to be a float. [F N; V V] [Public] | |
| 2389 (defun math-float (a) | |
| 2390 (cond ((Math-integerp a) (math-make-float a 0)) | |
| 2391 ((eq (car a) 'frac) (math-div (math-float (nth 1 a)) (nth 2 a))) | |
| 2392 ((eq (car a) 'float) a) | |
| 2393 ((memq (car a) '(cplx polar vec hms date sdev mod)) | |
| 2394 (cons (car a) (mapcar 'math-float (cdr a)))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2395 (t (math-float-fancy a)))) |
| 40785 | 2396 |
| 2397 | |
| 2398 (defun math-neg (a) | |
| 2399 (cond ((not (consp a)) (- a)) | |
| 2400 ((eq (car a) 'bigpos) (cons 'bigneg (cdr a))) | |
| 2401 ((eq (car a) 'bigneg) (cons 'bigpos (cdr a))) | |
| 2402 ((memq (car a) '(frac float)) | |
| 2403 (list (car a) (Math-integer-neg (nth 1 a)) (nth 2 a))) | |
| 2404 ((memq (car a) '(cplx vec hms date calcFunc-idn)) | |
| 2405 (cons (car a) (mapcar 'math-neg (cdr a)))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2406 (t (math-neg-fancy a)))) |
| 40785 | 2407 |
| 2408 | |
| 2409 ;;; Compute the number of decimal digits in integer A. [S I] | |
| 2410 (defun math-numdigs (a) | |
| 2411 (if (consp a) | |
| 2412 (if (cdr a) | |
| 2413 (let* ((len (1- (length a))) | |
| 2414 (top (nth len a))) | |
| 2415 (+ (* len 3) (cond ((>= top 100) 0) ((>= top 10) -1) (t -2)))) | |
| 2416 0) | |
| 2417 (cond ((>= a 100) (+ (math-numdigs (/ a 1000)) 3)) | |
| 2418 ((>= a 10) 2) | |
| 2419 ((>= a 1) 1) | |
| 2420 ((= a 0) 0) | |
| 2421 ((> a -10) 1) | |
| 2422 ((> a -100) 2) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2423 (t (math-numdigs (- a)))))) |
| 40785 | 2424 |
| 2425 ;;; Multiply (with truncation toward 0) the integer A by 10^N. [I i S] | |
| 2426 (defun math-scale-int (a n) | |
| 2427 (cond ((= n 0) a) | |
| 2428 ((> n 0) (math-scale-left a n)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2429 (t (math-normalize (math-scale-right a (- n)))))) |
| 40785 | 2430 |
| 2431 (defun math-scale-left (a n) ; [I I S] | |
| 2432 (if (= n 0) | |
| 2433 a | |
| 2434 (if (consp a) | |
| 2435 (cons (car a) (math-scale-left-bignum (cdr a) n)) | |
| 2436 (if (>= n 3) | |
| 2437 (if (or (>= a 1000) (<= a -1000)) | |
| 2438 (math-scale-left (math-bignum a) n) | |
| 2439 (math-scale-left (* a 1000) (- n 3))) | |
| 2440 (if (= n 2) | |
| 2441 (if (or (>= a 10000) (<= a -10000)) | |
| 2442 (math-scale-left (math-bignum a) 2) | |
| 2443 (* a 100)) | |
| 2444 (if (or (>= a 100000) (<= a -100000)) | |
| 2445 (math-scale-left (math-bignum a) 1) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2446 (* a 10))))))) |
| 40785 | 2447 |
| 2448 (defun math-scale-left-bignum (a n) | |
| 2449 (if (>= n 3) | |
| 2450 (while (>= (setq a (cons 0 a) | |
| 2451 n (- n 3)) 3))) | |
| 2452 (if (> n 0) | |
| 2453 (math-mul-bignum-digit a (if (= n 2) 100 10) 0) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2454 a)) |
| 40785 | 2455 |
| 2456 (defun math-scale-right (a n) ; [i i S] | |
| 2457 (if (= n 0) | |
| 2458 a | |
| 2459 (if (consp a) | |
| 2460 (cons (car a) (math-scale-right-bignum (cdr a) n)) | |
| 2461 (if (<= a 0) | |
| 2462 (if (= a 0) | |
| 2463 0 | |
| 2464 (- (math-scale-right (- a) n))) | |
| 2465 (if (>= n 3) | |
| 2466 (while (and (> (setq a (/ a 1000)) 0) | |
| 2467 (>= (setq n (- n 3)) 3)))) | |
| 2468 (if (= n 2) | |
| 2469 (/ a 100) | |
| 2470 (if (= n 1) | |
| 2471 (/ a 10) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2472 a)))))) |
| 40785 | 2473 |
| 2474 (defun math-scale-right-bignum (a n) ; [L L S; l l S] | |
| 2475 (if (>= n 3) | |
| 2476 (setq a (nthcdr (/ n 3) a) | |
| 2477 n (% n 3))) | |
| 2478 (if (> n 0) | |
| 2479 (cdr (math-mul-bignum-digit a (if (= n 2) 10 100) 0)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2480 a)) |
| 40785 | 2481 |
| 2482 ;;; Multiply (with rounding) the integer A by 10^N. [I i S] | |
| 2483 (defun math-scale-rounding (a n) | |
| 2484 (cond ((>= n 0) | |
| 2485 (math-scale-left a n)) | |
| 2486 ((consp a) | |
| 2487 (math-normalize | |
| 2488 (cons (car a) | |
| 2489 (let ((val (if (< n -3) | |
| 2490 (math-scale-right-bignum (cdr a) (- -3 n)) | |
| 2491 (if (= n -2) | |
| 2492 (math-mul-bignum-digit (cdr a) 10 0) | |
| 2493 (if (= n -1) | |
| 2494 (math-mul-bignum-digit (cdr a) 100 0) | |
| 2495 (cdr a)))))) ; n = -3 | |
| 2496 (if (and val (>= (car val) 500)) | |
| 2497 (if (cdr val) | |
| 2498 (if (eq (car (cdr val)) 999) | |
| 2499 (math-add-bignum (cdr val) '(1)) | |
| 2500 (cons (1+ (car (cdr val))) (cdr (cdr val)))) | |
| 2501 '(1)) | |
| 2502 (cdr val)))))) | |
| 2503 (t | |
| 2504 (if (< a 0) | |
| 2505 (- (math-scale-rounding (- a) n)) | |
| 2506 (if (= n -1) | |
| 2507 (/ (+ a 5) 10) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2508 (/ (+ (math-scale-right a (- -1 n)) 5) 10)))))) |
| 40785 | 2509 |
| 2510 | |
| 2511 ;;; Compute the sum of A and B. [O O O] [Public] | |
| 2512 (defun math-add (a b) | |
| 2513 (or | |
| 2514 (and (not (or (consp a) (consp b))) | |
| 2515 (progn | |
| 2516 (setq a (+ a b)) | |
| 2517 (if (or (<= a -1000000) (>= a 1000000)) | |
| 2518 (math-bignum a) | |
| 2519 a))) | |
| 2520 (and (Math-zerop a) (not (eq (car-safe a) 'mod)) | |
| 2521 (if (and (math-floatp a) (Math-ratp b)) (math-float b) b)) | |
| 2522 (and (Math-zerop b) (not (eq (car-safe b) 'mod)) | |
| 2523 (if (and (math-floatp b) (Math-ratp a)) (math-float a) a)) | |
| 2524 (and (Math-objvecp a) (Math-objvecp b) | |
| 2525 (or | |
| 2526 (and (Math-integerp a) (Math-integerp b) | |
| 2527 (progn | |
| 2528 (or (consp a) (setq a (math-bignum a))) | |
| 2529 (or (consp b) (setq b (math-bignum b))) | |
| 2530 (if (eq (car a) 'bigneg) | |
| 2531 (if (eq (car b) 'bigneg) | |
| 2532 (cons 'bigneg (math-add-bignum (cdr a) (cdr b))) | |
| 2533 (math-normalize | |
| 2534 (let ((diff (math-sub-bignum (cdr b) (cdr a)))) | |
| 2535 (if (eq diff 'neg) | |
| 2536 (cons 'bigneg (math-sub-bignum (cdr a) (cdr b))) | |
| 2537 (cons 'bigpos diff))))) | |
| 2538 (if (eq (car b) 'bigneg) | |
| 2539 (math-normalize | |
| 2540 (let ((diff (math-sub-bignum (cdr a) (cdr b)))) | |
| 2541 (if (eq diff 'neg) | |
| 2542 (cons 'bigneg (math-sub-bignum (cdr b) (cdr a))) | |
| 2543 (cons 'bigpos diff)))) | |
| 2544 (cons 'bigpos (math-add-bignum (cdr a) (cdr b))))))) | |
| 2545 (and (Math-ratp a) (Math-ratp b) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2546 (require 'calc-ext) |
| 40785 | 2547 (calc-add-fractions a b)) |
| 2548 (and (Math-realp a) (Math-realp b) | |
| 2549 (progn | |
| 2550 (or (and (consp a) (eq (car a) 'float)) | |
| 2551 (setq a (math-float a))) | |
| 2552 (or (and (consp b) (eq (car b) 'float)) | |
| 2553 (setq b (math-float b))) | |
| 2554 (math-add-float a b))) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2555 (and (require 'calc-ext) |
| 40785 | 2556 (math-add-objects-fancy a b)))) |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2557 (and (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2558 (math-add-symb-fancy a b)))) |
| 40785 | 2559 |
| 2560 (defun math-add-bignum (a b) ; [L L L; l l l] | |
| 2561 (if a | |
| 2562 (if b | |
| 2563 (let* ((a (copy-sequence a)) (aa a) (carry nil) sum) | |
| 2564 (while (and aa b) | |
| 2565 (if carry | |
| 2566 (if (< (setq sum (+ (car aa) (car b))) 999) | |
| 2567 (progn | |
| 2568 (setcar aa (1+ sum)) | |
| 2569 (setq carry nil)) | |
| 2570 (setcar aa (+ sum -999))) | |
| 2571 (if (< (setq sum (+ (car aa) (car b))) 1000) | |
| 2572 (setcar aa sum) | |
| 2573 (setcar aa (+ sum -1000)) | |
| 2574 (setq carry t))) | |
| 2575 (setq aa (cdr aa) | |
| 2576 b (cdr b))) | |
| 2577 (if carry | |
| 2578 (if b | |
| 2579 (nconc a (math-add-bignum b '(1))) | |
| 2580 (while (eq (car aa) 999) | |
| 2581 (setcar aa 0) | |
| 2582 (setq aa (cdr aa))) | |
| 2583 (if aa | |
| 2584 (progn | |
| 2585 (setcar aa (1+ (car aa))) | |
| 2586 a) | |
| 2587 (nconc a '(1)))) | |
| 2588 (if b | |
| 2589 (nconc a b) | |
| 2590 a))) | |
| 2591 a) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2592 b)) |
| 40785 | 2593 |
| 2594 (defun math-sub-bignum (a b) ; [l l l] | |
| 2595 (if b | |
| 2596 (if a | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
2597 (let* ((a (copy-sequence a)) (aa a) (borrow nil) sum diff) |
| 40785 | 2598 (while (and aa b) |
| 2599 (if borrow | |
| 2600 (if (>= (setq diff (- (car aa) (car b))) 1) | |
| 2601 (progn | |
| 2602 (setcar aa (1- diff)) | |
| 2603 (setq borrow nil)) | |
| 2604 (setcar aa (+ diff 999))) | |
| 2605 (if (>= (setq diff (- (car aa) (car b))) 0) | |
| 2606 (setcar aa diff) | |
| 2607 (setcar aa (+ diff 1000)) | |
| 2608 (setq borrow t))) | |
| 2609 (setq aa (cdr aa) | |
| 2610 b (cdr b))) | |
| 2611 (if borrow | |
| 2612 (progn | |
| 2613 (while (eq (car aa) 0) | |
| 2614 (setcar aa 999) | |
| 2615 (setq aa (cdr aa))) | |
| 2616 (if aa | |
| 2617 (progn | |
| 2618 (setcar aa (1- (car aa))) | |
| 2619 a) | |
| 2620 'neg)) | |
| 2621 (while (eq (car b) 0) | |
| 2622 (setq b (cdr b))) | |
| 2623 (if b | |
| 2624 'neg | |
| 2625 a))) | |
| 2626 (while (eq (car b) 0) | |
| 2627 (setq b (cdr b))) | |
| 2628 (and b | |
| 2629 'neg)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2630 a)) |
| 40785 | 2631 |
| 2632 (defun math-add-float (a b) ; [F F F] | |
| 2633 (let ((ediff (- (nth 2 a) (nth 2 b)))) | |
| 2634 (if (>= ediff 0) | |
| 2635 (if (>= ediff (+ calc-internal-prec calc-internal-prec)) | |
| 2636 a | |
| 2637 (math-make-float (math-add (nth 1 b) | |
| 2638 (if (eq ediff 0) | |
| 2639 (nth 1 a) | |
| 2640 (math-scale-left (nth 1 a) ediff))) | |
| 2641 (nth 2 b))) | |
| 2642 (if (>= (setq ediff (- ediff)) | |
| 2643 (+ calc-internal-prec calc-internal-prec)) | |
| 2644 b | |
| 2645 (math-make-float (math-add (nth 1 a) | |
| 2646 (math-scale-left (nth 1 b) ediff)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2647 (nth 2 a)))))) |
| 40785 | 2648 |
| 2649 ;;; Compute the difference of A and B. [O O O] [Public] | |
| 2650 (defun math-sub (a b) | |
| 2651 (if (or (consp a) (consp b)) | |
| 2652 (math-add a (math-neg b)) | |
| 2653 (setq a (- a b)) | |
| 2654 (if (or (<= a -1000000) (>= a 1000000)) | |
| 2655 (math-bignum a) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2656 a))) |
| 40785 | 2657 |
| 2658 (defun math-sub-float (a b) ; [F F F] | |
| 2659 (let ((ediff (- (nth 2 a) (nth 2 b)))) | |
| 2660 (if (>= ediff 0) | |
| 2661 (if (>= ediff (+ calc-internal-prec calc-internal-prec)) | |
| 2662 a | |
| 2663 (math-make-float (math-add (Math-integer-neg (nth 1 b)) | |
| 2664 (if (eq ediff 0) | |
| 2665 (nth 1 a) | |
| 2666 (math-scale-left (nth 1 a) ediff))) | |
| 2667 (nth 2 b))) | |
| 2668 (if (>= (setq ediff (- ediff)) | |
| 2669 (+ calc-internal-prec calc-internal-prec)) | |
| 2670 b | |
| 2671 (math-make-float (math-add (nth 1 a) | |
| 2672 (Math-integer-neg | |
| 2673 (math-scale-left (nth 1 b) ediff))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2674 (nth 2 a)))))) |
| 40785 | 2675 |
| 2676 | |
| 2677 ;;; Compute the product of A and B. [O O O] [Public] | |
| 2678 (defun math-mul (a b) | |
| 2679 (or | |
| 2680 (and (not (consp a)) (not (consp b)) | |
| 2681 (< a 1000) (> a -1000) (< b 1000) (> b -1000) | |
| 2682 (* a b)) | |
| 2683 (and (Math-zerop a) (not (eq (car-safe b) 'mod)) | |
| 2684 (if (Math-scalarp b) | |
| 2685 (if (and (math-floatp b) (Math-ratp a)) (math-float a) a) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2686 (require 'calc-ext) |
| 40785 | 2687 (math-mul-zero a b))) |
| 2688 (and (Math-zerop b) (not (eq (car-safe a) 'mod)) | |
| 2689 (if (Math-scalarp a) | |
| 2690 (if (and (math-floatp a) (Math-ratp b)) (math-float b) b) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2691 (require 'calc-ext) |
| 40785 | 2692 (math-mul-zero b a))) |
| 2693 (and (Math-objvecp a) (Math-objvecp b) | |
| 2694 (or | |
| 2695 (and (Math-integerp a) (Math-integerp b) | |
| 2696 (progn | |
| 2697 (or (consp a) (setq a (math-bignum a))) | |
| 2698 (or (consp b) (setq b (math-bignum b))) | |
| 2699 (math-normalize | |
| 2700 (cons (if (eq (car a) (car b)) 'bigpos 'bigneg) | |
| 2701 (if (cdr (cdr a)) | |
| 2702 (if (cdr (cdr b)) | |
| 2703 (math-mul-bignum (cdr a) (cdr b)) | |
| 2704 (math-mul-bignum-digit (cdr a) (nth 1 b) 0)) | |
| 2705 (math-mul-bignum-digit (cdr b) (nth 1 a) 0)))))) | |
| 2706 (and (Math-ratp a) (Math-ratp b) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2707 (require 'calc-ext) |
| 40785 | 2708 (calc-mul-fractions a b)) |
| 2709 (and (Math-realp a) (Math-realp b) | |
| 2710 (progn | |
| 2711 (or (and (consp a) (eq (car a) 'float)) | |
| 2712 (setq a (math-float a))) | |
| 2713 (or (and (consp b) (eq (car b) 'float)) | |
| 2714 (setq b (math-float b))) | |
| 2715 (math-make-float (math-mul (nth 1 a) (nth 1 b)) | |
| 2716 (+ (nth 2 a) (nth 2 b))))) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2717 (and (require 'calc-ext) |
| 40785 | 2718 (math-mul-objects-fancy a b)))) |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2719 (and (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2720 (math-mul-symb-fancy a b)))) |
| 40785 | 2721 |
| 2722 (defun math-infinitep (a &optional undir) | |
| 2723 (while (and (consp a) (memq (car a) '(* / neg))) | |
| 2724 (if (or (not (eq (car a) '*)) (math-infinitep (nth 1 a))) | |
| 2725 (setq a (nth 1 a)) | |
| 2726 (setq a (nth 2 a)))) | |
| 2727 (and (consp a) | |
| 2728 (eq (car a) 'var) | |
| 2729 (memq (nth 2 a) '(var-inf var-uinf var-nan)) | |
| 2730 (if (and undir (eq (nth 2 a) 'var-inf)) | |
| 2731 '(var uinf var-uinf) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2732 a))) |
| 40785 | 2733 |
| 2734 ;;; Multiply digit lists A and B. [L L L; l l l] | |
| 2735 (defun math-mul-bignum (a b) | |
| 2736 (and a b | |
| 2737 (let* ((sum (if (<= (car b) 1) | |
| 2738 (if (= (car b) 0) | |
| 2739 (list 0) | |
| 2740 (copy-sequence a)) | |
| 2741 (math-mul-bignum-digit a (car b) 0))) | |
| 2742 (sump sum) c d aa ss prod) | |
| 2743 (while (setq b (cdr b)) | |
| 2744 (setq ss (setq sump (or (cdr sump) (setcdr sump (list 0)))) | |
| 2745 d (car b) | |
| 2746 c 0 | |
| 2747 aa a) | |
| 2748 (while (progn | |
| 2749 (setcar ss (% (setq prod (+ (+ (car ss) (* (car aa) d)) | |
| 2750 c)) 1000)) | |
| 2751 (setq aa (cdr aa))) | |
| 2752 (setq c (/ prod 1000) | |
| 2753 ss (or (cdr ss) (setcdr ss (list 0))))) | |
| 2754 (if (>= prod 1000) | |
| 2755 (if (cdr ss) | |
| 2756 (setcar (cdr ss) (+ (/ prod 1000) (car (cdr ss)))) | |
| 2757 (setcdr ss (list (/ prod 1000)))))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2758 sum))) |
| 40785 | 2759 |
| 2760 ;;; Multiply digit list A by digit D. [L L D D; l l D D] | |
| 2761 (defun math-mul-bignum-digit (a d c) | |
| 2762 (if a | |
| 2763 (if (<= d 1) | |
| 2764 (and (= d 1) a) | |
| 2765 (let* ((a (copy-sequence a)) (aa a) prod) | |
| 2766 (while (progn | |
| 2767 (setcar aa (% (setq prod (+ (* (car aa) d) c)) 1000)) | |
| 2768 (cdr aa)) | |
| 2769 (setq aa (cdr aa) | |
| 2770 c (/ prod 1000))) | |
| 2771 (if (>= prod 1000) | |
| 2772 (setcdr aa (list (/ prod 1000)))) | |
| 2773 a)) | |
| 2774 (and (> c 0) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2775 (list c)))) |
| 40785 | 2776 |
| 2777 | |
| 2778 ;;; Compute the integer (quotient . remainder) of A and B, which may be | |
| 2779 ;;; small or big integers. Type and consistency of truncation is undefined | |
| 2780 ;;; if A or B is negative. B must be nonzero. [I.I I I] [Public] | |
| 2781 (defun math-idivmod (a b) | |
| 2782 (if (eq b 0) | |
| 2783 (math-reject-arg a "*Division by zero")) | |
| 2784 (if (or (consp a) (consp b)) | |
| 2785 (if (and (natnump b) (< b 1000)) | |
| 2786 (let ((res (math-div-bignum-digit (cdr a) b))) | |
| 2787 (cons | |
| 2788 (math-normalize (cons (car a) (car res))) | |
| 2789 (cdr res))) | |
| 2790 (or (consp a) (setq a (math-bignum a))) | |
| 2791 (or (consp b) (setq b (math-bignum b))) | |
| 2792 (let ((res (math-div-bignum (cdr a) (cdr b)))) | |
| 2793 (cons | |
| 2794 (math-normalize (cons (if (eq (car a) (car b)) 'bigpos 'bigneg) | |
| 2795 (car res))) | |
| 2796 (math-normalize (cons (car a) (cdr res)))))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2797 (cons (/ a b) (% a b)))) |
| 40785 | 2798 |
| 2799 (defun math-quotient (a b) ; [I I I] [Public] | |
| 2800 (if (and (not (consp a)) (not (consp b))) | |
| 2801 (if (= b 0) | |
| 2802 (math-reject-arg a "*Division by zero") | |
| 2803 (/ a b)) | |
| 2804 (if (and (natnump b) (< b 1000)) | |
| 2805 (if (= b 0) | |
| 2806 (math-reject-arg a "*Division by zero") | |
| 2807 (math-normalize (cons (car a) | |
| 2808 (car (math-div-bignum-digit (cdr a) b))))) | |
| 2809 (or (consp a) (setq a (math-bignum a))) | |
| 2810 (or (consp b) (setq b (math-bignum b))) | |
| 2811 (let* ((alen (1- (length a))) | |
| 2812 (blen (1- (length b))) | |
| 2813 (d (/ 1000 (1+ (nth (1- blen) (cdr b))))) | |
| 2814 (res (math-div-bignum-big (math-mul-bignum-digit (cdr a) d 0) | |
| 2815 (math-mul-bignum-digit (cdr b) d 0) | |
| 2816 alen blen))) | |
| 2817 (math-normalize (cons (if (eq (car a) (car b)) 'bigpos 'bigneg) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2818 (car res))))))) |
| 40785 | 2819 |
| 2820 | |
| 2821 ;;; Divide a bignum digit list by another. [l.l l L] | |
| 2822 ;;; The following division algorithm is borrowed from Knuth vol. II, sec. 4.3.1 | |
| 2823 (defun math-div-bignum (a b) | |
| 2824 (if (cdr b) | |
| 2825 (let* ((alen (length a)) | |
| 2826 (blen (length b)) | |
| 2827 (d (/ 1000 (1+ (nth (1- blen) b)))) | |
| 2828 (res (math-div-bignum-big (math-mul-bignum-digit a d 0) | |
| 2829 (math-mul-bignum-digit b d 0) | |
| 2830 alen blen))) | |
| 2831 (if (= d 1) | |
| 2832 res | |
| 2833 (cons (car res) | |
| 2834 (car (math-div-bignum-digit (cdr res) d))))) | |
| 2835 (let ((res (math-div-bignum-digit a (car b)))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2836 (cons (car res) (list (cdr res)))))) |
| 40785 | 2837 |
| 2838 ;;; Divide a bignum digit list by a digit. [l.D l D] | |
| 2839 (defun math-div-bignum-digit (a b) | |
| 2840 (if a | |
| 2841 (let* ((res (math-div-bignum-digit (cdr a) b)) | |
| 2842 (num (+ (* (cdr res) 1000) (car a)))) | |
| 2843 (cons | |
| 2844 (cons (/ num b) (car res)) | |
| 2845 (% num b))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2846 '(nil . 0))) |
| 40785 | 2847 |
| 2848 (defun math-div-bignum-big (a b alen blen) ; [l.l l L] | |
| 2849 (if (< alen blen) | |
| 2850 (cons nil a) | |
| 2851 (let* ((res (math-div-bignum-big (cdr a) b (1- alen) blen)) | |
| 2852 (num (cons (car a) (cdr res))) | |
| 2853 (res2 (math-div-bignum-part num b blen))) | |
| 2854 (cons | |
| 2855 (cons (car res2) (car res)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2856 (cdr res2))))) |
| 40785 | 2857 |
| 2858 (defun math-div-bignum-part (a b blen) ; a < b*1000 [D.l l L] | |
| 2859 (let* ((num (+ (* (or (nth blen a) 0) 1000) (or (nth (1- blen) a) 0))) | |
| 2860 (den (nth (1- blen) b)) | |
| 2861 (guess (min (/ num den) 999))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2862 (math-div-bignum-try a b (math-mul-bignum-digit b guess 0) guess))) |
| 40785 | 2863 |
| 2864 (defun math-div-bignum-try (a b c guess) ; [D.l l l D] | |
| 2865 (let ((rem (math-sub-bignum a c))) | |
| 2866 (if (eq rem 'neg) | |
| 2867 (math-div-bignum-try a b (math-sub-bignum c b) (1- guess)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2868 (cons guess rem)))) |
| 40785 | 2869 |
| 2870 | |
| 2871 ;;; Compute the quotient of A and B. [O O N] [Public] | |
| 2872 (defun math-div (a b) | |
| 2873 (or | |
| 2874 (and (Math-zerop b) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2875 (require 'calc-ext) |
| 40785 | 2876 (math-div-by-zero a b)) |
| 2877 (and (Math-zerop a) (not (eq (car-safe b) 'mod)) | |
| 2878 (if (Math-scalarp b) | |
| 2879 (if (and (math-floatp b) (Math-ratp a)) (math-float a) a) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2880 (require 'calc-ext) |
| 40785 | 2881 (math-div-zero a b))) |
| 2882 (and (Math-objvecp a) (Math-objvecp b) | |
| 2883 (or | |
| 2884 (and (Math-integerp a) (Math-integerp b) | |
| 2885 (let ((q (math-idivmod a b))) | |
| 2886 (if (eq (cdr q) 0) | |
| 2887 (car q) | |
| 2888 (if calc-prefer-frac | |
| 2889 (progn | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2890 (require 'calc-ext) |
| 40785 | 2891 (math-make-frac a b)) |
| 2892 (math-div-float (math-make-float a 0) | |
| 2893 (math-make-float b 0)))))) | |
| 2894 (and (Math-ratp a) (Math-ratp b) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2895 (require 'calc-ext) |
| 40785 | 2896 (calc-div-fractions a b)) |
| 2897 (and (Math-realp a) (Math-realp b) | |
| 2898 (progn | |
| 2899 (or (and (consp a) (eq (car a) 'float)) | |
| 2900 (setq a (math-float a))) | |
| 2901 (or (and (consp b) (eq (car b) 'float)) | |
| 2902 (setq b (math-float b))) | |
| 2903 (math-div-float a b))) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2904 (and (require 'calc-ext) |
| 40785 | 2905 (math-div-objects-fancy a b)))) |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2906 (and (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2907 (math-div-symb-fancy a b)))) |
| 40785 | 2908 |
| 2909 (defun math-div-float (a b) ; [F F F] | |
| 2910 (let ((ldiff (max (- (1+ calc-internal-prec) | |
| 2911 (- (math-numdigs (nth 1 a)) (math-numdigs (nth 1 b)))) | |
| 2912 0))) | |
| 2913 (math-make-float (math-quotient (math-scale-int (nth 1 a) ldiff) (nth 1 b)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2914 (- (- (nth 2 a) (nth 2 b)) ldiff)))) |
| 40785 | 2915 |
| 2916 | |
| 2917 | |
| 2918 | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
2919 (defvar calc-selection-cache-entry) |
| 40785 | 2920 ;;; Format the number A as a string. [X N; X Z] [Public] |
| 2921 (defun math-format-stack-value (entry) | |
| 2922 (setq calc-selection-cache-entry calc-selection-cache-default-entry) | |
| 2923 (let* ((a (car entry)) | |
| 2924 (math-comp-selected (nth 2 entry)) | |
| 2925 (c (cond ((null a) "<nil>") | |
| 2926 ((eq calc-display-raw t) (format "%s" a)) | |
| 2927 ((stringp a) a) | |
| 45769 | 2928 ((eq a 'top-of-stack) (propertize "." 'font-lock-face 'bold)) |
| 40785 | 2929 (calc-prepared-composition |
| 2930 calc-prepared-composition) | |
| 2931 ((and (Math-scalarp a) | |
| 2932 (memq calc-language '(nil flat unform)) | |
| 2933 (null math-comp-selected)) | |
| 2934 (math-format-number a)) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2935 (t (require 'calc-ext) |
| 40785 | 2936 (math-compose-expr a 0)))) |
| 2937 (off (math-stack-value-offset c)) | |
| 2938 s w) | |
| 2939 (and math-comp-selected (setq calc-any-selections t)) | |
| 2940 (setq w (cdr off) | |
| 2941 off (car off)) | |
| 45769 | 2942 (when (> off 0) |
| 2943 (setq c (math-comp-concat (make-string off ? ) c))) | |
| 40785 | 2944 (or (equal calc-left-label "") |
| 2945 (setq c (math-comp-concat (if (eq a 'top-of-stack) | |
| 2946 (make-string (length calc-left-label) ? ) | |
| 2947 calc-left-label) | |
| 2948 c))) | |
| 45769 | 2949 (when calc-line-numbering |
| 2950 (setq c (math-comp-concat (if (eq calc-language 'big) | |
|
46807
f57a8a1712ae
(math-format-stack-value): Revert a broken
David Kastrup <dak@gnu.org>
parents:
45769
diff
changeset
|
2951 (if math-comp-selected |
|
f57a8a1712ae
(math-format-stack-value): Revert a broken
David Kastrup <dak@gnu.org>
parents:
45769
diff
changeset
|
2952 '(tag t "1: ") |
|
f57a8a1712ae
(math-format-stack-value): Revert a broken
David Kastrup <dak@gnu.org>
parents:
45769
diff
changeset
|
2953 "1: ") |
| 45769 | 2954 " ") |
| 2955 c))) | |
| 2956 (unless (or (equal calc-right-label "") | |
| 2957 (eq a 'top-of-stack)) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2958 (require 'calc-ext) |
| 45769 | 2959 (setq c (list 'horiz c |
| 2960 (make-string (max (- w (math-comp-width c) | |
| 2961 (length calc-right-label)) 0) ? ) | |
| 2962 '(break -1) | |
| 2963 calc-right-label))) | |
| 40785 | 2964 (setq s (if (stringp c) |
| 2965 (if calc-display-raw | |
| 2966 (prin1-to-string c) | |
| 2967 c) | |
| 2968 (math-composition-to-string c w))) | |
| 45769 | 2969 (when calc-language-output-filter |
| 2970 (setq s (funcall calc-language-output-filter s))) | |
| 40785 | 2971 (if (eq calc-language 'big) |
| 2972 (setq s (concat s "\n")) | |
| 45769 | 2973 (when calc-line-numbering |
|
54583
4a88f2b2e26a
(calc-mode-map): Use mapc.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
2974 (setq s (concat "1:" (substring s 2))))) |
| 40785 | 2975 (setcar (cdr entry) (calc-count-lines s)) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
2976 s)) |
| 40785 | 2977 |
|
58467
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2978 ;; The variables math-svo-c, math-svo-wid and math-svo-off are local |
|
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2979 ;; to math-stack-value-offset, but are used by math-stack-value-offset-fancy |
|
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2980 ;; in calccomp.el. |
|
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2981 |
|
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2982 (defun math-stack-value-offset (math-svo-c) |
| 40785 | 2983 (let* ((num (if calc-line-numbering 4 0)) |
|
58467
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2984 (math-svo-wid (calc-window-width)) |
|
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2985 math-svo-off) |
| 40785 | 2986 (if calc-display-just |
| 2987 (progn | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
2988 (require 'calc-ext) |
| 40785 | 2989 (math-stack-value-offset-fancy)) |
|
58467
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2990 (setq math-svo-off (or calc-display-origin 0)) |
| 45769 | 2991 (when (integerp calc-line-breaking) |
|
58467
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2992 (setq math-svo-wid calc-line-breaking))) |
|
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2993 (cons (max (- math-svo-off (length calc-left-label)) 0) |
|
4a905282edbb
(math-stack-value-offset): Replace variables c, wid and off with
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58103
diff
changeset
|
2994 (+ math-svo-wid num)))) |
| 40785 | 2995 |
| 2996 (defun calc-count-lines (s) | |
| 2997 (let ((pos 0) | |
| 2998 (num 1)) | |
|
47641
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
2999 (while (setq pos (string-match "\n" s pos)) |
|
172cf7391545
(calc-bug-address, calc-scan-for-dels, calc-stack)
Colin Walters <walters@gnu.org>
parents:
47539
diff
changeset
|
3000 (setq pos (1+ pos) |
| 40785 | 3001 num (1+ num))) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3002 num)) |
| 40785 | 3003 |
| 3004 (defun math-format-value (a &optional w) | |
| 3005 (if (and (Math-scalarp a) | |
| 3006 (memq calc-language '(nil flat unform))) | |
| 3007 (math-format-number a) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3008 (require 'calc-ext) |
| 40785 | 3009 (let ((calc-line-breaking nil)) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3010 (math-composition-to-string (math-compose-expr a 0) w)))) |
| 40785 | 3011 |
| 3012 (defun calc-window-width () | |
| 3013 (if calc-embedded-info | |
| 3014 (let ((win (get-buffer-window (aref calc-embedded-info 0)))) | |
|
40999
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
3015 (1- (if win (window-width win) (frame-width)))) |
| 40785 | 3016 (- (window-width (get-buffer-window (current-buffer))) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3017 (if calc-line-numbering 5 1)))) |
| 40785 | 3018 |
| 3019 (defun math-comp-concat (c1 c2) | |
| 3020 (if (and (stringp c1) (stringp c2)) | |
| 3021 (concat c1 c2) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3022 (list 'horiz c1 c2))) |
| 40785 | 3023 |
| 3024 | |
| 3025 | |
| 3026 ;;; Format an expression as a one-line string suitable for re-reading. | |
| 3027 | |
| 3028 (defun math-format-flat-expr (a prec) | |
| 3029 (cond | |
| 3030 ((or (not (or (consp a) (integerp a))) | |
| 3031 (eq calc-display-raw t)) | |
| 3032 (let ((print-escape-newlines t)) | |
| 3033 (concat "'" (prin1-to-string a)))) | |
| 3034 ((Math-scalarp a) | |
| 3035 (let ((calc-group-digits nil) | |
| 3036 (calc-point-char ".") | |
| 3037 (calc-frac-format (if (> (length (car calc-frac-format)) 1) | |
| 3038 '("::" nil) '(":" nil))) | |
| 3039 (calc-complex-format nil) | |
| 3040 (calc-hms-format "%s@ %s' %s\"") | |
| 3041 (calc-language nil)) | |
| 3042 (math-format-number a))) | |
| 3043 (t | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3044 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3045 (math-format-flat-expr-fancy a prec)))) |
| 40785 | 3046 |
| 3047 | |
| 3048 | |
| 3049 ;;; Format a number as a string. | |
| 3050 (defun math-format-number (a &optional prec) ; [X N] [Public] | |
| 3051 (cond | |
| 3052 ((eq calc-display-raw t) (format "%s" a)) | |
| 3053 ((and (nth 1 calc-frac-format) (Math-integerp a)) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3054 (require 'calc-ext) |
| 40785 | 3055 (math-format-number (math-adjust-fraction a))) |
| 3056 ((integerp a) | |
| 3057 (if (not (or calc-group-digits calc-leading-zeros)) | |
| 3058 (if (= calc-number-radix 10) | |
| 3059 (int-to-string a) | |
| 3060 (if (< a 0) | |
| 3061 (concat "-" (math-format-number (- a))) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3062 (require 'calc-ext) |
| 40785 | 3063 (if math-radix-explicit-format |
| 3064 (if calc-radix-formatter | |
| 3065 (funcall calc-radix-formatter | |
| 3066 calc-number-radix | |
| 3067 (if (= calc-number-radix 2) | |
| 3068 (math-format-binary a) | |
| 3069 (math-format-radix a))) | |
| 3070 (format "%d#%s" calc-number-radix | |
| 3071 (if (= calc-number-radix 2) | |
| 3072 (math-format-binary a) | |
| 3073 (math-format-radix a)))) | |
| 3074 (math-format-radix a)))) | |
| 3075 (math-format-number (math-bignum a)))) | |
| 3076 ((stringp a) a) | |
| 3077 ((not (consp a)) (prin1-to-string a)) | |
| 3078 ((eq (car a) 'bigpos) (math-format-bignum (cdr a))) | |
| 3079 ((eq (car a) 'bigneg) (concat "-" (math-format-bignum (cdr a)))) | |
| 3080 ((and (eq (car a) 'float) (= calc-number-radix 10)) | |
| 3081 (if (Math-integer-negp (nth 1 a)) | |
| 3082 (concat "-" (math-format-number (math-neg a))) | |
| 3083 (let ((mant (nth 1 a)) | |
| 3084 (exp (nth 2 a)) | |
| 3085 (fmt (car calc-float-format)) | |
| 3086 (figs (nth 1 calc-float-format)) | |
| 3087 (point calc-point-char) | |
| 3088 str) | |
| 3089 (if (and (eq fmt 'fix) | |
| 3090 (or (and (< figs 0) (setq figs (- figs))) | |
| 3091 (> (+ exp (math-numdigs mant)) (- figs)))) | |
| 3092 (progn | |
| 3093 (setq mant (math-scale-rounding mant (+ exp figs)) | |
| 3094 str (if (integerp mant) | |
| 3095 (int-to-string mant) | |
| 3096 (math-format-bignum-decimal (cdr mant)))) | |
| 3097 (if (<= (length str) figs) | |
| 3098 (setq str (concat (make-string (1+ (- figs (length str))) ?0) | |
| 3099 str))) | |
| 3100 (if (> figs 0) | |
| 3101 (setq str (concat (substring str 0 (- figs)) point | |
| 3102 (substring str (- figs)))) | |
| 3103 (setq str (concat str point))) | |
|
44574
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3104 (when calc-group-digits |
|
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3105 (require 'calc-ext) |
|
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3106 (setq str (math-group-float str)))) |
| 45769 | 3107 (when (< figs 0) |
| 3108 (setq figs (+ calc-internal-prec figs))) | |
| 3109 (when (> figs 0) | |
| 3110 (let ((adj (- figs (math-numdigs mant)))) | |
| 3111 (when (< adj 0) | |
| 3112 (setq mant (math-scale-rounding mant adj) | |
| 3113 exp (- exp adj))))) | |
| 40785 | 3114 (setq str (if (integerp mant) |
| 3115 (int-to-string mant) | |
| 3116 (math-format-bignum-decimal (cdr mant)))) | |
| 3117 (let* ((len (length str)) | |
| 3118 (dpos (+ exp len))) | |
| 3119 (if (and (eq fmt 'float) | |
| 3120 (<= dpos (+ calc-internal-prec calc-display-sci-high)) | |
| 3121 (>= dpos (+ calc-display-sci-low 2))) | |
| 3122 (progn | |
| 3123 (cond | |
| 3124 ((= dpos 0) | |
| 3125 (setq str (concat "0" point str))) | |
| 3126 ((and (<= exp 0) (> dpos 0)) | |
| 3127 (setq str (concat (substring str 0 dpos) point | |
| 3128 (substring str dpos)))) | |
| 3129 ((> exp 0) | |
| 3130 (setq str (concat str (make-string exp ?0) point))) | |
| 3131 (t ; (< dpos 0) | |
| 3132 (setq str (concat "0" point | |
| 3133 (make-string (- dpos) ?0) str)))) | |
|
44574
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3134 (when calc-group-digits |
|
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3135 (require 'calc-ext) |
|
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3136 (setq str (math-group-float str)))) |
| 40785 | 3137 (let* ((eadj (+ exp len)) |
| 3138 (scale (if (eq fmt 'eng) | |
| 3139 (1+ (math-mod (+ eadj 300002) 3)) | |
| 3140 1))) | |
| 3141 (if (> scale (length str)) | |
| 3142 (setq str (concat str (make-string (- scale (length str)) | |
| 3143 ?0)))) | |
| 3144 (if (< scale (length str)) | |
| 3145 (setq str (concat (substring str 0 scale) point | |
| 3146 (substring str scale)))) | |
|
44574
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3147 (when calc-group-digits |
|
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3148 (require 'calc-ext) |
|
f9b633c7d323
(math-format-number): Load `calc-ext' before we call
Colin Walters <walters@gnu.org>
parents:
44249
diff
changeset
|
3149 (setq str (math-group-float str))) |
| 40785 | 3150 (setq str (format (if (memq calc-language '(math maple)) |
| 3151 (if (and prec (> prec 191)) | |
| 3152 "(%s*10.^%d)" "%s*10.^%d") | |
| 3153 "%se%d") | |
| 3154 str (- eadj scale))))))) | |
| 3155 str))) | |
| 3156 (t | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3157 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3158 (math-format-number-fancy a prec)))) |
| 40785 | 3159 |
| 3160 (defun math-format-bignum (a) ; [X L] | |
| 3161 (if (and (= calc-number-radix 10) | |
| 3162 (not calc-leading-zeros) | |
| 3163 (not calc-group-digits)) | |
| 3164 (math-format-bignum-decimal a) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3165 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3166 (math-format-bignum-fancy a))) |
| 40785 | 3167 |
| 3168 (defun math-format-bignum-decimal (a) ; [X L] | |
| 3169 (if a | |
| 3170 (let ((s "")) | |
| 3171 (while (cdr (cdr a)) | |
| 3172 (setq s (concat (format "%06d" (+ (* (nth 1 a) 1000) (car a))) s) | |
| 3173 a (cdr (cdr a)))) | |
| 3174 (concat (int-to-string (+ (* (or (nth 1 a) 0) 1000) (car a))) s)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3175 "0")) |
| 40785 | 3176 |
| 3177 | |
| 3178 | |
| 3179 ;;; Parse a simple number in string form. [N X] [Public] | |
| 3180 (defun math-read-number (s) | |
| 3181 (math-normalize | |
| 3182 (cond | |
| 3183 | |
| 3184 ;; Integers (most common case) | |
| 3185 ((string-match "\\` *\\([0-9]+\\) *\\'" s) | |
| 3186 (let ((digs (math-match-substring s 1))) | |
| 3187 (if (and (eq calc-language 'c) | |
| 3188 (> (length digs) 1) | |
| 3189 (eq (aref digs 0) ?0)) | |
| 3190 (math-read-number (concat "8#" digs)) | |
| 3191 (if (<= (length digs) 6) | |
| 3192 (string-to-int digs) | |
| 3193 (cons 'bigpos (math-read-bignum digs)))))) | |
| 3194 | |
| 3195 ;; Clean up the string if necessary | |
| 3196 ((string-match "\\`\\(.*\\)[ \t\n]+\\([^\001]*\\)\\'" s) | |
| 3197 (math-read-number (concat (math-match-substring s 1) | |
| 3198 (math-match-substring s 2)))) | |
| 3199 | |
| 3200 ;; Plus and minus signs | |
| 3201 ((string-match "^[-_+]\\(.*\\)$" s) | |
| 3202 (let ((val (math-read-number (math-match-substring s 1)))) | |
| 3203 (and val (if (eq (aref s 0) ?+) val (math-neg val))))) | |
| 3204 | |
| 3205 ;; Forms that require extensions module | |
| 3206 ((string-match "[^-+0-9eE.]" s) | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3207 (require 'calc-ext) |
| 40785 | 3208 (math-read-number-fancy s)) |
| 3209 | |
| 3210 ;; Decimal point | |
| 3211 ((string-match "^\\([0-9]*\\)\\.\\([0-9]*\\)$" s) | |
| 3212 (let ((int (math-match-substring s 1)) | |
| 3213 (frac (math-match-substring s 2))) | |
| 3214 (let ((ilen (length int)) | |
| 3215 (flen (length frac))) | |
| 3216 (let ((int (if (> ilen 0) (math-read-number int) 0)) | |
| 3217 (frac (if (> flen 0) (math-read-number frac) 0))) | |
| 3218 (and int frac (or (> ilen 0) (> flen 0)) | |
| 3219 (list 'float | |
| 3220 (math-add (math-scale-int int flen) frac) | |
| 3221 (- flen))))))) | |
| 3222 | |
| 3223 ;; "e" notation | |
| 3224 ((string-match "^\\(.*\\)[eE]\\([-+]?[0-9]+\\)$" s) | |
| 3225 (let ((mant (math-match-substring s 1)) | |
| 3226 (exp (math-match-substring s 2))) | |
| 3227 (let ((mant (if (> (length mant) 0) (math-read-number mant) 1)) | |
| 3228 (exp (if (<= (length exp) (if (memq (aref exp 0) '(?+ ?-)) 8 7)) | |
| 3229 (string-to-int exp)))) | |
| 3230 (and mant exp (Math-realp mant) (> exp -4000000) (< exp 4000000) | |
| 3231 (let ((mant (math-float mant))) | |
| 3232 (list 'float (nth 1 mant) (+ (nth 2 mant) exp))))))) | |
| 3233 | |
| 3234 ;; Syntax error! | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3235 (t nil)))) |
| 40785 | 3236 |
| 3237 (defun math-match-substring (s n) | |
| 3238 (if (match-beginning n) | |
| 3239 (substring s (match-beginning n) (match-end n)) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3240 "")) |
| 40785 | 3241 |
| 3242 (defun math-read-bignum (s) ; [l X] | |
| 3243 (if (> (length s) 3) | |
| 3244 (cons (string-to-int (substring s -3)) | |
| 3245 (math-read-bignum (substring s 0 -3))) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3246 (list (string-to-int s)))) |
| 40785 | 3247 |
| 3248 | |
| 3249 (defconst math-tex-ignore-words | |
| 3250 '( ("\\hbox") ("\\mbox") ("\\text") ("\\left") ("\\right") | |
| 3251 ("\\,") ("\\>") ("\\:") ("\\;") ("\\!") ("\\ ") | |
| 3252 ("\\quad") ("\\qquad") ("\\hfil") ("\\hfill") | |
| 3253 ("\\displaystyle") ("\\textstyle") ("\\dsize") ("\\tsize") | |
| 3254 ("\\scriptstyle") ("\\scriptscriptstyle") ("\\ssize") ("\\sssize") | |
| 3255 ("\\rm") ("\\bf") ("\\it") ("\\sl") | |
| 3256 ("\\roman") ("\\bold") ("\\italic") ("\\slanted") | |
| 3257 ("\\cal") ("\\mit") ("\\Cal") ("\\Bbb") ("\\frak") ("\\goth") | |
| 3258 ("\\evalto") | |
| 3259 ("\\matrix" mat) ("\\bmatrix" mat) ("\\pmatrix" mat) | |
| 3260 ("\\cr" punc ";") ("\\\\" punc ";") ("\\*" punc "*") | |
| 3261 ("\\{" punc "[") ("\\}" punc "]") | |
| 3262 )) | |
| 3263 | |
| 3264 (defconst math-eqn-ignore-words | |
| 3265 '( ("roman") ("bold") ("italic") ("mark") ("lineup") ("evalto") | |
| 3266 ("left" ("floor") ("ceil")) | |
| 3267 ("right" ("floor") ("ceil")) | |
| 3268 ("arc" ("sin") ("cos") ("tan") ("sinh") ("cosh") ("tanh")) | |
| 3269 ("size" n) ("font" n) ("fwd" n) ("back" n) ("up" n) ("down" n) | |
| 3270 ("above" punc ",") | |
| 3271 )) | |
| 3272 | |
| 3273 (defconst math-standard-opers | |
| 3274 '( ( "_" calcFunc-subscr 1200 1201 ) | |
| 3275 ( "%" calcFunc-percent 1100 -1 ) | |
| 3276 ( "u+" ident -1 1000 ) | |
| 3277 ( "u-" neg -1 1000 197 ) | |
| 3278 ( "u!" calcFunc-lnot -1 1000 ) | |
| 3279 ( "mod" mod 400 400 185 ) | |
| 3280 ( "+/-" sdev 300 300 185 ) | |
| 3281 ( "!!" calcFunc-dfact 210 -1 ) | |
| 3282 ( "!" calcFunc-fact 210 -1 ) | |
| 3283 ( "^" ^ 201 200 ) | |
| 3284 ( "**" ^ 201 200 ) | |
| 3285 ( "*" * 196 195 ) | |
| 3286 ( "2x" * 196 195 ) | |
| 3287 ( "/" / 190 191 ) | |
| 3288 ( "%" % 190 191 ) | |
| 3289 ( "\\" calcFunc-idiv 190 191 ) | |
| 3290 ( "+" + 180 181 ) | |
| 3291 ( "-" - 180 181 ) | |
| 3292 ( "|" | 170 171 ) | |
| 3293 ( "<" calcFunc-lt 160 161 ) | |
| 3294 ( ">" calcFunc-gt 160 161 ) | |
| 3295 ( "<=" calcFunc-leq 160 161 ) | |
| 3296 ( ">=" calcFunc-geq 160 161 ) | |
| 3297 ( "=" calcFunc-eq 160 161 ) | |
| 3298 ( "==" calcFunc-eq 160 161 ) | |
| 3299 ( "!=" calcFunc-neq 160 161 ) | |
| 3300 ( "&&" calcFunc-land 110 111 ) | |
| 3301 ( "||" calcFunc-lor 100 101 ) | |
| 3302 ( "?" (math-read-if) 91 90 ) | |
| 3303 ( "!!!" calcFunc-pnot -1 85 ) | |
| 3304 ( "&&&" calcFunc-pand 80 81 ) | |
| 3305 ( "|||" calcFunc-por 75 76 ) | |
| 3306 ( ":=" calcFunc-assign 51 50 ) | |
| 3307 ( "::" calcFunc-condition 45 46 ) | |
| 3308 ( "=>" calcFunc-evalto 40 41 ) | |
|
41270
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
3309 ( "=>" calcFunc-evalto 40 -1 ))) |
|
711f18abaf57
(calc-record-compilation-date): Remove.
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
3310 (defvar math-expr-opers math-standard-opers) |
| 40785 | 3311 |
| 3312 ;;;###autoload | |
| 3313 (defun calc-grab-region (top bot arg) | |
| 3314 "Parse the region as a vector of numbers and push it on the Calculator stack." | |
| 3315 (interactive "r\nP") | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3316 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3317 (calc-do-grab-region top bot arg)) |
| 40785 | 3318 |
| 3319 ;;;###autoload | |
| 3320 (defun calc-grab-rectangle (top bot arg) | |
| 3321 "Parse a rectangle as a matrix of numbers and push it on the Calculator stack." | |
| 3322 (interactive "r\nP") | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3323 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3324 (calc-do-grab-rectangle top bot arg)) |
| 40785 | 3325 |
| 3326 (defun calc-grab-sum-down (top bot arg) | |
| 3327 "Parse a rectangle as a matrix of numbers and sum its columns." | |
| 3328 (interactive "r\nP") | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3329 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3330 (calc-do-grab-rectangle top bot arg 'calcFunc-reduced)) |
| 40785 | 3331 |
| 3332 (defun calc-grab-sum-across (top bot arg) | |
| 3333 "Parse a rectangle as a matrix of numbers and sum its rows." | |
| 3334 (interactive "r\nP") | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3335 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3336 (calc-do-grab-rectangle top bot arg 'calcFunc-reducea)) |
| 40785 | 3337 |
| 3338 | |
| 3339 ;;;###autoload | |
| 3340 (defun calc-embedded (arg &optional end obeg oend) | |
| 3341 "Start Calc Embedded mode on the formula surrounding point." | |
| 3342 (interactive "P") | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3343 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3344 (calc-do-embedded arg end obeg oend)) |
| 40785 | 3345 |
| 3346 ;;;###autoload | |
| 3347 (defun calc-embedded-activate (&optional arg cbuf) | |
| 3348 "Scan the current editing buffer for all embedded := and => formulas. | |
| 3349 Also looks for the equivalent TeX words, \\gets and \\evalto." | |
| 3350 (interactive "P") | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3351 (calc-do-embedded-activate arg cbuf)) |
| 40785 | 3352 |
| 3353 (defun calc-user-invocation () | |
| 3354 (interactive) | |
| 45769 | 3355 (unless (stringp calc-invocation-macro) |
| 3356 (error "Use `Z I' inside Calc to define a `M-# Z' keyboard macro")) | |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3357 (execute-kbd-macro calc-invocation-macro nil)) |
| 40785 | 3358 |
| 3359 ;;; User-programmability. | |
| 3360 | |
| 3361 ;;;###autoload | |
| 3362 (defmacro defmath (func args &rest body) ; [Public] | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3363 (require 'calc-ext) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3364 (math-do-defmath func args body)) |
| 40785 | 3365 |
| 3366 ;;; Functions needed for Lucid Emacs support. | |
| 3367 | |
| 3368 (defun calc-read-key (&optional optkey) | |
| 3369 (cond (calc-emacs-type-lucid | |
| 3370 (let ((event (next-command-event))) | |
| 3371 (let ((key (event-to-character event t t))) | |
| 3372 (or key optkey (error "Expected a plain keystroke")) | |
| 3373 (cons key event)))) | |
|
57591
98d755565607
(calc-emacs-type-19, calc-emacs-type-epoch, calc-emacs-type-gnu19):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57429
diff
changeset
|
3374 (t |
| 40785 | 3375 (let ((key (read-event))) |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3376 (cons key key))))) |
| 40785 | 3377 |
| 3378 (defun calc-unread-command (&optional input) | |
|
40999
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
3379 (if (featurep 'xemacs) |
|
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
3380 (setq unread-command-event |
|
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
3381 (if (integerp input) (character-to-event input) |
|
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
3382 (or input last-command-event))) |
|
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
3383 (push (or input last-command-event) unread-command-events))) |
| 40785 | 3384 |
| 3385 (defun calc-clear-unread-commands () | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
3386 (if (featurep 'xemacs) |
| 40785 | 3387 (calc-emacs-type-lucid (setq unread-command-event nil)) |
|
40999
d5ccdce87268
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40911
diff
changeset
|
3388 (setq unread-command-events nil))) |
| 40785 | 3389 |
| 45769 | 3390 (when calc-always-load-extensions |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3391 (require 'calc-ext) |
| 45769 | 3392 (calc-load-everything)) |
| 40785 | 3393 |
| 3394 | |
| 3395 (run-hooks 'calc-load-hook) | |
| 3396 | |
|
58615
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3397 (provide 'calc) |
|
bba6d2de0a93
Move require to end of file.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58477
diff
changeset
|
3398 |
| 52401 | 3399 ;;; arch-tag: 0c3b170c-4ce6-4eaf-8d9b-5834d1fe938f |
|
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40999
diff
changeset
|
3400 ;;; calc.el ends here |
