emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [RFC] Changing internal representation of back-ends to defstructs
Date: Thu, 04 Jul 2013 15:42:31 +0200	[thread overview]
Message-ID: <877gh6jvaw.fsf@gmail.com> (raw)
In-Reply-To: <87obaijy8a.fsf@gmail.com> (Nicolas Goaziou's message of "Thu, 04 Jul 2013 14:39:17 +0200")

Completing myself,

> I applied the patches. Now, onto orgtbl-to-*.

Here is an example illustrating the new features provided by quick and
anonymous export back-ends:

#+begin_src emacs-lisp
(defun my-orgtbl-to-csv ()
  "Insert a comma separated version of Org table at point.
The table will be inserted at the end of the buffer.  This
function makes no assumption about the major mode in the current
back-end."
  (interactive)
  (unless (org-at-table-p) (user-error "Not at an Org table"))
  (require 'ox-org)
  (let ((table
         (org-export-string-as
          ;; Export the following table...
          (buffer-substring-no-properties (org-table-begin) (org-table-end))
          ;; ... with the following back-end.
          (org-export-create-backend
           :parent 'org
           :transcoders
           '((table . (lambda (table contents info) contents))
             (table-row . (lambda (row contents info)
                            ;; Ignore table separators.
                            (and (eq (org-element-property :type row) 'standard)
                                 (concat contents "\n"))))
             (table-cell . (lambda (cell contents info)
                             (let ((field (org-quote-csv-field contents)))
                               (if (org-export-get-next-element cell info)
                                   (concat field ",")
                                 field))))))
          ;; Focus on the table only.
          'body-only)))
    ;; Insert TABLE at an appropriate location.  For the sake of
    ;; example, it will be point-max.
    (goto-char (point-max))
    (insert table)))
#+end_src

-- 
Nicolas Goaziou

  parent reply	other threads:[~2013-07-04 13:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-03 20:57 [RFC] Changing internal representation of back-ends to defstructs Nicolas Goaziou
2013-07-03 21:48 ` Carsten Dominik
2013-07-04 12:39   ` Nicolas Goaziou
2013-07-04 12:48     ` Bastien
2013-07-04 12:55       ` Nicolas Goaziou
2013-07-04 12:59         ` Bastien
2013-07-04 13:32           ` Nicolas Goaziou
2013-07-04 13:42     ` Nicolas Goaziou [this message]
2013-07-04 14:01       ` Bastien
2013-07-04 14:45         ` Carsten Dominik
2013-07-05 17:01       ` Eric S Fraga
2013-07-05 17:09         ` Bastien
2013-07-08 11:15           ` Eric S Fraga
2013-07-08 13:59             ` Bastien
2013-07-09 16:56               ` Eric S Fraga

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=877gh6jvaw.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=carsten.dominik@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).