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