Function: ses-recalculate-cell
ses-recalculate-cell is an interactive and byte-compiled function
defined in ses.el.gz.
Signature
(ses-recalculate-cell &optional CURCELL)
Documentation
Recalculate and reprint the current cell or range.
If CURCELL is non nil use it as current cell or range without any check, otherwise function (ses-check-curcell 'range) is called.
For an individual cell, shows the error if the formula or printer signals one, or otherwise shows the cell's complete value. For a range, the cells are recalculated in "natural" order, so cells that other cells refer to are recalculated first.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/ses.el.gz
;; 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 (&optional curcell)
"Recalculate and reprint the current cell or range.
If CURCELL is non nil use it as current cell or range
without any check, otherwise function (ses-check-curcell \\='range)
is called.
For an individual cell, shows the error if the formula or printer
signals one, or otherwise shows the cell's complete value. For a range, the
cells are recalculated in \"natural\" order, so cells that other cells refer
to are recalculated first."
(interactive "*")
(if curcell (setq ses--curcell curcell)
(ses-check-curcell 'range))
(ses-begin-change)
(ses-initialize-Dijkstra-attempt)
(let (sig cur-rowcol)
(setq ses-start-time (float-time))
(if (atom ses--curcell)
(when
(setq cur-rowcol (ses-sym-rowcol ses--curcell)
sig (progn
(setf (ses-cell-property :ses-Dijkstra-attempt
(car cur-rowcol)
(cdr cur-rowcol))
(cons ses--Dijkstra-attempt-nb 0))
(ses-calculate-cell (car cur-rowcol) (cdr cur-rowcol) t)))
(nconc sig (list (ses-cell-symbol (car cur-rowcol)
(cdr cur-rowcol)))))
;; First, recalculate all cells that don't refer to other cells and
;; produce a list of cells with references.
(ses-dorange ses--curcell
(ses--time-check "Recalculating... %s" (ses-cell-symbol row col))
(condition-case nil
(progn
;; The t causes an error if the cell has references. If no
;; references, the t will be the result value.
(1value (ses-formula-references (ses-cell-formula row col) t))
(setf (ses-cell-property :ses-Dijkstra-attempt row col)
(cons ses--Dijkstra-attempt-nb 0))
(when (setq sig (ses-calculate-cell row col t))
(nconc sig (list (ses-cell-symbol row col)))))
(wrong-type-argument
;; The formula contains a reference.
(cl-pushnew (ses-cell-symbol row col) ses--deferred-recalc
:test #'equal)))))
;; Do the update now, so we can force recalculation.
(let ((x ses--deferred-recalc))
(setq ses--deferred-recalc nil)
(condition-case hold
(ses-update-cells x t)
(error (setq sig hold))))
(cond
(sig
(message "%s" (error-message-string sig)))
((consp ses--curcell)
(message " "))
(t
(princ (symbol-value ses--curcell))))))