Mercurial > emacs
comparison lisp/calc/calc-aent.el @ 58611:79b3fe261527
Remove unnecessary eval-when-compile.
(calc-do-quick-calc, calc-do-calc-eval, calc-alg-entry)
(math-read-expr-level, calc-check-user-syntax, math-read-factor):
Replace calls to calc-extensions by appropriate require,
replace calc-extensions-loaded by appropriate featurep.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Mon, 29 Nov 2004 05:56:06 +0000 |
parents | cddffb5e15f3 |
children | 157fd661769f |
comparison
equal
deleted
inserted
replaced
58610:903d22ed0208 | 58611:79b3fe261527 |
---|---|
25 ;;; Commentary: | 25 ;;; Commentary: |
26 | 26 |
27 ;;; Code: | 27 ;;; Code: |
28 | 28 |
29 ;; This file is autoloaded from calc.el. | 29 ;; This file is autoloaded from calc.el. |
30 | |
30 (require 'calc) | 31 (require 'calc) |
31 | |
32 (require 'calc-macs) | 32 (require 'calc-macs) |
33 (eval-when-compile '(require calc-macs)) | |
34 | 33 |
35 (defun calc-Need-calc-aent () nil) | 34 (defun calc-Need-calc-aent () nil) |
36 | 35 |
37 | 36 |
38 (defun calc-do-quick-calc () | 37 (defun calc-do-quick-calc () |
49 (calc-language (if (memq calc-language '(nil big)) | 48 (calc-language (if (memq calc-language '(nil big)) |
50 'flat calc-language)) | 49 'flat calc-language)) |
51 (entry (calc-do-alg-entry "" "Quick calc: " t)) | 50 (entry (calc-do-alg-entry "" "Quick calc: " t)) |
52 (alg-exp (mapcar (function | 51 (alg-exp (mapcar (function |
53 (lambda (x) | 52 (lambda (x) |
54 (if (and (not calc-extensions-loaded) | 53 (if (and (not (featurep 'calc-ext)) |
55 calc-previous-alg-entry | 54 calc-previous-alg-entry |
56 (string-match | 55 (string-match |
57 "\\`[-0-9._+*/^() ]+\\'" | 56 "\\`[-0-9._+*/^() ]+\\'" |
58 calc-previous-alg-entry)) | 57 calc-previous-alg-entry)) |
59 (calc-normalize x) | 58 (calc-normalize x) |
60 (calc-extensions) | 59 (require 'calc-ext) |
61 (math-evaluate-expr x)))) | 60 (math-evaluate-expr x)))) |
62 entry))) | 61 entry))) |
63 (when (and (= (length alg-exp) 1) | 62 (when (and (= (length alg-exp) 1) |
64 (eq (car-safe (car alg-exp)) 'calcFunc-assign) | 63 (eq (car-safe (car alg-exp)) 'calcFunc-assign) |
65 (= (length (car alg-exp)) 3) | 64 (= (length (car alg-exp)) 3) |
66 (eq (car-safe (nth 1 (car alg-exp))) 'var)) | 65 (eq (car-safe (nth 1 (car alg-exp))) 'var)) |
67 (calc-extensions) | 66 (require 'calc-ext) |
68 (set (nth 2 (nth 1 (car alg-exp))) (nth 2 (car alg-exp))) | 67 (set (nth 2 (nth 1 (car alg-exp))) (nth 2 (car alg-exp))) |
69 (calc-refresh-evaltos (nth 2 (nth 1 (car alg-exp)))) | 68 (calc-refresh-evaltos (nth 2 (nth 1 (car alg-exp)))) |
70 (setq alg-exp (list (nth 2 (car alg-exp))))) | 69 (setq alg-exp (list (nth 2 (car alg-exp))))) |
71 (setq calc-quick-prev-results alg-exp | 70 (setq calc-quick-prev-results alg-exp |
72 buf (mapconcat (function (lambda (x) | 71 buf (mapconcat (function (lambda (x) |
89 (< (car alg-exp) 127)) | 88 (< (car alg-exp) 127)) |
90 (format ", \"%c\"" (car alg-exp)) | 89 (format ", \"%c\"" (car alg-exp)) |
91 "") | 90 "") |
92 ")"))) | 91 ")"))) |
93 (if (and (< (length buf) (frame-width)) (= (length entry) 1) | 92 (if (and (< (length buf) (frame-width)) (= (length entry) 1) |
94 calc-extensions-loaded) | 93 (featurep 'calc-ext)) |
95 (let ((long (concat (math-format-value (car entry) 1000) | 94 (let ((long (concat (math-format-value (car entry) 1000) |
96 " => " buf))) | 95 " => " buf))) |
97 (if (<= (length long) (- (frame-width) 8)) | 96 (if (<= (length long) (- (frame-width) 8)) |
98 (setq buf long)))) | 97 (setq buf long)))) |
99 (calc-handle-whys) | 98 (calc-handle-whys) |
145 (setq strp (cdr (cdr strp)))) | 144 (setq strp (cdr (cdr strp)))) |
146 (calc-do-calc-eval (car str) separator args))) | 145 (calc-do-calc-eval (car str) separator args))) |
147 ((eq separator 'eval) | 146 ((eq separator 'eval) |
148 (eval str)) | 147 (eval str)) |
149 ((eq separator 'macro) | 148 ((eq separator 'macro) |
150 (calc-extensions) | 149 (require 'calc-ext) |
151 (let* ((calc-buffer (current-buffer)) | 150 (let* ((calc-buffer (current-buffer)) |
152 (calc-window (get-buffer-window calc-buffer)) | 151 (calc-window (get-buffer-window calc-buffer)) |
153 (save-window (selected-window))) | 152 (save-window (selected-window))) |
154 (if calc-window | 153 (if calc-window |
155 (unwind-protect | 154 (unwind-protect |
206 (calc-eval-error (cdr res)) | 205 (calc-eval-error (cdr res)) |
207 (setq res (mapcar 'calc-normalize res)) | 206 (setq res (mapcar 'calc-normalize res)) |
208 (and (memq 'clear-message calc-command-flags) | 207 (and (memq 'clear-message calc-command-flags) |
209 (message "")) | 208 (message "")) |
210 (cond ((eq separator 'pred) | 209 (cond ((eq separator 'pred) |
211 (calc-extensions) | 210 (require 'calc-ext) |
212 (if (= (length res) 1) | 211 (if (= (length res) 1) |
213 (math-is-true (car res)) | 212 (math-is-true (car res)) |
214 (calc-eval-error '(0 "Single value expected")))) | 213 (calc-eval-error '(0 "Single value expected")))) |
215 ((eq separator 'raw) | 214 ((eq separator 'raw) |
216 (if (= (length res) 1) | 215 (if (= (length res) 1) |
274 (calc-dollar-used 0) | 273 (calc-dollar-used 0) |
275 (calc-plain-entry t) | 274 (calc-plain-entry t) |
276 (alg-exp (calc-do-alg-entry initial prompt t))) | 275 (alg-exp (calc-do-alg-entry initial prompt t))) |
277 (if (stringp alg-exp) | 276 (if (stringp alg-exp) |
278 (progn | 277 (progn |
279 (calc-extensions) | 278 (require 'calc-ext) |
280 (calc-alg-edit alg-exp)) | 279 (calc-alg-edit alg-exp)) |
281 (let* ((calc-simplify-mode (if (eq last-command-char ?\C-j) | 280 (let* ((calc-simplify-mode (if (eq last-command-char ?\C-j) |
282 'none | 281 'none |
283 calc-simplify-mode)) | 282 calc-simplify-mode)) |
284 (nvals (mapcar 'calc-normalize alg-exp))) | 283 (nvals (mapcar 'calc-normalize alg-exp))) |
285 (while alg-exp | 284 (while alg-exp |
286 (calc-record (if calc-extensions-loaded (car alg-exp) (car nvals)) | 285 (calc-record (if (featurep 'calc-ext) (car alg-exp) (car nvals)) |
287 "alg'") | 286 "alg'") |
288 (calc-pop-push-record-list calc-dollar-used | 287 (calc-pop-push-record-list calc-dollar-used |
289 (and (not (equal (car alg-exp) | 288 (and (not (equal (car alg-exp) |
290 (car nvals))) | 289 (car nvals))) |
291 calc-extensions-loaded | 290 (featurep 'calc-ext) |
292 "") | 291 "") |
293 (list (car nvals))) | 292 (list (car nvals))) |
294 (setq alg-exp (cdr alg-exp) | 293 (setq alg-exp (cdr alg-exp) |
295 nvals (cdr nvals) | 294 nvals (cdr nvals) |
296 calc-dollar-used 0))) | 295 calc-dollar-used 0))) |
784 (not (and exp-term (equal math-expr-data exp-term))) | 783 (not (and exp-term (equal math-expr-data exp-term))) |
785 (>= (nth 2 op) exp-prec)) | 784 (>= (nth 2 op) exp-prec)) |
786 (if (not (equal (car op) "2x")) | 785 (if (not (equal (car op) "2x")) |
787 (math-read-token)) | 786 (math-read-token)) |
788 (and (memq (nth 1 op) '(sdev mod)) | 787 (and (memq (nth 1 op) '(sdev mod)) |
789 (calc-extensions)) | 788 (require 'calc-ext)) |
790 (setq x (cond ((consp (nth 1 op)) | 789 (setq x (cond ((consp (nth 1 op)) |
791 (funcall (car (nth 1 op)) x op)) | 790 (funcall (car (nth 1 op)) x op)) |
792 ((eq (nth 3 op) -1) | 791 ((eq (nth 3 op) -1) |
793 (if (eq (nth 1 op) 'ident) | 792 (if (eq (nth 1 op) 'ident) |
794 x | 793 x |
800 (throw 'syntax "Mismatched delimiters")) | 799 (throw 'syntax "Mismatched delimiters")) |
801 (list (nth 1 op) x)))) | 800 (list (nth 1 op) x)))) |
802 ((and (not first) | 801 ((and (not first) |
803 (memq (nth 1 op) math-alg-inequalities) | 802 (memq (nth 1 op) math-alg-inequalities) |
804 (memq (car-safe x) math-alg-inequalities)) | 803 (memq (car-safe x) math-alg-inequalities)) |
805 (calc-extensions) | 804 (require 'calc-ext) |
806 (math-composite-inequalities x op)) | 805 (math-composite-inequalities x op)) |
807 (t (list (nth 1 op) | 806 (t (list (nth 1 op) |
808 x | 807 x |
809 (math-read-expr-level (nth 3 op) exp-term)))) | 808 (math-read-expr-level (nth 3 op) exp-term)))) |
810 first nil)) | 809 first nil)) |
828 (save-exp-token math-exp-token) | 827 (save-exp-token math-exp-token) |
829 (save-exp-data math-expr-data)) | 828 (save-exp-data math-expr-data)) |
830 (or (not (listp | 829 (or (not (listp |
831 (setq matches (calc-match-user-syntax rule)))) | 830 (setq matches (calc-match-user-syntax rule)))) |
832 (let ((args (progn | 831 (let ((args (progn |
833 (calc-extensions) | 832 (require 'calc-ext) |
834 calc-arg-values)) | 833 calc-arg-values)) |
835 (conds nil) | 834 (conds nil) |
836 temp) | 835 temp) |
837 (if x | 836 (if x |
838 (setq matches (cons x matches))) | 837 (setq matches (cons x matches))) |
843 (setq conds (append (math-flatten-lands | 842 (setq conds (append (math-flatten-lands |
844 (nth 2 match)) | 843 (nth 2 match)) |
845 conds) | 844 conds) |
846 match (nth 1 match))) | 845 match (nth 1 match))) |
847 (while (and conds match) | 846 (while (and conds match) |
848 (calc-extensions) | 847 (require 'calc-ext) |
849 (cond ((eq (car-safe (car conds)) | 848 (cond ((eq (car-safe (car conds)) |
850 'calcFunc-let) | 849 'calcFunc-let) |
851 (setq temp (car conds)) | 850 (setq temp (car conds)) |
852 (or (= (length temp) 3) | 851 (or (= (length temp) 3) |
853 (and (= (length temp) 2) | 852 (and (= (length temp) 2) |
1035 (if (not (or (equal math-expr-data calc-function-close) | 1034 (if (not (or (equal math-expr-data calc-function-close) |
1036 (eq math-exp-token 'end))) | 1035 (eq math-exp-token 'end))) |
1037 (throw 'syntax "Expected `)'")) | 1036 (throw 'syntax "Expected `)'")) |
1038 (math-read-token) | 1037 (math-read-token) |
1039 (if (and (eq calc-language 'fortran) args | 1038 (if (and (eq calc-language 'fortran) args |
1040 (calc-extensions) | 1039 (require 'calc-ext) |
1041 (let ((calc-matrix-mode 'scalar)) | 1040 (let ((calc-matrix-mode 'scalar)) |
1042 (math-known-matrixp | 1041 (math-known-matrixp |
1043 (list 'var sym | 1042 (list 'var sym |
1044 (intern | 1043 (intern |
1045 (concat "var-" | 1044 (concat "var-" |
1094 "Too many $'s" | 1093 "Too many $'s" |
1095 "$'s not allowed in this context"))))) | 1094 "$'s not allowed in this context"))))) |
1096 ((eq math-exp-token 'hash) | 1095 ((eq math-exp-token 'hash) |
1097 (or calc-hashes-used | 1096 (or calc-hashes-used |
1098 (throw 'syntax "#'s not allowed in this context")) | 1097 (throw 'syntax "#'s not allowed in this context")) |
1099 (calc-extensions) | 1098 (require 'calc-ext) |
1100 (if (<= math-expr-data (length calc-arg-values)) | 1099 (if (<= math-expr-data (length calc-arg-values)) |
1101 (let ((num math-expr-data)) | 1100 (let ((num math-expr-data)) |
1102 (math-read-token) | 1101 (math-read-token) |
1103 (setq calc-hashes-used (max calc-hashes-used num)) | 1102 (setq calc-hashes-used (max calc-hashes-used num)) |
1104 (nth (1- num) calc-arg-values)) | 1103 (nth (1- num) calc-arg-values)) |
1125 (math-read-token) | 1124 (math-read-token) |
1126 (let ((exp2 (math-read-expr-level 0))) | 1125 (let ((exp2 (math-read-expr-level 0))) |
1127 (setq exp (if (and exp2 (Math-realp exp) | 1126 (setq exp (if (and exp2 (Math-realp exp) |
1128 (Math-anglep exp2)) | 1127 (Math-anglep exp2)) |
1129 (math-normalize (list 'polar exp exp2)) | 1128 (math-normalize (list 'polar exp exp2)) |
1130 (calc-extensions) | 1129 (require 'calc-ext) |
1131 (list '* exp | 1130 (list '* exp |
1132 (list 'calcFunc-exp | 1131 (list 'calcFunc-exp |
1133 (list '* | 1132 (list '* |
1134 (math-to-radians-2 exp2) | 1133 (math-to-radians-2 exp2) |
1135 '(var i var-i))))))))) | 1134 '(var i var-i))))))))) |
1152 (eq math-exp-token 'end))) | 1151 (eq math-exp-token 'end))) |
1153 (throw 'syntax "Expected `)'")) | 1152 (throw 'syntax "Expected `)'")) |
1154 (math-read-token) | 1153 (math-read-token) |
1155 exp)) | 1154 exp)) |
1156 ((eq math-exp-token 'string) | 1155 ((eq math-exp-token 'string) |
1157 (calc-extensions) | 1156 (require 'calc-ext) |
1158 (math-read-string)) | 1157 (math-read-string)) |
1159 ((equal math-expr-data "[") | 1158 ((equal math-expr-data "[") |
1160 (calc-extensions) | 1159 (require 'calc-ext) |
1161 (math-read-brackets t "]")) | 1160 (math-read-brackets t "]")) |
1162 ((equal math-expr-data "{") | 1161 ((equal math-expr-data "{") |
1163 (calc-extensions) | 1162 (require 'calc-ext) |
1164 (math-read-brackets nil "}")) | 1163 (math-read-brackets nil "}")) |
1165 ((equal math-expr-data "<") | 1164 ((equal math-expr-data "<") |
1166 (calc-extensions) | 1165 (require 'calc-ext) |
1167 (math-read-angle-brackets)) | 1166 (math-read-angle-brackets)) |
1168 (t (throw 'syntax "Expected a number"))))) | 1167 (t (throw 'syntax "Expected a number"))))) |
1169 | 1168 |
1170 ;;; arch-tag: 5599e45d-e51e-44bb-9a20-9f4ed8c96c32 | 1169 ;;; arch-tag: 5599e45d-e51e-44bb-9a20-9f4ed8c96c32 |
1171 ;;; calc-aent.el ends here | 1170 ;;; calc-aent.el ends here |