Function: org-table-delete-column

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

Signature

(org-table-delete-column)

Documentation

Delete a column from the table.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
;;;###autoload
(defun org-table-delete-column ()
  "Delete a column from the table."
  (interactive)
  (unless (org-at-table-p) (user-error "Not at a table"))
  (org-table-find-dataline)
  (when (save-excursion (skip-chars-forward " \t") (eolp))
    (search-backward "|"))		;snap into last column
  (org-table-check-inside-data-field nil t)
  (let* ((col (org-table-current-column))
	 (beg (org-table-begin))
	 (end (copy-marker (org-table-end)))
	 (shrunk-columns (remq col (org-table--list-shrunk-columns))))
    (org-table-expand beg end)
    (org-table-save-field
     (goto-char beg)
     (while (< (point) end)
       (if (org-at-table-hline-p)
	   nil
	 (org-table-goto-column col t)
	 (and (looking-at "|[^|\n]+|")
	      (replace-match "|")))
       (forward-line)))
    (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
       "$" (list (cons (number-to-string col) "INVALID")) col -1 col))))