Commit eeb46c74 authored by Vincent Belaïche's avatar Vincent Belaïche
Browse files

* 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.
parent 2b2e7e66
2014-09-30 Vincent Belaïche <vincentb1@users.sourceforge.net>
* 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.
2014-09-30 Stefan Monnier <monnier@iro.umontreal.ca>
 
* minibuffer.el (completion-at-point): Emit warning for ill-behaved
......
......@@ -592,30 +592,37 @@ for safety. This is a macro to prevent propagate-on-load viruses."
t)
(defmacro ses-dorange (curcell &rest body)
"Execute BODY repeatedly, with the variables `row' and `col' set to each
cell in the range specified by CURCELL. The range is available in the
variables `minrow', `maxrow', `mincol', and `maxcol'."
"Execute BODY repeatedly, with the variables `row', `col',
`maxrow' and `maxcol' dynamically scoped to each cell in the
range specified by CURCELL."
(declare (indent defun) (debug (form body)))
(let ((cur (make-symbol "cur"))
(min (make-symbol "min"))
(max (make-symbol "max"))
(r (make-symbol "r"))
(c (make-symbol "c")))
(c (make-symbol "c"))
(row (make-symbol "row"))
;; The range is available in the variables `minrow', `maxrow',
;; `mincol', and `maxcol'.
(minrow (make-symbol "minrow"))
(mincol (make-symbol "mincol"))
(maxrow (make-symbol "maxrow"))
(maxcol (make-symbol "maxcol")) )
`(let* ((,cur ,curcell)
(,min (ses-sym-rowcol (if (consp ,cur) (car ,cur) ,cur)))
(,max (ses-sym-rowcol (if (consp ,cur) (cdr ,cur) ,cur))))
(let ((minrow (car ,min))
(maxrow (car ,max))
(mincol (cdr ,min))
(maxcol (cdr ,max))
row col)
(if (or (> minrow maxrow) (> mincol maxcol))
(let ((,minrow (car ,min))
(,maxrow (car ,max))
(,mincol (cdr ,min))
(,maxcol (cdr ,max))
,row)
(if (or (> ,minrow ,maxrow) (> ,mincol ,maxcol))
(error "Empty range"))
(dotimes (,r (- maxrow minrow -1))
(setq row (+ ,r minrow))
(dotimes (,c (- maxcol mincol -1))
(setq col (+ ,c mincol))
,@body))))))
(dotimes (,r (- ,maxrow ,minrow -1))
(setq ,row (+ ,r ,minrow))
(dotimes (,c (- ,maxcol ,mincol -1))
(cl-progv '(row col maxrow maxcol) (list ,row (+ ,c ,mincol) ,maxrow ,maxcol)
,@body)))))))
;;Support for coverage testing.
(defmacro 1value (form)
......@@ -939,7 +946,9 @@ the old and FORCE is nil."
(setq formula (ses-safe-formula (cadr formula)))
(ses-set-cell row col 'formula formula))
(condition-case sig
(setq newval (eval formula))
(setq newval (cl-progv '(row col)
(list row col)
(eval formula)))
(error
;; Variable `sig' can't be nil.
(nconc sig (list (ses-cell-symbol cell)))
......@@ -2177,6 +2186,14 @@ print area if NONARROW is nil."
(setq ses--Dijkstra-attempt-nb (1+ ses--Dijkstra-attempt-nb)
ses--Dijkstra-weight-bound (* ses--numrows ses--numcols)))
;; These functions use the variables 'row' and 'col' that are dynamically bound
;; by ses-print-cell. We define these variables at compile-time to make the
;; compiler happy.
(defvar row)
(defvar col)
(defvar maxrow)
(defvar maxcol)
(defun ses-recalculate-cell ()
"Recalculate and reprint the current cell or range.
......@@ -3676,12 +3693,6 @@ either (ses-range BEG END) or (list ...). The TEST is evaluated."
;; Standard print functions
;;----------------------------------------------------------------------------
;; These functions use the variables 'row' and 'col' that are dynamically bound
;; by ses-print-cell. We define these variables at compile-time to make the
;; compiler happy.
(defvar row)
(defvar col)
(defun ses-center (value &optional span fill)
"Print VALUE, centered within column.
FILL is the fill character for centering (default = space).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment