From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ethan Subject: ReStructured Text table exporter Date: Tue, 10 Aug 2010 14:48:38 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1294709818==" Return-path: Received: from [140.186.70.92] (port=56917 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oitvj-0001IV-7L for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 14:52:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OitsO-00080k-3I for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 14:48:41 -0400 Received: from mail-qy0-f176.google.com ([209.85.216.176]:40891) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OitsN-00080O-TU for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 14:48:40 -0400 Received: by qyk34 with SMTP id 34so10234125qyk.0 for ; Tue, 10 Aug 2010 11:48:38 -0700 (PDT) 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 --===============1294709818== Content-Type: multipart/alternative; boundary=0016e65bbaf4c64006048d7c947e --0016e65bbaf4c64006048d7c947e Content-Type: text/plain; charset=ISO-8859-1 Hi, I found it useful to have Org mode export a table into ReStructured Text. Here's my code: ------------ ;; RST export for orgtbl (defun orgtbl-to-rst-line (line) (apply 'format (cons *org-rst-lfmt* line))) (defun orgtbl-to-rst (table params) "Convert the Orgtbl mode TABLE to ReStructuredText." (let* ((hline (concat "+-" (mapconcat (lambda (width) (apply 'string (make-list width ?-))) org-table-last-column-widths "-+-") "-+")) (*org-rst-lfmt* (concat "| " (mapconcat (lambda (width) (format "%%-%ss" width)) org-table-last-column-widths " | ") " |")) (params2 (list :tstart hline :hline hline :lfmt 'orgtbl-to-rst-line ))) (orgtbl-to-generic table (org-combine-plists params2 params)))) ------- Some questions: 1. I tried to use a format-string directly instead of lfmt pointing to a function, but when I tried that I got the message: apply: Not enough arguments for format string Through some experimentation, you can find that the format string is only receiving one argument, which is the list of other arguments. I'm guessing this is a bug in orgtbl-apply-format, and that (apply 'format fmt args) should be (apply 'format fmt (car args)) or something else. 2. Even if you define your own exporter function, you can't use org-table-export, because the list of exporters are hard-coded. That's fine, but in that case, can you add an example on how to use the TABLE_EXPORT_FORMAT and TABLE_EXPORT_FILE? Just something like the following in the "Built in table editor" section would have made my life easier. * Table :PROPERTIES: :TABLE_EXPORT_FILE: foo.rst :TABLE_EXPORT_FORMAT: orgtbl-to-rst :END: Other than that, thanks! Org mode's table editor is pretty useful, and closer to what I needed than table.el was. Ethan --0016e65bbaf4c64006048d7c947e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

I found it useful to have Org mode export a table into ReStructu= red Text. Here's my code:

------------

;; RST export for = orgtbl
(defun orgtbl-to-rst-line (line)
=A0 (apply 'format (cons = *org-rst-lfmt* line)))

(defun orgtbl-to-rst (table params)
=A0 "Convert the Orgtbl mod= e TABLE to ReStructuredText."
=A0 (let* ((hline (concat
=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 (mapconcat (lambda (width) (apply '= ;string (make-list width ?-)))
=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-last-column-widths "-+-")
=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-rst-lfmt* (concat
=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=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (mapconcat (lambda (wid= th) (format "%%-%ss" width))
=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-last-column-widths " | &qu= ot;)
=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 (params2
=A0=A0= =A0=A0=A0=A0=A0=A0=A0 (list
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 :tstart hline=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 :hline hline
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 :lfmt 'orgtbl-to-rst-line
=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 )))
=A0=A0=A0 (orgtbl-to-generic table (org-combin= e-plists params2 params))))

-------

Some questions:

1.= I tried to use a format-string directly instead of lfmt pointing to a func= tion, but when I tried that I got the message:

apply: Not enough arguments for format string

Through some exper= imentation, you can find that the format string is only receiving one argum= ent, which is the list of other arguments. I'm guessing this is a bug i= n orgtbl-apply-format, and that (apply 'format fmt args) should be (app= ly 'format fmt (car args)) or something else.

2. Even if you define your own exporter function, you can't use org= -table-export, because the list of exporters are hard-coded. That's fin= e, but in that case, can you add an example on how to use the TABLE_EXPORT_= FORMAT and TABLE_EXPORT_FILE? Just something like the following in the &quo= t;Built in table editor" section would have made my life easier.

* Table
=A0 :PROPERTIES:
=A0 :TABLE_EXPORT_FILE: foo.rst
=A0 := TABLE_EXPORT_FORMAT: orgtbl-to-rst
=A0 :END:

Other than that, tha= nks! Org mode's table editor is pretty useful, and closer to what I nee= ded than table.el was.

Ethan

--0016e65bbaf4c64006048d7c947e-- --===============1294709818== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1294709818==--