Function: org-table-convert
org-table-convert is an interactive and byte-compiled function defined
in org-table.el.gz.
Signature
(org-table-convert)
Documentation
Convert from Org table to table.el and back.
Obviously, this only works within limits. When an Org table is converted to table.el, all horizontal separator lines get lost, because table.el uses these as cell boundaries and has no notion of horizontal lines. A table.el table can be converted to an Org table only if it does not do row or column spanning. Multiline cells will become multiple cells. Beware, Org mode does not test if the table can be successfully converted - it blindly applies a recipe that works for simple tables.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun org-table-convert ()
"Convert from Org table to table.el and back.
Obviously, this only works within limits. When an Org table is converted
to table.el, all horizontal separator lines get lost, because table.el uses
these as cell boundaries and has no notion of horizontal lines. A table.el
table can be converted to an Org table only if it does not do row or column
spanning. Multiline cells will become multiple cells. Beware, Org mode
does not test if the table can be successfully converted - it blindly
applies a recipe that works for simple tables."
(interactive)
(require 'table)
(if (org-at-table.el-p)
;; convert to Org table
(let ((beg (copy-marker (org-table-begin t)))
(end (copy-marker (org-table-end t))))
(table-unrecognize-region beg end)
(goto-char beg)
(while (re-search-forward "^\\([ \t]*\\)\\+-.*\n" end t)
(replace-match ""))
(goto-char beg))
(if (org-at-table-p)
;; convert to table.el table
(let ((beg (copy-marker (org-table-begin)))
(end (copy-marker (org-table-end))))
;; first, get rid of all horizontal lines
(goto-char beg)
(while (re-search-forward "^\\([ \t]*\\)|-.*\n" end t)
(replace-match ""))
;; insert a hline before first
(goto-char beg)
(org-table-insert-hline 'above)
(beginning-of-line -1)
;; insert a hline after each line
(while (progn (beginning-of-line 3) (< (point) end))
(org-table-insert-hline))
(goto-char beg)
(setq end (move-marker end (org-table-end)))
;; replace "+" at beginning and ending of hlines
(while (re-search-forward "^\\([ \t]*\\)|-" end t)
(replace-match "\\1+-"))
(goto-char beg)
(while (re-search-forward "-|[ \t]*$" end t)
(replace-match "-+"))
(goto-char beg)))))