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