annotate lisp/calc/calc-aent.el @ 109234:810852b2385b

Merge from mainline.
author Katsumi Yamaoka <katsumi@flagship2>
date Sat, 03 Jul 2010 11:08:43 +0000
parents d150a25a0eb9
children 6ea012a6203d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
1 ;;; calc-aent.el --- algebraic entry functions for Calc
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
2
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005,
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
5
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
6 ;; Author: Dave Gillespie <daveg@synaptics.com>
77465
1154f082efd9 Update maintainer's address.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 76595
diff changeset
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10
94654
6c9af2bfcfee Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93880
diff changeset
11 ;; 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
12 ;; 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: 93880
diff changeset
13 ;; 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: 93880
diff changeset
14 ;; (at your option) any later version.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15
76595
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
17 ;; 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
18 ;; 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
19 ;; 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
20
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
21 ;; 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: 93880
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
24 ;;; Commentary:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
26 ;;; Code:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28 ;; This file is autoloaded from calc.el.
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
29
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30 (require 'calc)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 (require 'calc-macs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32
86466
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
33 ;; Declare functions which are defined elsewhere.
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
34 (declare-function calc-refresh-evaltos "calc-ext" (&optional which-var))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
35 (declare-function calc-execute-kbd-macro "calc-prog" (mac arg &rest prefix))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
36 (declare-function math-is-true "calc-ext" (expr))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
37 (declare-function calc-explain-why "calc-stuff" (why &optional more))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
38 (declare-function calc-alg-edit "calc-yank" (str))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
39 (declare-function math-composite-inequalities "calc-prog" (x op))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
40 (declare-function math-flatten-lands "calc-rewr" (expr))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
41 (declare-function math-multi-subst "calc-map" (expr olds news))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
42 (declare-function calcFunc-vmatches "calc-rewr" (expr pat))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
43 (declare-function math-simplify "calc-alg" (top-expr))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
44 (declare-function math-known-matrixp "calc-arith" (a))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
45 (declare-function math-parse-fortran-subscr "calc-lang" (sym args))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
46 (declare-function math-to-radians-2 "calc-math" (a))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
47 (declare-function math-read-string "calc-ext" ())
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
48 (declare-function math-read-brackets "calc-vec" (space-sep math-rb-close))
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
49 (declare-function math-read-angle-brackets "calc-forms" ())
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
50 (declare-function math-to-percentsigns "calccomp" (x))
86466
7777ff0392d6 (calc-refresh-evaltos, calc-execute-kbd-macro)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86165
diff changeset
51
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
52 (defvar calc-quick-calc-history nil
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
53 "The history list for quick-calc.")
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
54
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
55 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
56 (defun calc-do-quick-calc ()
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
57 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
58 (calc-check-defines)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
59 (if (eq major-mode 'calc-mode)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
60 (calc-algebraic-entry t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
61 (let (buf shortbuf)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
62 (save-excursion
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
63 (calc-create-buffer)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
64 (let* ((calc-command-flags nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
65 (calc-dollar-values calc-quick-prev-results)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
66 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67 (enable-recursive-minibuffers t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 (calc-language (if (memq calc-language '(nil big))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
69 'flat calc-language))
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
70 (entry (calc-do-alg-entry "" "Quick calc: " t 'calc-quick-calc-history))
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
71 (alg-exp (mapcar 'math-evaluate-expr entry)))
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
72 (when (and (= (length alg-exp) 1)
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
73 (eq (car-safe (car alg-exp)) 'calcFunc-assign)
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
74 (= (length (car alg-exp)) 3)
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
75 (eq (car-safe (nth 1 (car alg-exp))) 'var))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
76 (set (nth 2 (nth 1 (car alg-exp))) (nth 2 (car alg-exp)))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
77 (calc-refresh-evaltos (nth 2 (nth 1 (car alg-exp))))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
78 (setq alg-exp (list (nth 2 (car alg-exp)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
79 (setq calc-quick-prev-results alg-exp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
80 buf (mapconcat (function (lambda (x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81 (math-format-value x 1000)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
82 alg-exp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
83 " ")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
84 shortbuf buf)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
85 (if (and (= (length alg-exp) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86 (memq (car-safe (car alg-exp)) '(nil bigpos bigneg))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
87 (< (length buf) 20)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
88 (= calc-number-radix 10))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 (setq buf (concat buf " ("
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 (let ((calc-number-radix 16))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 (math-format-value (car alg-exp) 1000))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92 ", "
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
93 (let ((calc-number-radix 8))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
94 (math-format-value (car alg-exp) 1000))
82378
b4a5bc0f9436 calc-aent.el
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82140
diff changeset
95 ", "
b4a5bc0f9436 calc-aent.el
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82140
diff changeset
96 (let ((calc-number-radix 2))
b4a5bc0f9436 calc-aent.el
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82140
diff changeset
97 (math-format-value (car alg-exp) 1000))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
98 (if (and (integerp (car alg-exp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
99 (> (car alg-exp) 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
100 (< (car alg-exp) 127))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
101 (format ", \"%c\"" (car alg-exp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102 "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
103 ")")))
40909
09249b7679f6 (toplevel): Require calc-macs during compilation.
Eli Zaretskii <eliz@gnu.org>
parents: 40785
diff changeset
104 (if (and (< (length buf) (frame-width)) (= (length entry) 1)
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
105 (featurep 'calc-ext))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
106 (let ((long (concat (math-format-value (car entry) 1000)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
107 " => " buf)))
40909
09249b7679f6 (toplevel): Require calc-macs during compilation.
Eli Zaretskii <eliz@gnu.org>
parents: 40785
diff changeset
108 (if (<= (length long) (- (frame-width) 8))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 (setq buf long))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 (calc-handle-whys)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111 (message "Result: %s" buf)))
101001
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
112 (if (eq last-command-event 10)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
113 (insert shortbuf)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
114 (kill-new shortbuf)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
116 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
117 (defun calc-do-calc-eval (str separator args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
118 (calc-check-defines)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
119 (catch 'calc-error
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120 (save-excursion
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
121 (calc-create-buffer)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
122 (cond
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
123 ((and (consp str) (not (symbolp (car str))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 (let ((calc-language nil)
81467
a90e4a0758e3 (calc-do-calc-eval): Let math-expr-opers equal the function
Jay Belanger <jay.p.belanger@gmail.com>
parents: 77465
diff changeset
125 (math-expr-opers (math-standard-ops))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 (calc-internal-prec 12)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127 (calc-word-size 32)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128 (calc-symbolic-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 (calc-matrix-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
130 (calc-angle-mode 'deg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131 (calc-number-radix 10)
106136
72136220d7f5 (calc-do-calc-eval): Let `calc-twos-complement-mode' be nil.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106037
diff changeset
132 (calc-twos-complement-mode nil)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 (calc-leading-zeros nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 (calc-group-digits nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 (calc-point-char ".")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136 (calc-frac-format '(":" nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 (calc-prefer-frac nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 (calc-hms-format "%s@ %s' %s\"")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 (calc-date-format '((H ":" mm C SS pp " ")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 Www " " Mmm " " D ", " YYYY))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141 (calc-float-format '(float 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 (calc-full-float-format '(float 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 (calc-complex-format nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144 (calc-matrix-just nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145 (calc-full-vectors t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 (calc-break-vectors nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 (calc-vector-commas ",")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148 (calc-vector-brackets "[]")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (calc-matrix-brackets '(R O))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 (calc-complex-mode 'cplx)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
151 (calc-infinite-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152 (calc-display-strings nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 (calc-simplify-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154 (calc-display-working-message 'lots)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 (strp (cdr str)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156 (while strp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
157 (set (car strp) (nth 1 strp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 (setq strp (cdr (cdr strp))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159 (calc-do-calc-eval (car str) separator args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 ((eq separator 'eval)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
161 (eval str))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162 ((eq separator 'macro)
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
163 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164 (let* ((calc-buffer (current-buffer))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 (calc-window (get-buffer-window calc-buffer))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 (save-window (selected-window)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167 (if calc-window
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168 (unwind-protect
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
169 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170 (select-window calc-window)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171 (calc-execute-kbd-macro str nil (car args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
172 (and (window-point save-window)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173 (select-window save-window)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
174 (save-window-excursion
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
175 (select-window (get-largest-window))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176 (switch-to-buffer calc-buffer)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 (calc-execute-kbd-macro str nil (car args)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
179 ((eq separator 'pop)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
180 (or (not (integerp str))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
181 (= str 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 (calc-pop (min str (calc-stack-size))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 (calc-stack-size))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184 ((eq separator 'top)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185 (and (integerp str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
186 (> str 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 (<= str (calc-stack-size))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188 (math-format-value (calc-top-n str (car args)) 1000)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189 ((eq separator 'rawtop)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190 (and (integerp str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
191 (> str 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192 (<= str (calc-stack-size))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 (calc-top-n str (car args))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194 (t
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
195 (let* ((calc-command-flags nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196 (calc-next-why nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
197 (calc-language (if (memq calc-language '(nil big))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
198 'flat calc-language))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
199 (calc-dollar-values (mapcar
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
200 (function
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
201 (lambda (x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
202 (if (stringp x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
204 (setq x (math-read-exprs x))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
205 (if (eq (car-safe x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
206 'error)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
207 (throw 'calc-error
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
208 (calc-eval-error
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
209 (cdr x)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
210 (car x)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
211 x)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
212 args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
213 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
214 (res (if (stringp str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
215 (math-read-exprs str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
216 (list str)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
217 buf)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
218 (if (eq (car res) 'error)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
219 (calc-eval-error (cdr res))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
220 (setq res (mapcar 'calc-normalize res))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
221 (and (memq 'clear-message calc-command-flags)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
222 (message ""))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
223 (cond ((eq separator 'pred)
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
224 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
225 (if (= (length res) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
226 (math-is-true (car res))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
227 (calc-eval-error '(0 "Single value expected"))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
228 ((eq separator 'raw)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
229 (if (= (length res) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
230 (car res)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
231 (calc-eval-error '(0 "Single value expected"))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
232 ((eq separator 'list)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
233 res)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
234 ((memq separator '(num rawnum))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
235 (if (= (length res) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
236 (if (math-constp (car res))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
237 (if (eq separator 'num)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
238 (math-format-value (car res) 1000)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
239 (car res))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
240 (calc-eval-error
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
241 (list 0
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
242 (if calc-next-why
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
243 (calc-explain-why (car calc-next-why))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
244 "Number expected"))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
245 (calc-eval-error '(0 "Single value expected"))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
246 ((eq separator 'push)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
247 (calc-push-list res)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
248 nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
249 (t (while res
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
250 (setq buf (concat buf
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
251 (and buf (or separator ", "))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
252 (math-format-value (car res) 1000))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
253 res (cdr res)))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
254 buf)))))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
255
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
256 (defvar calc-eval-error nil
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
257 "Determines how calc handles errors.
74579
d5f79339859e (calc-eval-error): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 72037
diff changeset
258 If nil, return a list containing the character position of error.
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
259 STRING means return error message as string rather than list.
74579
d5f79339859e (calc-eval-error): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 72037
diff changeset
260 The value t means abort and give an error message.")
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
261
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
262 (defun calc-eval-error (msg)
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
263 (if calc-eval-error
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
264 (if (eq calc-eval-error 'string)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
265 (nth 1 msg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266 (error "%s" (nth 1 msg)))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
267 msg))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
268
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
269
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
270 ;;;; Reading an expression in algebraic form.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
271
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
272 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273 (defun calc-auto-algebraic-entry (&optional prefix)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 (interactive "P")
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
275 (calc-algebraic-entry prefix t))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
276
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
277 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
278 (defun calc-algebraic-entry (&optional prefix auto)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
279 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
280 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
281 (let ((calc-language (if prefix nil calc-language))
81467
a90e4a0758e3 (calc-do-calc-eval): Let math-expr-opers equal the function
Jay Belanger <jay.p.belanger@gmail.com>
parents: 77465
diff changeset
282 (math-expr-opers (if prefix (math-standard-ops) (math-expr-ops))))
101001
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
283 (calc-alg-entry (and auto (char-to-string last-command-event))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
284
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
285 (defvar calc-alg-entry-history nil
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
286 "History for algebraic entry.")
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
287
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
288 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
289 (defun calc-alg-entry (&optional initial prompt)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
290 (let* ((sel-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
291 (calc-dollar-values (mapcar 'calc-get-stack-element
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
292 (nthcdr calc-stack-top calc-stack)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
294 (calc-plain-entry t)
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
295 (alg-exp (calc-do-alg-entry initial prompt t 'calc-alg-entry-history)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
296 (if (stringp alg-exp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
297 (progn
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
298 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
299 (calc-alg-edit alg-exp))
101001
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
300 (let* ((calc-simplify-mode (if (eq last-command-event ?\C-j)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
301 'none
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
302 calc-simplify-mode))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
303 (nvals (mapcar 'calc-normalize alg-exp)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
304 (while alg-exp
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
305 (calc-record (if (featurep 'calc-ext) (car alg-exp) (car nvals))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
306 "alg'")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
307 (calc-pop-push-record-list calc-dollar-used
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308 (and (not (equal (car alg-exp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
309 (car nvals)))
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
310 (featurep 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
311 "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
312 (list (car nvals)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
313 (setq alg-exp (cdr alg-exp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
314 nvals (cdr nvals)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
315 calc-dollar-used 0)))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
316 (calc-handle-whys))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
317
57635
b1a458fd1ca9 (calc-alg-ent-map, calc-alg-ent-esc-map): Declared these variables
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57595
diff changeset
318 (defvar calc-alg-ent-map nil
b1a458fd1ca9 (calc-alg-ent-map, calc-alg-ent-esc-map): Declared these variables
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57595
diff changeset
319 "The keymap used for algebraic entry.")
b1a458fd1ca9 (calc-alg-ent-map, calc-alg-ent-esc-map): Declared these variables
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57595
diff changeset
320
b1a458fd1ca9 (calc-alg-ent-map, calc-alg-ent-esc-map): Declared these variables
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57595
diff changeset
321 (defvar calc-alg-ent-esc-map nil
b1a458fd1ca9 (calc-alg-ent-map, calc-alg-ent-esc-map): Declared these variables
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57595
diff changeset
322 "The keymap used for escapes in algebraic entry.")
b1a458fd1ca9 (calc-alg-ent-map, calc-alg-ent-esc-map): Declared these variables
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57595
diff changeset
323
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
324 (defvar calc-alg-exp)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
325
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
326 ;;;###autoload
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
327 (defun calc-do-alg-entry (&optional initial prompt no-normalize history)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
328 (let* ((calc-buffer (current-buffer))
40995
e29926a2ef59 (calc-do-alg-entry): Use
Eli Zaretskii <eliz@gnu.org>
parents: 40909
diff changeset
329 (blink-paren-function 'calcAlg-blink-matching-open)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
330 (calc-alg-exp 'error))
57635
b1a458fd1ca9 (calc-alg-ent-map, calc-alg-ent-esc-map): Declared these variables
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57595
diff changeset
331 (unless calc-alg-ent-map
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
332 (setq calc-alg-ent-map (copy-keymap minibuffer-local-map))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
333 (define-key calc-alg-ent-map "'" 'calcAlg-previous)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
334 (define-key calc-alg-ent-map "`" 'calcAlg-edit)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
335 (define-key calc-alg-ent-map "\C-m" 'calcAlg-enter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
336 (define-key calc-alg-ent-map "\C-j" 'calcAlg-enter)
57590
afc7ff1f1214 (calc-do-alg-entry): Remove Emacs version check. Use `copy-keymap' to
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
337 (let ((i 33))
afc7ff1f1214 (calc-do-alg-entry): Remove Emacs version check. Use `copy-keymap' to
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
338 (setq calc-alg-ent-esc-map (copy-keymap esc-map))
afc7ff1f1214 (calc-do-alg-entry): Remove Emacs version check. Use `copy-keymap' to
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
339 (while (< i 127)
afc7ff1f1214 (calc-do-alg-entry): Remove Emacs version check. Use `copy-keymap' to
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
340 (aset (nth 1 calc-alg-ent-esc-map) i 'calcAlg-escape)
afc7ff1f1214 (calc-do-alg-entry): Remove Emacs version check. Use `copy-keymap' to
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
341 (setq i (1+ i)))))
afc7ff1f1214 (calc-do-alg-entry): Remove Emacs version check. Use `copy-keymap' to
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
342 (define-key calc-alg-ent-map "\e" nil)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 (if (eq calc-algebraic-mode 'total)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
344 (define-key calc-alg-ent-map "\e" calc-alg-ent-esc-map)
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
345 (define-key calc-alg-ent-map "\e+" 'calcAlg-plus-minus)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
346 (define-key calc-alg-ent-map "\em" 'calcAlg-mod)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
347 (define-key calc-alg-ent-map "\e=" 'calcAlg-equals)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
348 (define-key calc-alg-ent-map "\e\r" 'calcAlg-equals)
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
349 (define-key calc-alg-ent-map "\ep" 'previous-history-element)
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
350 (define-key calc-alg-ent-map "\en" 'next-history-element)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
351 (define-key calc-alg-ent-map "\e%" 'self-insert-command))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
352 (setq calc-aborted-prefix nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
353 (let ((buf (read-from-minibuffer (or prompt "Algebraic: ")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
354 (or initial "")
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
355 calc-alg-ent-map nil history)))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
356 (when (eq calc-alg-exp 'error)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
357 (when (eq (car-safe (setq calc-alg-exp (math-read-exprs buf))) 'error)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
358 (setq calc-alg-exp nil)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
359 (setq calc-aborted-prefix "alg'")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360 (or no-normalize
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
361 (and calc-alg-exp (setq calc-alg-exp (mapcar 'calc-normalize calc-alg-exp))))
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
362 calc-alg-exp)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
363
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
364 (defun calcAlg-plus-minus ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
365 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
366 (if (calc-minibuffer-contains ".* \\'")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
367 (insert "+/- ")
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
368 (insert " +/- ")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
369
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
370 (defun calcAlg-mod ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
371 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
372 (if (not (calc-minibuffer-contains ".* \\'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
373 (insert " "))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
374 (if (calc-minibuffer-contains ".* mod +\\'")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
375 (if calc-previous-modulo
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
376 (insert (math-format-flat-expr calc-previous-modulo 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
377 (beep))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
378 (insert "mod ")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
379
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
380 (defun calcAlg-previous ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381 (interactive)
57595
8ca090ac0a97 (calcAlg-previous): Changed the regexp to the end of buffer regexp.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57590
diff changeset
382 (if (calc-minibuffer-contains "\\'")
72037
52f1e8d569ad (calcAlg-edit, calcAlg-enter): Remove reference to calc-previous-alg-entry.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
383 (previous-history-element 1)
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
384 (insert "'")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
385
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
386 (defun calcAlg-equals ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
387 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
388 (unwind-protect
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
389 (calcAlg-enter)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
390 (if (consp calc-alg-exp)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
391 (progn (setq prefix-arg (length calc-alg-exp))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
392 (calc-unread-command ?=)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
393
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
394 (defun calcAlg-escape ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
395 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
396 (calc-unread-command)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
397 (save-excursion
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
398 (calc-select-buffer)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
399 (use-local-map calc-mode-map))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
400 (calcAlg-enter))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
401
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
402 (defvar calc-plain-entry nil)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
403 (defun calcAlg-edit ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
404 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
405 (if (or (not calc-plain-entry)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
406 (calc-minibuffer-contains
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407 "\\`\\([^\"]*\"[^\"]*\"\\)*[^\"]*\"[^\"]*\\'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
408 (insert "`")
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
409 (setq calc-alg-exp (minibuffer-contents))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
410 (exit-minibuffer)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
412 (defvar calc-buffer)
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
413
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414 (defun calcAlg-enter ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
415 (interactive)
40909
09249b7679f6 (toplevel): Require calc-macs during compilation.
Eli Zaretskii <eliz@gnu.org>
parents: 40785
diff changeset
416 (let* ((str (minibuffer-contents))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
417 (exp (and (> (length str) 0)
105792
2c12fbae77c2 * calc/calc.el (calc, calc-refresh, calc-trail-buffer, calc-record)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101001
diff changeset
418 (with-current-buffer calc-buffer
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
419 (math-read-exprs str)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
420 (if (eq (car-safe exp) 'error)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
421 (progn
40909
09249b7679f6 (toplevel): Require calc-macs during compilation.
Eli Zaretskii <eliz@gnu.org>
parents: 40785
diff changeset
422 (goto-char (minibuffer-prompt-end))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
423 (forward-char (nth 1 exp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
424 (beep)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
425 (calc-temp-minibuffer-message
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
426 (concat " [" (or (nth 2 exp) "Error") "]"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
427 (calc-clear-unread-commands))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
428 (setq calc-alg-exp (if (calc-minibuffer-contains "\\` *\\[ *\\'")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
429 '((incomplete vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
430 exp))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
431 (exit-minibuffer))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
432
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
433 (defun calcAlg-blink-matching-open ()
59037
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
434 (let ((rightpt (point))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
435 (leftpt nil)
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
436 (rightchar (preceding-char))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
437 leftchar
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
438 rightsyntax
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
439 leftsyntax)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
440 (save-excursion
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
441 (condition-case ()
59037
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
442 (setq leftpt (scan-sexps rightpt -1)
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
443 leftchar (char-after leftpt))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
444 (error nil)))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
445 (if (and leftpt
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
446 (or (and (= rightchar ?\))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
447 (= leftchar ?\[))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
448 (and (= rightchar ?\])
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
449 (= leftchar ?\()))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
450 (save-excursion
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
451 (goto-char leftpt)
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
452 (looking-at ".+\\(\\.\\.\\|\\\\dots\\|\\\\ldots\\)")))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
453 (let ((leftsaved (aref (syntax-table) leftchar))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
454 (rightsaved (aref (syntax-table) rightchar)))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
455 (unwind-protect
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
456 (progn
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
457 (cond ((= leftchar ?\[)
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
458 (aset (syntax-table) leftchar (cons 4 ?\)))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
459 (aset (syntax-table) rightchar (cons 5 ?\[)))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
460 (t
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
461 (aset (syntax-table) leftchar (cons 4 ?\]))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
462 (aset (syntax-table) rightchar (cons 5 ?\())))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
463 (blink-matching-open))
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
464 (aset (syntax-table) leftchar leftsaved)
d572ad446699 (calcAlg-blank-matching-open): Temporarily adjust the syntax of both
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58843
diff changeset
465 (aset (syntax-table) rightchar rightsaved)))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
466 (blink-matching-open))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
467
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
468 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
469 (defun calc-alg-digit-entry ()
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49262
diff changeset
470 (calc-alg-entry
101001
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
471 (cond ((eq last-command-event ?e)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
472 (if (> calc-number-radix 14) (format "%d.^" calc-number-radix) "1e"))
101001
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
473 ((eq last-command-event ?#) (format "%d#" calc-number-radix))
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
474 ((eq last-command-event ?_) "-")
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
475 ((eq last-command-event ?@) "0@ ")
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
476 (t (char-to-string last-command-event)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
477
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
478 ;; The variable calc-digit-value is initially declared in calc.el,
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
479 ;; but can be set by calcDigit-algebraic and calcDigit-edit.
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
480 (defvar calc-digit-value)
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
481
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
482 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
483 (defun calcDigit-algebraic ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
484 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
485 (if (calc-minibuffer-contains ".*[@oh] *[^'m ]+[^'m]*\\'")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
486 (calcDigit-key)
40909
09249b7679f6 (toplevel): Require calc-macs during compilation.
Eli Zaretskii <eliz@gnu.org>
parents: 40785
diff changeset
487 (setq calc-digit-value (minibuffer-contents))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
488 (exit-minibuffer)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
489
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
490 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
491 (defun calcDigit-edit ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
492 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
493 (calc-unread-command)
40909
09249b7679f6 (toplevel): Require calc-macs during compilation.
Eli Zaretskii <eliz@gnu.org>
parents: 40785
diff changeset
494 (setq calc-digit-value (minibuffer-contents))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
495 (exit-minibuffer))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
496
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
497
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
498 ;;; Algebraic expression parsing. [Public]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
499
58843
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
500 (defvar math-read-replacement-list
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
501 '(;; Misc symbols
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
502 ("±" "+/-") ; plus or minus
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
503 ("×" "*") ; multiplication sign
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
504 ("÷" ":") ; division sign
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
505 ("−" "-") ; subtraction sign
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
506 ("∕" "/") ; division sign
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
507 ("∗" "*") ; asterisk multiplication
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
508 ("∞" "inf") ; infinity symbol
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
509 ("≤" "<=")
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
510 ("≥" ">=")
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
511 ("≦" "<=")
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
512 ("≧" ">=")
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
513 ("µ" "μ")
58843
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
514 ;; fractions
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
515 ("¼" "(1:4)") ; 1/4
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
516 ("½" "(1:2)") ; 1/2
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
517 ("¾" "(3:4)") ; 3/4
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
518 ("⅓" "(1:3)") ; 1/3
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
519 ("⅔" "(2:3)") ; 2/3
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
520 ("⅕" "(1:5)") ; 1/5
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
521 ("⅖" "(2:5)") ; 2/5
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
522 ("⅗" "(3:5)") ; 3/5
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
523 ("⅘" "(4:5)") ; 4/5
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
524 ("⅙" "(1:6)") ; 1/6
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
525 ("⅚" "(5:6)") ; 5/6
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
526 ("⅛" "(1:8)") ; 1/8
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
527 ("⅜" "(3:8)") ; 3/8
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
528 ("⅝" "(5:8)") ; 5/8
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
529 ("⅞" "(7:8)") ; 7/8
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
530 ("⅟" "1:") ; 1/...
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
531 ;; superscripts
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
532 ("⁰" "0") ; 0
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
533 ("¹" "1") ; 1
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
534 ("²" "2") ; 2
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
535 ("³" "3") ; 3
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
536 ("⁴" "4") ; 4
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
537 ("⁵" "5") ; 5
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
538 ("⁶" "6") ; 6
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
539 ("⁷" "7") ; 7
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
540 ("⁸" "8") ; 8
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
541 ("⁹" "9") ; 9
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
542 ("⁺" "+") ; +
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
543 ("⁻" "-") ; -
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
544 ("⁽" "(") ; (
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
545 ("⁾" ")") ; )
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
546 ("ⁿ" "n") ; n
61303
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
547 ("ⁱ" "i") ; i
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
548 ;; subscripts
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
549 ("₀" "0") ; 0
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
550 ("₁" "1") ; 1
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
551 ("₂" "2") ; 2
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
552 ("₃" "3") ; 3
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
553 ("₄" "4") ; 4
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
554 ("₅" "5") ; 5
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
555 ("₆" "6") ; 6
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
556 ("₇" "7") ; 7
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
557 ("₈" "8") ; 8
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
558 ("₉" "9") ; 9
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
559 ("₊" "+") ; +
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
560 ("₋" "-") ; -
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
561 ("₍" "(") ; (
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
562 ("₎" ")")) ; )
58843
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
563 "A list whose elements (old new) indicate replacements to make
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
564 in Calc algebraic input.")
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
565
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
566 (defvar math-read-superscripts
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
567 "⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ" ; 0123456789+-()ni
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
568 "A string consisting of the superscripts allowed by Calc.")
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
569
61303
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
570 (defvar math-read-subscripts
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
571 "₀₁₂₃₄₅₆₇₈₉₊₋₍₎" ; 0123456789+-()
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
572 "A string consisting of the subscripts allowed by Calc.")
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
573
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
574 ;;;###autoload
58843
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
575 (defun math-read-preprocess-string (str)
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
576 "Replace some substrings of STR by Calc equivalents."
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
577 (setq str
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
578 (replace-regexp-in-string (concat "[" math-read-superscripts "]+")
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
579 "^(\\&)" str))
61303
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
580 (setq str
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
581 (replace-regexp-in-string (concat "[" math-read-subscripts "]+")
b56d5250fbc3 (math-read-replacement-list): Add subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 60169
diff changeset
582 "_(\\&)" str))
58843
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
583 (let ((rep-list math-read-replacement-list))
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
584 (while rep-list
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
585 (setq str
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
586 (replace-regexp-in-string (nth 0 (car rep-list))
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
587 (nth 1 (car rep-list)) str))
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
588 (setq rep-list (cdr rep-list))))
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
589 str)
f3d24ef9bf58 (math-read-replacement-list, math-read-superscripts): Move from
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58645
diff changeset
590
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
591 ;; The next few variables are local to math-read-exprs (and math-read-expr
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
592 ;; in calc-ext.el), but are set in functions they call.
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
593
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
594 (defvar math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
595 (defvar math-exp-str)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
596 (defvar math-exp-old-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
597 (defvar math-exp-token)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
598 (defvar math-exp-keep-spaces)
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
599 (defvar math-expr-data)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
600
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
601 ;;;###autoload
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
602 (defun math-read-exprs (math-exp-str)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
603 (let ((math-exp-pos 0)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
604 (math-exp-old-pos 0)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
605 (math-exp-keep-spaces nil)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
606 math-exp-token math-expr-data)
58455
61e76fb7d4c9 (math-read-exprs): Filter input through math-read-preprocess-string.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58131
diff changeset
607 (setq math-exp-str (math-read-preprocess-string math-exp-str))
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
608 (if (memq calc-language calc-lang-allow-percentsigns)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
609 (setq math-exp-str (math-remove-percentsigns math-exp-str)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
610 (if calc-language-input-filter
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
611 (setq math-exp-str (funcall calc-language-input-filter math-exp-str)))
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
612 (while (setq math-exp-token
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
613 (string-match "\\.\\.\\([^.]\\|.[^.]\\)" math-exp-str))
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
614 (setq math-exp-str
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
615 (concat (substring math-exp-str 0 math-exp-token) "\\dots"
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
616 (substring math-exp-str (+ math-exp-token 2)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
617 (math-build-parse-table)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
618 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
619 (let ((val (catch 'syntax (math-read-expr-list))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
620 (if (stringp val)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
621 (list 'error math-exp-old-pos val)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
622 (if (equal math-exp-token 'end)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
623 val
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
624 (list 'error math-exp-old-pos "Syntax error"))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
625
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
626 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
627 (defun math-read-expr-list ()
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
628 (let* ((math-exp-keep-spaces nil)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
629 (val (list (math-read-expr-level 0)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
630 (last val))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
631 (while (equal math-expr-data ",")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
632 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
633 (let ((rest (list (math-read-expr-level 0))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
634 (setcdr last rest)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
635 (setq last rest)))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
636 val))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
637
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
638 (defvar calc-user-parse-table nil)
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
639 (defvar calc-last-main-parse-table nil)
86165
8d7e01d03e55 (calc-last-user-lang-parse-table): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82378
diff changeset
640 (defvar calc-last-user-lang-parse-table nil)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
641 (defvar calc-last-lang-parse-table nil)
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
642 (defvar calc-user-tokens nil)
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41039
diff changeset
643 (defvar calc-user-token-chars nil)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
644
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
645 (defvar math-toks nil
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
646 "Tokens to pass between math-build-parse-table and math-find-user-tokens.")
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
647
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
648 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
649 (defun math-build-parse-table ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
650 (let ((mtab (cdr (assq nil calc-user-parse-tables)))
86165
8d7e01d03e55 (calc-last-user-lang-parse-table): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82378
diff changeset
651 (ltab (cdr (assq calc-language calc-user-parse-tables)))
8d7e01d03e55 (calc-last-user-lang-parse-table): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82378
diff changeset
652 (lltab (get calc-language 'math-parse-table)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
653 (or (and (eq mtab calc-last-main-parse-table)
86165
8d7e01d03e55 (calc-last-user-lang-parse-table): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82378
diff changeset
654 (eq ltab calc-last-user-lang-parse-table)
8d7e01d03e55 (calc-last-user-lang-parse-table): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82378
diff changeset
655 (eq lltab calc-last-lang-parse-table))
8d7e01d03e55 (calc-last-user-lang-parse-table): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82378
diff changeset
656 (let ((p (append mtab ltab lltab))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
657 (math-toks nil))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
658 (setq calc-user-parse-table p)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
659 (setq calc-user-token-chars nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
660 (while p
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
661 (math-find-user-tokens (car (car p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
662 (setq p (cdr p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
663 (setq calc-user-tokens (mapconcat 'identity
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
664 (sort (mapcar 'car math-toks)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
665 (function (lambda (x y)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
666 (> (length x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
667 (length y)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
668 "\\|")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
669 calc-last-main-parse-table mtab
86165
8d7e01d03e55 (calc-last-user-lang-parse-table): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82378
diff changeset
670 calc-last-user-lang-parse-table ltab
8d7e01d03e55 (calc-last-user-lang-parse-table): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 82378
diff changeset
671 calc-last-lang-parse-table lltab)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
672
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
673 ;;;###autoload
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
674 (defun math-find-user-tokens (p)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
675 (while p
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
676 (cond ((and (stringp (car p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
677 (or (> (length (car p)) 1) (equal (car p) "$")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
678 (equal (car p) "\""))
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
679 (string-match "[^a-zA-Zα-ωΑ-Ω0-9]" (car p)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
680 (let ((s (regexp-quote (car p))))
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
681 (if (string-match "\\`[a-zA-Zα-ωΑ-Ω0-9]" s)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
682 (setq s (concat "\\<" s)))
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
683 (if (string-match "[a-zA-Zα-ωΑ-Ω0-9]\\'" s)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
684 (setq s (concat s "\\>")))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
685 (or (assoc s math-toks)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
686 (progn
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
687 (setq math-toks (cons (list s) math-toks))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
688 (or (memq (aref (car p) 0) calc-user-token-chars)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
689 (setq calc-user-token-chars
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
690 (cons (aref (car p) 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
691 calc-user-token-chars)))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
692 ((consp (car p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
693 (math-find-user-tokens (nth 1 (car p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
694 (or (eq (car (car p)) '\?)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
695 (math-find-user-tokens (nth 2 (car p))))))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
696 (setq p (cdr p))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
697
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
698 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
699 (defun math-read-token ()
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
700 (if (>= math-exp-pos (length math-exp-str))
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
701 (setq math-exp-old-pos math-exp-pos
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
702 math-exp-token 'end
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
703 math-expr-data "\000")
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
704 (let (adfn
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
705 (ch (aref math-exp-str math-exp-pos)))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
706 (setq math-exp-old-pos math-exp-pos)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
707 (cond ((memq ch '(32 10 9))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
708 (setq math-exp-pos (1+ math-exp-pos))
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
709 (if math-exp-keep-spaces
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
710 (setq math-exp-token 'space
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
711 math-expr-data " ")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
712 (math-read-token)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
713 ((and (memq ch calc-user-token-chars)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
714 (let ((case-fold-search nil))
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
715 (eq (string-match
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
716 calc-user-tokens math-exp-str math-exp-pos)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
717 math-exp-pos)))
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
718 (setq math-exp-token 'punc
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
719 math-expr-data (math-match-substring math-exp-str 0)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
720 math-exp-pos (match-end 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
721 ((or (and (>= ch ?a) (<= ch ?z))
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
722 (and (>= ch ?A) (<= ch ?Z))
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
723 (and (>= ch ?α) (<= ch ?ω))
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
724 (and (>= ch ?Α) (<= ch ?Ω)))
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
725 (string-match
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
726 (cond
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
727 ((and (memq calc-language calc-lang-allow-underscores)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
728 (memq calc-language calc-lang-allow-percentsigns))
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
729 "[a-zA-Zα-ωΑ-Ω0-9_'#]*")
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
730 ((memq calc-language calc-lang-allow-underscores)
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
731 "[a-zA-Zα-ωΑ-Ω0-9_#]*")
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
732 (t "[a-zA-Zα-ωΑ-Ω0-9'#]*"))
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
733 math-exp-str math-exp-pos)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
734 (setq math-exp-token 'symbol
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
735 math-exp-pos (match-end 0)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
736 math-expr-data (math-restore-dashes
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
737 (math-match-substring math-exp-str 0)))
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
738 (if (setq adfn (get calc-language 'math-lang-adjust-words))
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
739 (funcall adfn)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
740 ((or (and (>= ch ?0) (<= ch ?9))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
741 (and (eq ch '?\.)
74579
d5f79339859e (calc-eval-error): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 72037
diff changeset
742 (eq (string-match "\\.[0-9]" math-exp-str math-exp-pos)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
743 math-exp-pos))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
744 (and (eq ch '?_)
74579
d5f79339859e (calc-eval-error): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 72037
diff changeset
745 (eq (string-match "_\\.?[0-9]" math-exp-str math-exp-pos)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
746 math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
747 (or (eq math-exp-pos 0)
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
748 (and (not (memq calc-language
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
749 calc-lang-allow-underscores))
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
750 (eq (string-match "[^])}\"a-zA-Zα-ωΑ-Ω0-9'$]_"
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
751 math-exp-str (1- math-exp-pos))
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
752 (1- math-exp-pos))))))
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
753 (or (and (memq calc-language calc-lang-c-type-hex)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
754 (string-match "0[xX][0-9a-fA-F]+" math-exp-str math-exp-pos))
108590
c84578d13e42 calc-aent.el (math-read-token, math-find-user-tokens):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 106815
diff changeset
755 (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-zA-Zα-ωΑ-Ω:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?"
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
756 math-exp-str math-exp-pos))
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
757 (setq math-exp-token 'number
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
758 math-expr-data (math-match-substring math-exp-str 0)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
759 math-exp-pos (match-end 0)))
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
760 ((and (setq adfn
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
761 (assq ch (get calc-language 'math-lang-read-symbol)))
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
762 (eval (nth 1 adfn)))
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
763 (eval (nth 2 adfn)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
764 ((eq ch ?\$)
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
765 (if (eq (string-match "\\$\\([1-9][0-9]*\\)" math-exp-str math-exp-pos)
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
766 math-exp-pos)
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
767 (setq math-expr-data (- (string-to-number (math-match-substring
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
768 math-exp-str 1))))
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
769 (string-match "\\$+" math-exp-str math-exp-pos)
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
770 (setq math-expr-data (- (match-end 0) (match-beginning 0))))
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
771 (setq math-exp-token 'dollar
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
772 math-exp-pos (match-end 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
773 ((eq ch ?\#)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
774 (if (eq (string-match "#\\([1-9][0-9]*\\)" math-exp-str math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
775 math-exp-pos)
62032
e570688e1d80 (math-read-token): Replace string-to-int by string-to-number.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 61303
diff changeset
776 (setq math-expr-data (string-to-number
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
777 (math-match-substring math-exp-str 1))
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
778 math-exp-pos (match-end 0))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
779 (setq math-expr-data 1
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
780 math-exp-pos (1+ math-exp-pos)))
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
781 (setq math-exp-token 'hash))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
782 ((eq (string-match "~=\\|<=\\|>=\\|<>\\|/=\\|\\+/-\\|\\\\dots\\|\\\\ldots\\|\\*\\*\\|<<\\|>>\\|==\\|!=\\|&&&\\||||\\|!!!\\|&&\\|||\\|!!\\|:=\\|::\\|=>"
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
783 math-exp-str math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
784 math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
785 (setq math-exp-token 'punc
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
786 math-expr-data (math-match-substring math-exp-str 0)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
787 math-exp-pos (match-end 0)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
788 ((and (eq ch ?\")
74579
d5f79339859e (calc-eval-error): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 72037
diff changeset
789 (string-match "\\(\"\\([^\"\\]\\|\\\\.\\)*\\)\\(\"\\|\\'\\)"
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
790 math-exp-str math-exp-pos))
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
791 (setq math-exp-token 'string
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
792 math-expr-data (math-match-substring math-exp-str 1)
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
793 math-exp-pos (match-end 0)))
87458
bb9a0a3cc5f2 (math-read-token): Fix misplaced parentheses.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87438
diff changeset
794 ((and (setq adfn (get calc-language 'math-lang-read))
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
795 (eval (nth 0 adfn))
87458
bb9a0a3cc5f2 (math-read-token): Fix misplaced parentheses.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87438
diff changeset
796 (eval (nth 1 adfn))))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
797 ((eq (string-match "%%.*$" math-exp-str math-exp-pos) math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
798 (setq math-exp-pos (match-end 0))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
799 (math-read-token))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
800 (t
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
801 (if (setq adfn (assq ch (get calc-language 'math-punc-table)))
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
802 (setq ch (cdr adfn)))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
803 (setq math-exp-token 'punc
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
804 math-expr-data (char-to-string ch)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
805 math-exp-pos (1+ math-exp-pos)))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
806
58569
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
807 (defconst math-alg-inequalities
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
808 '(calcFunc-lt calcFunc-gt calcFunc-leq calcFunc-geq
cddffb5e15f3 (calc-eval-error): Declare and initialize the variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58455
diff changeset
809 calcFunc-eq calcFunc-neq))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
810
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
811 (defun math-read-expr-level (exp-prec &optional exp-term)
81467
a90e4a0758e3 (calc-do-calc-eval): Let math-expr-opers equal the function
Jay Belanger <jay.p.belanger@gmail.com>
parents: 77465
diff changeset
812 (let* ((math-expr-opers (math-expr-ops))
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
813 (x (math-read-factor))
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
814 (first t)
81467
a90e4a0758e3 (calc-do-calc-eval): Let math-expr-opers equal the function
Jay Belanger <jay.p.belanger@gmail.com>
parents: 77465
diff changeset
815 op op2)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
816 (while (and (or (and calc-user-parse-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
817 (setq op (calc-check-user-syntax x exp-prec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
818 (setq x op
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
819 op '("2x" ident 999999 -1)))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
820 (and (setq op (assoc math-expr-data math-expr-opers))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
821 (/= (nth 2 op) -1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
822 (or (and (setq op2 (assoc
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
823 math-expr-data
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
824 (cdr (memq op math-expr-opers))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
825 (eq (= (nth 3 op) -1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
826 (/= (nth 3 op2) -1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
827 (eq (= (nth 3 op2) -1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
828 (not (math-factor-after)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
829 (setq op op2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
830 t))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
831 (and (or (eq (nth 2 op) -1)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
832 (memq math-exp-token '(symbol number dollar hash))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
833 (equal math-expr-data "(")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
834 (and (equal math-expr-data "[")
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
835 (not (equal
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
836 (get calc-language
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
837 'math-function-open) "["))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
838 (not (and math-exp-keep-spaces
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
839 (eq (car-safe x) 'vec)))))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
840 (or (not (setq op (assoc math-expr-data math-expr-opers)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
841 (/= (nth 2 op) -1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
842 (or (not calc-user-parse-table)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
843 (not (eq math-exp-token 'symbol))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
844 (let ((p calc-user-parse-table))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
845 (while (and p
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
846 (or (not (integerp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
847 (car (car (car p)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
848 (not (equal
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
849 (nth 1 (car (car p)))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
850 math-expr-data))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
851 (setq p (cdr p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
852 (not p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
853 (setq op (assoc "2x" math-expr-opers))))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
854 (not (and exp-term (equal math-expr-data exp-term)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
855 (>= (nth 2 op) exp-prec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
856 (if (not (equal (car op) "2x"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
857 (math-read-token))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
858 (and (memq (nth 1 op) '(sdev mod))
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
859 (require 'calc-ext))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
860 (setq x (cond ((consp (nth 1 op))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
861 (funcall (car (nth 1 op)) x op))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
862 ((eq (nth 3 op) -1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
863 (if (eq (nth 1 op) 'ident)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
864 x
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
865 (if (eq (nth 1 op) 'closing)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
866 (if (eq (nth 2 op) exp-prec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
867 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
868 (setq exp-prec 1000)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
869 x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
870 (throw 'syntax "Mismatched delimiters"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
871 (list (nth 1 op) x))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
872 ((and (not first)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
873 (memq (nth 1 op) math-alg-inequalities)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
874 (memq (car-safe x) math-alg-inequalities))
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
875 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
876 (math-composite-inequalities x op))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
877 (t (list (nth 1 op)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
878 x
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
879 (math-read-expr-level (nth 3 op) exp-term))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
880 first nil))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
881 x))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
882
62835
6dcbf1f1fd92 (calc-arg-values): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 62032
diff changeset
883 ;; calc-arg-values is defined in calc-ext.el, but is used here.
6dcbf1f1fd92 (calc-arg-values): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 62032
diff changeset
884 (defvar calc-arg-values)
6dcbf1f1fd92 (calc-arg-values): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 62032
diff changeset
885
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
886 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
887 (defun calc-check-user-syntax (&optional x prec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
888 (let ((p calc-user-parse-table)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
889 (matches nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
890 match rule)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
891 (while (and p
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
892 (or (not (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
893 (setq rule (car (car p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
894 (if x
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
895 (and (integerp (car rule))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
896 (>= (car rule) prec)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
897 (equal math-expr-data
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
898 (car (setq rule (cdr rule)))))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
899 (equal math-expr-data (car rule)))))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
900 (let ((save-exp-pos math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
901 (save-exp-old-pos math-exp-old-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
902 (save-exp-token math-exp-token)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
903 (save-exp-data math-expr-data))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
904 (or (not (listp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
905 (setq matches (calc-match-user-syntax rule))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
906 (let ((args (progn
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
907 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
908 calc-arg-values))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
909 (conds nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
910 temp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
911 (if x
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
912 (setq matches (cons x matches)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
913 (setq match (cdr (car p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
914 (while (and (eq (car-safe match)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
915 'calcFunc-condition)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
916 (= (length match) 3))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
917 (setq conds (append (math-flatten-lands
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
918 (nth 2 match))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
919 conds)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
920 match (nth 1 match)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
921 (while (and conds match)
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
922 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
923 (cond ((eq (car-safe (car conds))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
924 'calcFunc-let)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
925 (setq temp (car conds))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
926 (or (= (length temp) 3)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
927 (and (= (length temp) 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
928 (eq (car-safe (nth 1 temp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
929 'calcFunc-assign)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
930 (= (length (nth 1 temp)) 3)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
931 (setq temp (nth 1 temp)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
932 (setq match nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
933 (setq matches (cons
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
934 (math-normalize
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
935 (math-multi-subst
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
936 (nth 2 temp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
937 args matches))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
938 matches)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
939 args (cons (nth 1 temp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
940 args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
941 ((and (eq (car-safe (car conds))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
942 'calcFunc-matches)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
943 (= (length (car conds)) 3))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
944 (setq temp (calcFunc-vmatches
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
945 (math-multi-subst
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
946 (nth 1 (car conds))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
947 args matches)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
948 (nth 2 (car conds))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
949 (if (eq temp 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
950 (setq match nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
951 (while (setq temp (cdr temp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
952 (setq matches (cons (nth 2 (car temp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
953 matches)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
954 args (cons (nth 1 (car temp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
955 args)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
956 (t
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
957 (or (math-is-true (math-simplify
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
958 (math-multi-subst
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
959 (car conds)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
960 args matches)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
961 (setq match nil))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
962 (setq conds (cdr conds)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
963 (if match
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
964 (not (setq match (math-multi-subst
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
965 match args matches)))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
966 (setq math-exp-old-pos save-exp-old-pos
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
967 math-exp-token save-exp-token
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
968 math-expr-data save-exp-data
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
969 math-exp-pos save-exp-pos)))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
970 (setq p (cdr p)))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
971 (and p match)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
972
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
973 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
974 (defun calc-match-user-syntax (p &optional term)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
975 (let ((matches nil)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
976 (save-exp-pos math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
977 (save-exp-old-pos math-exp-old-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
978 (save-exp-token math-exp-token)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
979 (save-exp-data math-expr-data)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
980 m)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
981 (while (and p
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
982 (cond ((stringp (car p))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
983 (and (equal math-expr-data (car p))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
984 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
985 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
986 t)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
987 ((integerp (car p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
988 (and (setq m (catch 'syntax
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
989 (math-read-expr-level
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
990 (car p)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
991 (if (cdr p)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
992 (if (consp (nth 1 p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
993 (car (nth 1 (nth 1 p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
994 (nth 1 p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
995 term))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
996 (not (stringp m))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
997 (setq matches (nconc matches (list m)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
998 ((eq (car (car p)) '\?)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
999 (setq m (calc-match-user-syntax (nth 1 (car p))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1000 (or (nth 2 (car p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1001 (setq matches
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1002 (nconc matches
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1003 (list
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1004 (cons 'vec (and (listp m) m))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1005 (or (listp m) (not (nth 2 (car p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1006 (not (eq (aref (car (nth 2 (car p))) 0) ?\$))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1007 (eq math-exp-token 'end)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1008 (t
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1009 (setq m (calc-match-user-syntax (nth 1 (car p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1010 (car (nth 2 (car p)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1011 (if (listp m)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1012 (let ((vec (cons 'vec m))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1013 opos mm)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1014 (while (and (listp
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1015 (setq opos math-exp-pos
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1016 mm (calc-match-user-syntax
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1017 (or (nth 2 (car p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1018 (nth 1 (car p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1019 (car (nth 2 (car p))))))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1020 (> math-exp-pos opos))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1021 (setq vec (nconc vec mm)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1022 (setq matches (nconc matches (list vec))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1023 (and (eq (car (car p)) '*)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1024 (setq matches (nconc matches (list '(vec)))))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1025 (setq p (cdr p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1026 (if p
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1027 (setq math-exp-pos save-exp-pos
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1028 math-exp-old-pos save-exp-old-pos
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1029 math-exp-token save-exp-token
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1030 math-expr-data save-exp-data
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1031 matches "Failed"))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
1032 matches))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1033
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
1034 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1035 (defun math-remove-dashes (x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1036 (if (string-match "\\`\\(.*\\)-\\(.*\\)\\'" x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1037 (math-remove-dashes
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1038 (concat (math-match-substring x 1) "#" (math-match-substring x 2)))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
1039 x))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1040
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1041 (defun math-remove-percentsigns (x)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1042 (if (string-match "\\`\\(.*\\)%\\(.*\\)\\'" x)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1043 (math-remove-percentsigns
87438
3c99a3e95b64 (math-remove-percentsigns): Change placeholder for percent signs.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87416
diff changeset
1044 (concat (math-match-substring x 1) "o'o" (math-match-substring x 2)))
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1045 x))
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1046
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1047 (defun math-restore-dashes (x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1048 (if (string-match "\\`\\(.*\\)[#_]\\(.*\\)\\'" x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1049 (math-restore-dashes
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1050 (concat (math-match-substring x 1) "-" (math-match-substring x 2)))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
1051 x))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1052
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1053 (defun math-restore-placeholders (x)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1054 "Replace placeholders by the proper characters in the symbol x.
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1055 This includes `#' for `_' and `'' for `%'.
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1056 If the current Calc language does not use placeholders, return nil."
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1057 (if (or (memq calc-language calc-lang-allow-underscores)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1058 (memq calc-language calc-lang-allow-percentsigns))
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1059 (let ((sx (symbol-name x)))
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1060 (when (memq calc-language calc-lang-allow-percentsigns)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1061 (require 'calccomp)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1062 (setq sx (math-to-percentsigns sx)))
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1063 (if (memq calc-language calc-lang-allow-underscores)
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1064 (setq sx (math-string-restore-underscores sx)))
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1065 (intern-soft sx))))
87269
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1066
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1067 (defun math-string-restore-underscores (x)
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1068 "Replace pound signs by underscores in the string x."
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1069 (if (string-match "\\`\\(.*\\)#\\(.*\\)\\'" x)
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1070 (math-string-restore-underscores
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1071 (concat (math-match-substring x 1) "_" (math-match-substring x 2)))
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1072 x))
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1073
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
1074 ;;;###autoload
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1075 (defun math-read-if (cond op)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1076 (let ((then (math-read-expr-level 0)))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1077 (or (equal math-expr-data ":")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1078 (throw 'syntax "Expected ':'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1079 (math-read-token)
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
1080 (list 'calcFunc-if cond then (math-read-expr-level (nth 3 op)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1081
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1082 (defun math-factor-after ()
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1083 (let ((math-exp-pos math-exp-pos)
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1084 math-exp-old-pos math-exp-token math-expr-data)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1085 (math-read-token)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1086 (or (memq math-exp-token '(number symbol dollar hash string))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1087 (and (assoc math-expr-data '(("-") ("+") ("!") ("|") ("/")))
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1088 (assoc (concat "u" math-expr-data) math-expr-opers))
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1089 (eq (nth 2 (assoc math-expr-data math-expr-opers)) -1)
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1090 (assoc math-expr-data '(("(") ("[") ("{"))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1091
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1092 (defun math-read-factor ()
81467
a90e4a0758e3 (calc-do-calc-eval): Let math-expr-opers equal the function
Jay Belanger <jay.p.belanger@gmail.com>
parents: 77465
diff changeset
1093 (let ((math-expr-opers (math-expr-ops))
a90e4a0758e3 (calc-do-calc-eval): Let math-expr-opers equal the function
Jay Belanger <jay.p.belanger@gmail.com>
parents: 77465
diff changeset
1094 op)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1095 (cond ((eq math-exp-token 'number)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1096 (let ((num (math-read-number math-expr-data)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1097 (if (not num)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1098 (progn
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1099 (setq math-exp-old-pos math-exp-pos)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1100 (throw 'syntax "Bad format")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1101 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1102 (if (and math-read-expr-quotes
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1103 (consp num))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1104 (list 'quote num)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1105 num)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1106 ((and calc-user-parse-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1107 (setq op (calc-check-user-syntax)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1108 op)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1109 ((or (equal math-expr-data "-")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1110 (equal math-expr-data "+")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1111 (equal math-expr-data "!")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1112 (equal math-expr-data "|")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1113 (equal math-expr-data "/"))
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1114 (setq math-expr-data (concat "u" math-expr-data))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1115 (math-read-factor))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1116 ((and (setq op (assoc math-expr-data math-expr-opers))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1117 (eq (nth 2 op) -1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1118 (if (consp (nth 1 op))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1119 (funcall (car (nth 1 op)) op)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1120 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1121 (let ((val (math-read-expr-level (nth 3 op))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1122 (cond ((eq (nth 1 op) 'ident)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1123 val)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1124 ((and (Math-numberp val)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1125 (equal (car op) "u-"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1126 (math-neg val))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1127 (t (list (nth 1 op) val))))))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1128 ((eq math-exp-token 'symbol)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1129 (let ((sym (intern math-expr-data)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1130 (math-read-token)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1131 (if (equal math-expr-data calc-function-open)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1132 (let ((f (assq sym math-expr-function-mapping)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1133 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1134 (if (consp (cdr f))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1135 (funcall (car (cdr f)) f sym)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1136 (let ((args (if (or (equal math-expr-data calc-function-close)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1137 (eq math-exp-token 'end))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1138 nil
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1139 (math-read-expr-list))))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1140 (if (not (or (equal math-expr-data calc-function-close)
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1141 (eq math-exp-token 'end)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1142 (throw 'syntax "Expected `)'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1143 (math-read-token)
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
1144 (if (and (memq calc-language
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
1145 calc-lang-parens-are-subscripts)
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
1146 args
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
1147 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1148 (let ((calc-matrix-mode 'scalar))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1149 (math-known-matrixp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1150 (list 'var sym
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1151 (intern
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1152 (concat "var-"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1153 (symbol-name sym)))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1154 (math-parse-fortran-subscr sym args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1155 (if f
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1156 (setq sym (cdr f))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1157 (and (= (aref (symbol-name sym) 0) ?\\)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1158 (< (prefix-numeric-value calc-language-option)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1159 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1160 (setq sym (intern (substring (symbol-name sym)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1161 1))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1162 (or (string-match "-" (symbol-name sym))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1163 (setq sym (intern
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1164 (concat "calcFunc-"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1165 (symbol-name sym))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1166 (cons sym args)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1167 (if math-read-expr-quotes
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1168 sym
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1169 (let ((val (list 'var
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1170 (intern (math-remove-dashes
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1171 (symbol-name sym)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1172 (if (string-match "-" (symbol-name sym))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1173 sym
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1174 (intern (concat "var-"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1175 (symbol-name sym)))))))
87269
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1176 (let ((v (or
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1177 (assq (nth 1 val) math-expr-variable-mapping)
87416
87a6da15351c (math-to-percentsigns): Declare as function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 87269
diff changeset
1178 (assq (math-restore-placeholders (nth 1 val))
87269
59fee65281f5 (math-restore-underscores, math-string-restore-underscores):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86929
diff changeset
1179 math-expr-variable-mapping))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1180 (and v (setq val (if (consp (cdr v))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1181 (funcall (car (cdr v)) v val)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1182 (list 'var
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1183 (intern
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1184 (substring (symbol-name (cdr v))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1185 4))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1186 (cdr v))))))
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
1187 (while (and (memq calc-language
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
1188 calc-lang-brackets-are-subscripts)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1189 (equal math-expr-data "["))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1190 (math-read-token)
86929
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
1191 (let ((el (math-read-expr-list)))
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
1192 (while el
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
1193 (setq val (append (list 'calcFunc-subscr val)
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
1194 (list (car el))))
edfd75871d15 (math-read-factor): Turn multiple subscripts into nested subscripts.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 86466
diff changeset
1195 (setq el (cdr el))))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1196 (if (equal math-expr-data "]")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1197 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1198 (throw 'syntax "Expected ']'")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1199 val)))))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1200 ((eq math-exp-token 'dollar)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1201 (let ((abs (if (> math-expr-data 0) math-expr-data (- math-expr-data))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1202 (if (>= (length calc-dollar-values) abs)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1203 (let ((num math-expr-data))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1204 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1205 (setq calc-dollar-used (max calc-dollar-used num))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1206 (math-check-complete (nth (1- abs) calc-dollar-values)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1207 (throw 'syntax (if calc-dollar-values
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1208 "Too many $'s"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1209 "$'s not allowed in this context")))))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1210 ((eq math-exp-token 'hash)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1211 (or calc-hashes-used
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1212 (throw 'syntax "#'s not allowed in this context"))
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
1213 (require 'calc-ext)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1214 (if (<= math-expr-data (length calc-arg-values))
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1215 (let ((num math-expr-data))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1216 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1217 (setq calc-hashes-used (max calc-hashes-used num))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1218 (nth (1- num) calc-arg-values))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1219 (throw 'syntax "Too many # arguments")))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1220 ((equal math-expr-data "(")
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1221 (let* ((exp (let ((math-exp-keep-spaces nil))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1222 (math-read-token)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1223 (if (or (equal math-expr-data "\\dots")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1224 (equal math-expr-data "\\ldots"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1225 '(neg (var inf var-inf))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1226 (math-read-expr-level 0)))))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1227 (let ((math-exp-keep-spaces nil))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1228 (cond
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1229 ((equal math-expr-data ",")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1230 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1231 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1232 (let ((exp2 (math-read-expr-level 0)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1233 (setq exp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1234 (if (and exp2 (Math-realp exp) (Math-realp exp2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1235 (math-normalize (list 'cplx exp exp2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1236 (list '+ exp (list '* exp2 '(var i var-i))))))))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1237 ((equal math-expr-data ";")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1238 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1239 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1240 (let ((exp2 (math-read-expr-level 0)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1241 (setq exp (if (and exp2 (Math-realp exp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1242 (Math-anglep exp2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1243 (math-normalize (list 'polar exp exp2))
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
1244 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1245 (list '* exp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1246 (list 'calcFunc-exp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1247 (list '*
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1248 (math-to-radians-2 exp2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1249 '(var i var-i)))))))))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1250 ((or (equal math-expr-data "\\dots")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1251 (equal math-expr-data "\\ldots"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1252 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1253 (math-read-token)
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1254 (let ((exp2 (if (or (equal math-expr-data ")")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1255 (equal math-expr-data "]")
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1256 (eq math-exp-token 'end))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1257 '(var inf var-inf)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1258 (math-read-expr-level 0))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1259 (setq exp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1260 (list 'intv
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1261 (if (equal math-expr-data ")") 0 1)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1262 exp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1263 exp2)))))))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1264 (if (not (or (equal math-expr-data ")")
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1265 (and (equal math-expr-data "]") (eq (car-safe exp) 'intv))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1266 (eq math-exp-token 'end)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1267 (throw 'syntax "Expected `)'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1268 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1269 exp))
58131
be4a8443df49 (calc-do-quick-calc): Use kill-new to append string to kill-ring.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58108
diff changeset
1270 ((eq math-exp-token 'string)
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
1271 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1272 (math-read-string))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1273 ((equal math-expr-data "[")
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
1274 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1275 (math-read-brackets t "]"))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1276 ((equal math-expr-data "{")
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
1277 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1278 (math-read-brackets nil "}"))
58108
46d104e25054 (math-read-exprs, math-read-expr-list, math-read-expr-level,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 57635
diff changeset
1279 ((equal math-expr-data "<")
58611
79b3fe261527 Remove unnecessary eval-when-compile.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58569
diff changeset
1280 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1281 (math-read-angle-brackets))
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
1282 (t (throw 'syntax "Expected a number")))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1283
58645
157fd661769f Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58611
diff changeset
1284 (provide 'calc-aent)
157fd661769f Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58611
diff changeset
1285
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
1286 ;; Local variables:
109033
d150a25a0eb9 Add some utf-8 coding cookies.
Glenn Morris <rgm@gnu.org>
parents: 108590
diff changeset
1287 ;; coding: utf-8
93880
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
1288 ;; generated-autoload-file: "calc-loaddefs.el"
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
1289 ;; End:
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
1290
c6152337e4ad * calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
1291 ;; arch-tag: 5599e45d-e51e-44bb-9a20-9f4ed8c96c32
41039
e65205f993f3 Style cleanup; don't put closing parens on their own line, add "foo.el
Colin Walters <walters@gnu.org>
parents: 40995
diff changeset
1292 ;;; calc-aent.el ends here