aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Belaïche2014-09-30 10:06:28 +0200
committerVincent Belaïche2014-09-30 10:06:28 +0200
commiteeb46c746af9739921c5836d51fdd680bb54a9b4 (patch)
treec08d8c6c15973b6db483e2ed90860d70798f05cf
parent2b2e7e6607f41cf7ad07d9e00d4e9ee833560958 (diff)
downloademacs-eeb46c746af9739921c5836d51fdd680bb54a9b4.tar.gz
emacs-eeb46c746af9739921c5836d51fdd680bb54a9b4.zip
* ses.el (ses-calculate-cell): bind row and col dynamically to
their values with 'cl-progv'. (ses-dorange): bind row, col, maxrow and maxcol dynamically to their values with 'cl-progv', also use non-interned symbols for row, minrow, maxrow, mincol and maxcol. (maxrow maxcol): New defvar, to make the compiler happy.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/ses.el55
2 files changed, 42 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 31e4e9d10f8..42c5df288a0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12014-09-30 Vincent Belaïche <vincentb1@users.sourceforge.net>
2
3 * ses.el (ses-calculate-cell): bind row and col dynamically to
4 their values with 'cl-progv'.
5 (ses-dorange): bind row, col, maxrow and maxcol dynamically to
6 their values with 'cl-progv', also use non-interned symbols for
7 row, minrow, maxrow, mincol and maxcol.
8 (maxrow maxcol): New defvar, to make the compiler happy.
9
12014-09-30 Stefan Monnier <monnier@iro.umontreal.ca> 102014-09-30 Stefan Monnier <monnier@iro.umontreal.ca>
2 11
3 * minibuffer.el (completion-at-point): Emit warning for ill-behaved 12 * minibuffer.el (completion-at-point): Emit warning for ill-behaved
diff --git a/lisp/ses.el b/lisp/ses.el
index 0e1aa5b472d..11250ec4097 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -592,30 +592,37 @@ for safety. This is a macro to prevent propagate-on-load viruses."
592 t) 592 t)
593 593
594(defmacro ses-dorange (curcell &rest body) 594(defmacro ses-dorange (curcell &rest body)
595 "Execute BODY repeatedly, with the variables `row' and `col' set to each 595 "Execute BODY repeatedly, with the variables `row', `col',
596cell in the range specified by CURCELL. The range is available in the 596`maxrow' and `maxcol' dynamically scoped to each cell in the
597variables `minrow', `maxrow', `mincol', and `maxcol'." 597range specified by CURCELL."
598 (declare (indent defun) (debug (form body))) 598 (declare (indent defun) (debug (form body)))
599 (let ((cur (make-symbol "cur")) 599 (let ((cur (make-symbol "cur"))
600 (min (make-symbol "min")) 600 (min (make-symbol "min"))
601 (max (make-symbol "max")) 601 (max (make-symbol "max"))
602 (r (make-symbol "r")) 602 (r (make-symbol "r"))
603 (c (make-symbol "c"))) 603 (c (make-symbol "c"))
604 (row (make-symbol "row"))
605 ;; The range is available in the variables `minrow', `maxrow',
606 ;; `mincol', and `maxcol'.
607 (minrow (make-symbol "minrow"))
608 (mincol (make-symbol "mincol"))
609 (maxrow (make-symbol "maxrow"))
610 (maxcol (make-symbol "maxcol")) )
604 `(let* ((,cur ,curcell) 611 `(let* ((,cur ,curcell)
605 (,min (ses-sym-rowcol (if (consp ,cur) (car ,cur) ,cur))) 612 (,min (ses-sym-rowcol (if (consp ,cur) (car ,cur) ,cur)))
606 (,max (ses-sym-rowcol (if (consp ,cur) (cdr ,cur) ,cur)))) 613 (,max (ses-sym-rowcol (if (consp ,cur) (cdr ,cur) ,cur))))
607 (let ((minrow (car ,min)) 614 (let ((,minrow (car ,min))
608 (maxrow (car ,max)) 615 (,maxrow (car ,max))
609 (mincol (cdr ,min)) 616 (,mincol (cdr ,min))
610 (maxcol (cdr ,max)) 617 (,maxcol (cdr ,max))
611 row col) 618 ,row)
612 (if (or (> minrow maxrow) (> mincol maxcol)) 619 (if (or (> ,minrow ,maxrow) (> ,mincol ,maxcol))
613 (error "Empty range")) 620 (error "Empty range"))
614 (dotimes (,r (- maxrow minrow -1)) 621 (dotimes (,r (- ,maxrow ,minrow -1))
615 (setq row (+ ,r minrow)) 622 (setq ,row (+ ,r ,minrow))
616 (dotimes (,c (- maxcol mincol -1)) 623 (dotimes (,c (- ,maxcol ,mincol -1))
617 (setq col (+ ,c mincol)) 624 (cl-progv '(row col maxrow maxcol) (list ,row (+ ,c ,mincol) ,maxrow ,maxcol)
618 ,@body)))))) 625 ,@body)))))))
619 626
620;;Support for coverage testing. 627;;Support for coverage testing.
621(defmacro 1value (form) 628(defmacro 1value (form)
@@ -939,7 +946,9 @@ the old and FORCE is nil."
939 (setq formula (ses-safe-formula (cadr formula))) 946 (setq formula (ses-safe-formula (cadr formula)))
940 (ses-set-cell row col 'formula formula)) 947 (ses-set-cell row col 'formula formula))
941 (condition-case sig 948 (condition-case sig
942 (setq newval (eval formula)) 949 (setq newval (cl-progv '(row col)
950 (list row col)
951 (eval formula)))
943 (error 952 (error
944 ;; Variable `sig' can't be nil. 953 ;; Variable `sig' can't be nil.
945 (nconc sig (list (ses-cell-symbol cell))) 954 (nconc sig (list (ses-cell-symbol cell)))
@@ -2177,6 +2186,14 @@ print area if NONARROW is nil."
2177 (setq ses--Dijkstra-attempt-nb (1+ ses--Dijkstra-attempt-nb) 2186 (setq ses--Dijkstra-attempt-nb (1+ ses--Dijkstra-attempt-nb)
2178 ses--Dijkstra-weight-bound (* ses--numrows ses--numcols))) 2187 ses--Dijkstra-weight-bound (* ses--numrows ses--numcols)))
2179 2188
2189;; These functions use the variables 'row' and 'col' that are dynamically bound
2190;; by ses-print-cell. We define these variables at compile-time to make the
2191;; compiler happy.
2192(defvar row)
2193(defvar col)
2194(defvar maxrow)
2195(defvar maxcol)
2196
2180(defun ses-recalculate-cell () 2197(defun ses-recalculate-cell ()
2181 "Recalculate and reprint the current cell or range. 2198 "Recalculate and reprint the current cell or range.
2182 2199
@@ -3676,12 +3693,6 @@ either (ses-range BEG END) or (list ...). The TEST is evaluated."
3676;; Standard print functions 3693;; Standard print functions
3677;;---------------------------------------------------------------------------- 3694;;----------------------------------------------------------------------------
3678 3695
3679;; These functions use the variables 'row' and 'col' that are dynamically bound
3680;; by ses-print-cell. We define these variables at compile-time to make the
3681;; compiler happy.
3682(defvar row)
3683(defvar col)
3684
3685(defun ses-center (value &optional span fill) 3696(defun ses-center (value &optional span fill)
3686 "Print VALUE, centered within column. 3697 "Print VALUE, centered within column.
3687FILL is the fill character for centering (default = space). 3698FILL is the fill character for centering (default = space).