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