emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ethan <ethan.glasser.camp@gmail.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: ReStructured Text table exporter
Date: Tue, 10 Aug 2010 14:48:38 -0400	[thread overview]
Message-ID: <AANLkTikDxxxYZtiU_LieGv=p9XRET1dAifZri4DMic_F@mail.gmail.com> (raw)


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

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

[-- 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.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

                 reply	other threads:[~2010-08-10 18:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTikDxxxYZtiU_LieGv=p9XRET1dAifZri4DMic_F@mail.gmail.com' \
    --to=ethan.glasser.camp@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).