From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Subject: [CODE SNIPPET] transpose table at point Date: Thu, 8 Jul 2010 15:10:13 -0300 Message-ID: <20100708181013.GA28721@soloJazz.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=51516 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWvYE-0002Xl-CF for emacs-orgmode@gnu.org; Thu, 08 Jul 2010 14:10:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWvYC-00048U-PG for emacs-orgmode@gnu.org; Thu, 08 Jul 2010 14:10:22 -0400 Received: from cpoproxy2-pub.bluehost.com ([67.222.39.38]:44980) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OWvYC-000488-IG for emacs-orgmode@gnu.org; Thu, 08 Jul 2010 14:10:20 -0400 Received: from r186-48-195-229.dialup.adsl.anteldata.net.uy ([186.48.195.229] helo=iso.palmas.net) by box519.bluehost.com with esmtpa (Exim 4.69) (envelope-from ) id 1OWvY9-000197-0V for emacs-orgmode@gnu.org; Thu, 08 Jul 2010 12:10:18 -0600 Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org 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) ) )