Function: ses-set-cell

ses-set-cell is a macro defined in ses.el.gz.

Signature

(ses-set-cell ROW COL FIELD VAL)

Documentation

Install VAL as the contents for field FIELD (named by a quoted symbol) of cell (ROW,COL). This is undoable. The cell's data will be updated through post-command-hook.

Source Code

;; Defined in /usr/src/emacs/lisp/ses.el.gz
;;----------------------------------------------------------------------------
;; The cells
;;----------------------------------------------------------------------------

(defmacro ses-set-cell (row col field val)
  "Install VAL as the contents for field FIELD (named by a quoted symbol) of
cell (ROW,COL).  This is undoable.  The cell's data will be updated through
`post-command-hook'."
  (macroexp-let2 nil row row
  (macroexp-let2 nil col col
  (macroexp-let2 nil val val
    `(let* ((cell (ses-get-cell ,row ,col))
            (change
             ,(let ((field (progn (cl-assert (eq (car field) 'quote))
                                  (cadr field))))
                (if (eq field 'value)
                    `(ses-set-with-undo (ses-cell-symbol cell) ,val)
                  ;; (let* ((slots (get 'ses-cell 'cl-struct-slots))
                  ;;        (slot (or (assq field slots)
                  ;;                  (error "Unknown field %S" field)))
                  ;;        (idx (- (length slots)
                  ;;                (length (memq slot slots)))))
                  ;;   `(ses-aset-with-undo cell ,idx ,val))
                  (let ((getter (intern-soft (format "ses-cell--%s" field))))
                    `(ses-setter-with-undo
                      (eval-when-compile
                        (cons #',getter
                              (lambda (newval cell)
                                (setf (,getter cell) newval))))
                      ,val cell))))))
       (if change
           (add-to-list 'ses--deferred-write (cons ,row ,col)))
       nil))))) ; Make coverage-tester happy.