* [CODE SNIPPET] transpose table at point
@ 2010-07-08 18:10 Juan
0 siblings, 0 replies; only message in thread
From: Juan @ 2010-07-08 18:10 UTC (permalink / raw)
To: Emacs-orgmode
The below code snippet is an interactive function to transpose an
org-mode table.
Just works for normal tables (no formulas, etc.).
Evaluate the code below (by throwing into .emacs, or by calling C-x
C-e after the defun()), and call M-x org-transpose-table-at-point with
the cursor on a table.
The magic part was stolen from the Library of Babel (1).
Hope it helps.
.j.
(1) http://orgmode.org/worg/org-contrib/babel/library-of-babel.php#sec-3_2
8<------------------------------------------------------------
(require 'cl)
(defun org-transpose-table-at-point ()
"Transpose orgmode table at point, eliminate hlines."
(interactive)
(let ((contents (apply #'mapcar* #'list ;; <== LOB magic imported here
(remove-if-not 'listp ;; remove 'hline from list
(org-table-to-lisp)))) ;; signals error if not table
)
(delete-region (org-table-begin) (org-table-end))
(insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) " |\n" ))
contents
""))
(org-table-align)
)
)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-07-08 18:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-08 18:10 [CODE SNIPPET] transpose table at point Juan
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.