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