Function: ses-delete-row

ses-delete-row is an interactive and byte-compiled function defined in ses.el.gz.

Signature

(ses-delete-row COUNT)

Documentation

Delete the current row.

With prefix, deletes COUNT rows starting from the current one.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/ses.el.gz
(defun ses-delete-row (count)
  "Delete the current row.
With prefix, deletes COUNT rows starting from the current one."
  (interactive "*p")
  (ses-check-curcell)
  (or (> count 0) (signal 'args-out-of-range nil))
  (let ((inhibit-quit t)
	(inhibit-read-only t)
	(row (car (ses-sym-rowcol ses--curcell))))
    (setq count (min count (- ses--numrows row)))
    (ses-begin-change)
    (ses-set-parameter 'ses--numrows (- ses--numrows count))
    ;;Delete lines from print area
    (ses-goto-print row 0)
    (ses-delete-line count)
    ;;Delete lines from cell data area
    (ses-goto-data row 0)
    (ses-delete-line (* count (1+ ses--numcols)))
    ;; Collect named cells in the deleted rows, in order to clean the
    ;; symbols out of the named cell hash map, once the deletion is
    ;; complete
    (unless (null ses--in-killing-named-cell-list)
      (warn "Internal error, `ses--in-killing-named-cell-list' should be nil, but is equal to %S"
      ses--in-killing-named-cell-list)
      (setq ses--in-killing-named-cell-list nil))
    (dotimes-with-progress-reporter (nrow count)
	"Collecting named cell in deleted rows..."
      (dotimes (col ses--numcols)
	(let* ((row (+ row nrow))
	       (sym (ses-cell-symbol row col)))
	  (and (eq (get sym 'ses-cell) :ses-named)
	       (push sym ses--in-killing-named-cell-list)))))
    ;;Relocate variables and formulas
    (ses-set-with-undo 'ses--cells (ses-vector-delete ses--cells row count))
    (ses-relocate-all row 0 (- count) 0)
    (ses-destroy-cell-variable-range ses--numrows (+ ses--numrows count -1)
				     0            (1- ses--numcols))
    (when (> ses--header-row row)
      (if (<= ses--header-row (+ row count))
	  ;;Deleting the header row
	  (ses-set-parameter 'ses--header-row 0)
	(ses-set-parameter 'ses--header-row (- ses--header-row count)))
      (ses-reset-header-string)))
  ;;Reconstruct attributes
  (ses-setup)
  ;;Prepare for undo
  (push '(apply ses-widen) buffer-undo-list)
  (ses-jump-safe ses--curcell))