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