Function: ses-formula-references

ses-formula-references is a byte-compiled function defined in ses.el.gz.

Signature

(ses-formula-references FORMULA &optional RESULT-SO-FAR)

Documentation

Produce a list of symbols for cells that this FORMULA's value refers to. For recursive calls, RESULT-SO-FAR is the list being constructed, or t to get a wrong-type-argument error when the first reference is found.

Source Code

;; Defined in /usr/src/emacs/lisp/ses.el.gz
;;----------------------------------------------------------------------------
;; Formula relocation
;;----------------------------------------------------------------------------

(defun ses-formula-references (formula &optional result-so-far)
  "Produce a list of symbols for cells that this FORMULA's value
refers to.  For recursive calls, RESULT-SO-FAR is the list being
constructed, or t to get a wrong-type-argument error when the
first reference is found."
  (if (ses-sym-rowcol formula)
      ;; Entire formula is one symbol.
      (cl-pushnew formula result-so-far :test #'equal)
    (if (consp formula)
	(cond
	 ((eq (car formula) 'ses-range)
	  (dolist (cur
		   (cdr (funcall 'macroexpand
				 (list 'ses-range (nth 1 formula)
				       (nth 2 formula)))))
	    (cl-pushnew cur result-so-far :test #'equal)))
	 ((null (eq (car formula) 'quote))
	  ;;Recursive call for subformulas
	  (dolist (cur formula)
	    (setq result-so-far (ses-formula-references cur result-so-far))))
	 (t
	  ;;Ignore other stuff
	  ))
      ;; other type of atom are ignored
      ))
    result-so-far)