diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2020-10-14 18:03:52 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2020-10-14 18:03:52 -0400 |
commit | 0fac3f55325cf33e797b33be9935bf39f344c7c9 (patch) | |
tree | 4fd9dc7fdace60642f3f179d75f54ba15489d6a9 /lisp/calc/calc-ext.el | |
parent | 423439b38067c4a428310edab24fba7da082027c (diff) | |
download | emacs-0fac3f55325cf33e797b33be9935bf39f344c7c9.tar.gz emacs-0fac3f55325cf33e797b33be9935bf39f344c7c9.tar.bz2 emacs-0fac3f55325cf33e797b33be9935bf39f344c7c9.zip |
* lisp/calc: Fix a few issues introduced by lexical scoping
Fix a few places I missed, where we incorrectly used lexical scoping on a var
that needed dynamic scoping.
These were detected thanks to a bit of footwork by Mattias EngdegÄrd!
* lisp/calc/calc-ext.el (math-read-big-lines): Declare as dynbound.
(math-read-big-bigp): Bind it inside a `let`.
* lisp/calc/calc-graph.el (math-arglist): Declare as dynbound.
* lisp/calc/calc-map.el (math-arglist): Declare as dynbound.
* lisp/calc/calc-misc.el (math-trunc-prec): Declare as dynbound.
(math-trunc): Bind it inside a `let`.
(math-floor-prec): Declare as dynbound.
(math-floor): Bind it inside a `let`.
* lisp/calc/calc-nlfit.el (calc-curve-varnames, calc-curve-coefnames):
Declare as dynbound.
* lisp/calc/calc-sel.el (math-comp-sel-tag): Declare as dynbound.
* lisp/calc/calcsel2.el (calc-sel-reselect): Declare as dynbound.
Diffstat (limited to 'lisp/calc/calc-ext.el')
-rw-r--r-- | lisp/calc/calc-ext.el | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el index fc0a2c88fea..c48d1595822 100644 --- a/lisp/calc/calc-ext.el +++ b/lisp/calc/calc-ext.el @@ -3094,6 +3094,7 @@ If X is not an error form, return 1." (defvar math-read-big-baseline) (defvar math-read-big-h2) (defvar math-read-big-err-msg) +(defvar math-read-big-lines) (defun math-read-big-expr (str) (and (> (length calc-left-label) 0) @@ -3138,41 +3139,42 @@ If X is not an error form, return 1." (defvar math-rb-h2) -(defun math-read-big-bigp (math-read-big-lines) - (and (cdr math-read-big-lines) - (let ((matrix nil) - (v 0) - (height (if (> (length (car math-read-big-lines)) 0) 1 0))) - (while (and (cdr math-read-big-lines) - (let* ((i 0) - j - (l1 (car math-read-big-lines)) - (l2 (nth 1 math-read-big-lines)) - (len (min (length l1) (length l2)))) - (if (> (length l2) 0) - (setq height (1+ height))) - (while (and (< i len) - (or (memq (aref l1 i) '(?\ ?\- ?\_)) - (memq (aref l2 i) '(?\ ?\-)) - (and (memq (aref l1 i) '(?\| ?\,)) - (= (aref l2 i) (aref l1 i))) - (and (eq (aref l1 i) ?\[) - (eq (aref l2 i) ?\[) - (let ((math-rb-h2 (length l1))) - (setq j (math-read-big-balance - (1+ i) v "["))) - (setq i (1- j))))) - (setq i (1+ i))) - (or (= i len) - (and (eq (aref l1 i) ?\[) - (eq (aref l2 i) ?\[) - (setq matrix t) - nil)))) - (setq math-read-big-lines (cdr math-read-big-lines) - v (1+ v))) - (or (and (> height 1) - (not (cdr math-read-big-lines))) - matrix)))) +(defun math-read-big-bigp (read-big-lines) + (when (cdr read-big-lines) + (let ((math-read-big-lines read-big-lines) + (matrix nil) + (v 0) + (height (if (> (length (car read-big-lines)) 0) 1 0))) + (while (and (cdr math-read-big-lines) + (let* ((i 0) + j + (l1 (car math-read-big-lines)) + (l2 (nth 1 math-read-big-lines)) + (len (min (length l1) (length l2)))) + (if (> (length l2) 0) + (setq height (1+ height))) + (while (and (< i len) + (or (memq (aref l1 i) '(?\ ?\- ?\_)) + (memq (aref l2 i) '(?\ ?\-)) + (and (memq (aref l1 i) '(?\| ?\,)) + (= (aref l2 i) (aref l1 i))) + (and (eq (aref l1 i) ?\[) + (eq (aref l2 i) ?\[) + (let ((math-rb-h2 (length l1))) + (setq j (math-read-big-balance + (1+ i) v "["))) + (setq i (1- j))))) + (setq i (1+ i))) + (or (= i len) + (and (eq (aref l1 i) ?\[) + (eq (aref l2 i) ?\[) + (setq matrix t) + nil)))) + (setq math-read-big-lines (cdr math-read-big-lines) + v (1+ v))) + (or (and (> height 1) + (not (cdr math-read-big-lines))) + matrix)))) ;;; Nontrivial "flat" formatting. |