Function: ses-insert-row
ses-insert-row is an interactive and byte-compiled function defined in
ses.el.gz.
Signature
(ses-insert-row COUNT)
Documentation
Insert a new row before the current one.
With prefix, insert COUNT rows before current one.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/ses.el.gz
;;----------------------------------------------------------------------------
;; Spreadsheet size adjustments
;;----------------------------------------------------------------------------
(defun ses-insert-row (count)
"Insert a new row before the current one.
With prefix, insert COUNT rows before current one."
(interactive "*p")
(ses-check-curcell 'end)
(or (> count 0) (signal 'args-out-of-range nil))
(ses-begin-change)
(let ((inhibit-quit t)
(inhibit-read-only t)
(row (or (car (ses-sym-rowcol ses--curcell)) ses--numrows))
newrow)
;;Create a new set of cell-variables
(ses-create-cell-variable-range ses--numrows (+ ses--numrows count -1)
0 (1- ses--numcols))
(ses-set-parameter 'ses--numrows (+ ses--numrows count))
;;Insert each row
(ses-goto-print row 0)
(dotimes-with-progress-reporter (x count) "Inserting row..."
;;Create a row of empty cells. The `symbol' fields will be set by
;;the call to ses-relocate-all.
(setq newrow (make-vector ses--numcols nil))
(dotimes (col ses--numcols)
(aset newrow col (ses-make-cell)))
(setq ses--cells (ses-vector-insert ses--cells row newrow))
(push `(apply ses-vector-delete ses--cells ,row 1) buffer-undo-list)
(insert ses--blank-line))
;;Insert empty lines in cell data area (will be replaced by
;;ses-relocate-all)
(ses-goto-data row 0)
(insert (make-string (* (1+ ses--numcols) count) ?\n))
(ses-relocate-all row 0 count 0)
;;If any cell printers insert constant text, insert that text
;;into the line.
(let ((cols (mapconcat #'ses-call-printer ses--col-printers nil))
(global (ses-call-printer ses--default-printer)))
(if (or (> (length cols) 0) (> (length global) 0))
(dotimes (x count)
(dotimes (col ses--numcols)
;;These cells are always nil, only constant formatting printed
(1value (ses-print-cell (+ x row) col))))))
(when (> ses--header-row row)
;;Inserting before header
(ses-set-parameter 'ses--header-row (+ ses--header-row count))
(ses-reset-header-string)))
;;Reconstruct text attributes
(ses-setup)
;;Prepare for undo
(push '(apply ses-widen) buffer-undo-list)
;;Return to current cell
(if ses--curcell
(ses-jump-safe ses--curcell)
(ses-goto-print (1- ses--numrows) 0)))