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