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