diff options
author | Bastien Guerry <bzg@altern.org> | 2011-12-11 17:34:37 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2011-12-11 17:34:37 +0100 |
commit | b67b6b7844f619f40a79dff69e700f24ac8d6ac9 (patch) | |
tree | 8d0745b99595daa407eae115018ef8d93473d18d | |
parent | bf25b68915b7decac1fc3054fc19425cf54c2141 (diff) | |
download | org-mode-b67b6b7844f619f40a79dff69e700f24ac8d6ac9.tar.gz |
New command: `org-table-transpose-table-at-point'.
* org-table.el (org-table-transpose-table-at-point): New
command.
Thanks to Juan Pechiar for this function.
-rw-r--r-- | lisp/org-table.el | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index 6ea0727..09f8968 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -1726,6 +1726,35 @@ blindly applies a recipe that works for simple tables." (replace-match "-+")) (goto-char beg))))) +(defun org-table-transpose-table-at-point () + "Transpose orgmode table at point and eliminate hlines. +So a table like + +| 1 | 2 | 4 | 5 | +|---+---+---+---| +| a | b | c | d | +| e | f | g | h | + +will be transposed as + +| 1 | a | e | +| 2 | b | f | +| 4 | c | g | +| 5 | d | h | + +Note that horizontal lines disappeared." + (interactive) + (let ((contents + (apply #'mapcar* #'list + ;; remove 'hline from list + (remove-if-not 'listp + ;; signals error if not table + (org-table-to-lisp))))) + (delete-region (org-table-begin) (org-table-end)) + (insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) " |\n" )) + contents "")) + (org-table-align))) + (defun org-table-wrap-region (arg) "Wrap several fields in a column like a paragraph. This is useful if you'd like to spread the contents of a field over several |