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