Function: org-table-insert-column

org-table-insert-column is an autoloaded, interactive and byte-compiled function defined in org-table.el.gz.

Signature

(org-table-insert-column)

Documentation

Insert a new column into the table.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
;;;###autoload
(defun org-table-insert-column ()
  "Insert a new column into the table."
  (interactive)
  (unless (org-at-table-p) (user-error "Not at a table"))
  (when (eobp) (save-excursion (insert "\n")))
  (unless (string-match-p "|[ \t]*$" (org-current-line-string))
    (org-table-align))
  (org-table-find-dataline)
  (let ((col (max 1 (org-table-current-column)))
	(beg (org-table-begin))
	(end (copy-marker (org-table-end)))
	(shrunk-columns (org-table--list-shrunk-columns)))
    (org-table-expand beg end)
    (save-excursion
      (goto-char beg)
      (while (< (point) end)
	(unless (org-at-table-hline-p)
	  (org-table-goto-column col t)
	  (insert "|"))
	(forward-line)))
    (org-table-goto-column col)
    (org-table-align)
    ;; Shift appropriately stored shrunk column numbers, then hide the
    ;; columns again.
    (org-table--shrink-columns (mapcar (lambda (c) (if (< c col) c (1+ c)))
				       shrunk-columns)
			       beg end)
    (set-marker end nil)
    ;; Fix TBLFM formulas, if desirable.
    (when (or (not org-table-fix-formulas-confirm)
	      (funcall org-table-fix-formulas-confirm "Fix formulas? "))
      (org-table-fix-formulas "$" nil (1- col) 1))))