Function: table-insert-sequence
table-insert-sequence is an autoloaded, interactive and byte-compiled
function defined in table.el.gz.
Signature
(table-insert-sequence STR N INCREMENT INTERVAL JUSTIFY)
Documentation
Travel cells forward while inserting a specified sequence string in each cell.
STR is the base string from which the sequence starts. When STR is an
empty string then each cell content is erased. When STR ends with
numerical characters (they may optionally be surrounded by a pair of
parentheses) they are incremented as a decimal number. Otherwise the
last character in STR is incremented in ASCII code order. N is the
number of sequence elements to insert. When N is negative the cell
traveling direction is backward. When N is zero it travels forward
entire table. INCREMENT is the increment between adjacent sequence
elements and can be a negative number for effectively decrementing.
INTERVAL is the number of cells to travel between sequence element
insertion which is normally 1. When zero or less is given for
INTERVAL it is interpreted as number of cells per row so that sequence
is placed straight down vertically as long as the table's cell
structure is uniform. JUSTIFY is a symbol left, center or
right that specifies justification of the inserted string.
Example:
(progn
(table-insert 16 3 5 1)
(table-forward-cell 15)
(table-insert-sequence "D0" -16 1 1 'center)
(table-forward-cell 16)
(table-insert-sequence "A[0]" -16 1 1 'center)
(table-forward-cell 1)
(table-insert-sequence "-" 16 0 1 'center))
(progn
(table-insert 16 8 5 1)
(table-insert-sequence "@" 0 1 2 'right)
(table-forward-cell 1)
(table-insert-sequence "64" 0 1 2 'left))
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
;;;###autoload
(defun table-insert-sequence (str n increment interval justify)
"Travel cells forward while inserting a specified sequence string in each cell.
STR is the base string from which the sequence starts. When STR is an
empty string then each cell content is erased. When STR ends with
numerical characters (they may optionally be surrounded by a pair of
parentheses) they are incremented as a decimal number. Otherwise the
last character in STR is incremented in ASCII code order. N is the
number of sequence elements to insert. When N is negative the cell
traveling direction is backward. When N is zero it travels forward
entire table. INCREMENT is the increment between adjacent sequence
elements and can be a negative number for effectively decrementing.
INTERVAL is the number of cells to travel between sequence element
insertion which is normally 1. When zero or less is given for
INTERVAL it is interpreted as number of cells per row so that sequence
is placed straight down vertically as long as the table's cell
structure is uniform. JUSTIFY is a symbol `left', `center' or
`right' that specifies justification of the inserted string.
Example:
(progn
(table-insert 16 3 5 1)
(table-forward-cell 15)
(table-insert-sequence \"D0\" -16 1 1 \\='center)
(table-forward-cell 16)
(table-insert-sequence \"A[0]\" -16 1 1 \\='center)
(table-forward-cell 1)
(table-insert-sequence \"-\" 16 0 1 \\='center))
(progn
(table-insert 16 8 5 1)
(table-insert-sequence \"@\" 0 1 2 \\='right)
(table-forward-cell 1)
(table-insert-sequence \"64\" 0 1 2 \\='left))"
(interactive
(progn
(barf-if-buffer-read-only)
(unless (table--probe-cell) (error "Table not found here"))
(list (read-from-minibuffer
"Sequence base string: " (car table-sequence-string-history) nil nil 'table-sequence-string-history)
(string-to-number
(table--read-from-minibuffer
'("How many elements (0: maximum, negative: backward traveling)" . table-sequence-count-history)))
(string-to-number
(table--read-from-minibuffer
'("Increment element by" . table-sequence-increment-history)))
(string-to-number
(table--read-from-minibuffer
'("Cell interval (0: vertical, 1:horizontal)" . table-sequence-interval-history)))
(let* ((completion-ignore-case t)
(default (car table-sequence-justify-history)))
(intern (downcase (completing-read
(format-prompt "Justify" default)
'(("left") ("center") ("right"))
nil t nil 'table-sequence-justify-history default)))))))
(unless (or (called-interactively-p 'interactive) (table--probe-cell))
(error "Table not found here"))
(string-match "\\([0-9]*\\)\\([]})>]*\\)\\'" str)
(if (called-interactively-p 'interactive)
(message "Sequencing..."))
(let* ((prefix (substring str 0 (match-beginning 1)))
(index (match-string 1 str))
(fmt (format "%%%s%dd" (if (eq (string-to-char index) ?0) "0" "") (length index)))
(postfix (match-string 2 str))
(dim (table-query-dimension))
(cells (nth 6 dim))
(direction (if (< n 0) -1 1))
(interval-count 0))
(if (string= index "")
(progn
(setq index nil)
(if (string= prefix "")
(setq prefix nil)))
(setq index (string-to-number index)))
(if (< n 0) (setq n (- n)))
(if (or (zerop n) (> n cells)) (setq n cells))
(if (< interval 0) (setq interval (- interval)))
(if (zerop interval) (setq interval (nth 4 dim)))
(save-excursion
(while (progn
(if (> interval-count 0) nil
(setq interval-count interval)
(table-with-cache-buffer
(goto-char (point-min))
(if (not (or prefix index))
(erase-buffer)
(insert prefix)
(if index (insert (format fmt index)))
(insert postfix)
(table--fill-region (point-min) (point) table-cell-info-width justify)
(setq table-cell-info-justify justify))
(setq table-inhibit-auto-fill-paragraph t))
(table--update-cell 'now)
(if index
(setq index (+ index increment))
(if (and prefix (string= postfix ""))
(let ((len-1 (1- (length prefix))))
(setq prefix (concat (substring prefix 0 len-1)
(char-to-string
(+ (string-to-char (substring prefix len-1)) increment)))))))
(setq n (1- n)))
(table-forward-cell direction t)
(setq interval-count (1- interval-count))
(setq cells (1- cells))
(and (> n 0) (> cells 0)))))
(table-recognize-cell 'force)
(if (called-interactively-p 'interactive)
(message "Sequencing...done"))
))