Function: table--horizontally-shift-above-and-below
table--horizontally-shift-above-and-below is a byte-compiled function
defined in table.el.gz.
Signature
(table--horizontally-shift-above-and-below COLUMNS-TO-EXTEND TOP-TO-BOTTOM-COORD-LIST)
Documentation
Horizontally shift outside contents right above and right below of the table.
This function moves the surrounding text outside of the table so that they match the horizontal growth/shrink of the table. It also untabify the shift affected area including the right side of the table so that tab related uneven shifting is avoided. COLUMNS-TO-EXTEND specifies the number of columns the table grows, or shrinks if negative. TOP-TO-BOTTOM-COORD-LIST is the vertical cell coordinate list. This list can be any vertical list within the table.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
(defun table--horizontally-shift-above-and-below (columns-to-extend top-to-bottom-coord-list)
"Horizontally shift outside contents right above and right below of the table.
This function moves the surrounding text outside of the table so that
they match the horizontal growth/shrink of the table. It also
untabify the shift affected area including the right side of the table
so that tab related uneven shifting is avoided. COLUMNS-TO-EXTEND
specifies the number of columns the table grows, or shrinks if
negative. TOP-TO-BOTTOM-COORD-LIST is the vertical cell coordinate
list. This list can be any vertical list within the table."
(save-excursion
(let (beg-coord end-coord)
(table--goto-coordinate (caar top-to-bottom-coord-list))
(let* ((cell (table--horizontal-cell-list nil 'first-only 'top))
(coord (cons (car (table--get-coordinate (cdr cell)))
(cdr (table--get-coordinate (car cell))))))
(setcar coord (1+ (car coord)))
(setcdr coord (- (cdr coord) 2))
(setq beg-coord (cons (car coord) (1+ (cdr coord))))
(while (and (table--goto-coordinate coord 'no-extension)
(not (looking-at "\\s *$")))
(if (< columns-to-extend 0)
(progn
(table--untabify-line)
(delete-char columns-to-extend))
(table--untabify-line (point))
(insert (make-string columns-to-extend ?\s)))
(setcdr coord (1- (cdr coord)))))
(table--goto-coordinate (caar (last top-to-bottom-coord-list)))
(let ((coord (table--get-coordinate (cdr (table--horizontal-cell-list nil 'first-only 'bottom)))))
(setcar coord (1+ (car coord)))
(setcdr coord (+ (cdr coord) 2))
(setq end-coord (cons (car coord) (1- (cdr coord))))
(while (and (table--goto-coordinate coord 'no-extension)
(not (looking-at "\\s *$")))
(if (< columns-to-extend 0)
(progn
(table--untabify-line)
(delete-char columns-to-extend))
(table--untabify-line (point))
(insert (make-string columns-to-extend ?\s)))
(setcdr coord (1+ (cdr coord)))))
(while (<= (cdr beg-coord) (cdr end-coord))
(table--untabify-line (table--goto-coordinate beg-coord 'no-extension))
(setcdr beg-coord (1+ (cdr beg-coord)))))))