Function: ses-dorange

ses-dorange is a macro defined in ses.el.gz.

Signature

(ses-dorange CURCELL &rest BODY)

Documentation

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.

Source Code

;; Defined in /usr/src/emacs/lisp/ses.el.gz
(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'."
  (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")))
    `(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)))
	 (if (or (> minrow maxrow) (> mincol maxcol))
	     (error "Empty range"))
	 (dotimes (,r (- maxrow minrow -1))
	   (let ((row (+ ,r minrow)))
             (dotimes (,c (- maxcol mincol -1))
               (let ((col (+ ,c mincol)))
                 ,@body))))))))