From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vikas Rawal Subject: Re: Converting table to properties Date: Fri, 8 Jun 2012 05:14:00 +0530 Message-ID: <6939046439501716163@unknownmsgid> References: <-8912430512402798276@unknownmsgid> <20120606130638.GC6258@soloJazz.com> Mime-Version: 1.0 (1.0) Content-Type: multipart/alternative; boundary=14dae93407158d41b104c1ea75c3 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScmN8-0005NP-8j for emacs-orgmode@gnu.org; Thu, 07 Jun 2012 19:44:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScmN6-0006f3-FV for emacs-orgmode@gnu.org; Thu, 07 Jun 2012 19:44:09 -0400 Received: from mail-yx0-f169.google.com ([209.85.213.169]:59355) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScmN6-0006ex-Bj for emacs-orgmode@gnu.org; Thu, 07 Jun 2012 19:44:08 -0400 Received: by yenm7 with SMTP id m7so1011627yen.0 for ; Thu, 07 Jun 2012 16:44:06 -0700 (PDT) In-Reply-To: <20120606130638.GC6258@soloJazz.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Juan Pechiar Cc: org-mode mailing list --14dae93407158d41b104c1ea75c3 Content-Type: text/plain; charset=ISO-8859-1 This is a quick hack on org-table-transpose-table-at-point to print out a property list instead of a table. #+begin_src elisp (defun vikas-convert () "table to props" (interactive) (let ((contents (apply #'mapcar* #'list ;; remove 'hline from list (delq nil (mapcar (lambda (x) (when (listp x) x)) (org-table-to-lisp)))))) (delete-region (org-table-begin) (org-table-end)) (insert " :PROPERTIES:\n") (insert (mapconcat (lambda(x) (concat " :" (first x) ": " (second x) "\n" )) contents "")) (insert " :END:\n\n"))) #+end_src This transforms: | PROP1 | PROP2 | PROP3 | | 1 | 2 | 3 | into :PROPERTIES: :PROP1: 1 :PROP2: 2 :PROP3: 3 :END: Your code worked flawlessly. Thank you. Vikas --14dae93407158d41b104c1ea75c3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



=

This is a quick hack on org-table-transpose-t= able-at-point to print
out a property list instead of a table.

#+begin_src elisp

(defun vikas-convert= ()
=A0"table to props"
=A0(int= eractive)
=A0(let ((contents
=A0=A0=A0=A0=A0=A0=A0=A0(apply #= 'mapcar* #'list
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0;; remove 'hline from list
=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0(delq nil (mapcar (lambda (x) (when = (listp x) x))
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0(org-table-to-lisp))))))

=A0=A0=A0(delete-region (org-table-begin) (org-table-end))
=A0=A0=A0(insert " =A0:PROPERTIES:\n")
= =A0=A0=A0(insert (mapconcat (lambda(x) (concat " =A0:" (fi= rst x) ": " (second
=A0=A0=A0x) "\n" ))
=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0contents ""))=
=A0=A0=A0(insert " =A0:END:\n\n")))

#+end_src

This transforms:<= /span>

| PROP1 | PROP2 | PROP3 |
| 1 =A0=A0= =A0=A0| 2 =A0=A0=A0=A0| 3 =A0=A0=A0=A0|

in= to

=A0:PROPERTIES:
=A0:P= ROP1: 1
=A0:PROP2: 2
=A0:PROP3: 3
=A0:END:


Your code worked flawlessly. Thank you= .

Vikas
--14dae93407158d41b104c1ea75c3--