emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ReStructured Text table exporter
@ 2010-08-10 18:48 Ethan
  0 siblings, 0 replies; only message in thread
From: Ethan @ 2010-08-10 18:48 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1.1: Type: text/plain, Size: 2024 bytes --]


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"
                                     org-table-last-column-widths " | ")
                          " |"))
           :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
  :TABLE_EXPORT_FORMAT: orgtbl-to-rst

Other than that, thanks! Org mode's table editor is pretty useful, and
closer to what I needed than table.el was.


[-- Attachment #1.2: Type: text/html, Size: 2329 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-10 18:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-10 18:48 ReStructured Text table exporter Ethan

Code repositories for project(s) associated with this inbox:


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).