From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Possible to use src block to generate org headlines for export?
Date: Thu, 24 Jul 2014 15:41:10 -0400 [thread overview]
Message-ID: <87a97ylf3d.fsf@alphaville.bos.redhat.com> (raw)
In-Reply-To: loom.20140724T202040-999@post.gmane.org
Charles Berry <ccberry@ucsd.edu> writes:
> Nick Dokos <ndokos <at> gmail.com> writes:
>
>>
>> Charles Berry <ccberry <at> ucsd.edu> writes:
>>
>> > Matt Lundin <mdl <at> imapmail.org> writes:
>> >
>> > [deleted]
> [more deleted]
>
>> > Or wrap the results in a drawer when you type C-c C-c, but render them as
>> > raw on export (which removes the drawer and replaces with raw results).
>> >
>> > Like so:
>> >
>> > #+header: :results (if (boundp 'backend) "raw" "drawer")
>> > #+BEGIN_SRC emacs-lisp :exports both
>> >
>> > (format "* headline\n1\n2\n5\n")
>> > #+END_SRC
>> >
>>
>> That's a very nice tip - one small weakness is that it'll do the wrong
>> thing if you just happen to have a binding for "backend" outside of the
>> export mechanism.
>>
>
> Fair enough. But getting assurance that an export process is really up and
> running looked tricky to me - what with anonymous backends and `info' being
> let-bound by babel. So this is what I came up with for a more robust test.
> Hopefully, nobody will bind both `backend' and `org-export-current-backend'
> to a common backend outside of doing an export...
>
>
> #+BEGIN_SRC emacs-lisp
> (defun org-export-if-exporting (export-val &optional other-val)
> "If backend exists, is a backend, and is currently running
> return EXPORT-VAL otherwise return OTHER-VAL or \"\"."
> (if
> (and (boundp 'backend)
> (equal (car (append backend nil))
> 'cl-struct-org-export-backend)
> (equal org-export-current-backend
> (org-export-backend-name backend)))
> export-val
> (or other-val "")))
>
> #+END_SRC
> #+header: :results (org-export-if-exporting "raw")
> #+BEGIN_SRC emacs-lisp :exports both
> (format "* headline\n1\n2\n6\n")
> #+END_SRC
>
>
Oh, man - I didn't mean that it needed hardening: it was a *very* small
weakness. I just meant to warn people so that they wouldn't do something
silly.
But thanks for going the extra distance.
Nick
next prev parent reply other threads:[~2014-07-24 19:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 23:52 Possible to use src block to generate org headlines for export? Matt Lundin
2014-07-23 1:27 ` Nick Dokos
2014-07-23 2:35 ` Matt Lundin
2014-07-23 2:46 ` Matt Lundin
2014-07-23 13:42 ` Brett Viren
2014-07-23 15:17 ` Matt Lundin
2014-07-23 16:06 ` Charles Berry
2014-07-23 17:07 ` Matt Lundin
2014-07-24 1:51 ` Nick Dokos
2014-07-24 10:21 ` Andreas Leha
2014-07-25 8:31 ` Nicolas Goaziou
2014-07-25 13:05 ` Andreas Leha
2014-07-25 13:23 ` Nicolas Goaziou
2014-07-25 13:39 ` Andreas Leha
2014-07-25 14:26 ` Thorsten Jolitz
2014-07-25 16:08 ` Nicolas Goaziou
2014-07-26 0:26 ` Andreas Leha
2014-07-26 8:07 ` Nicolas Goaziou
2014-07-26 19:47 ` Andreas Leha
2014-07-24 18:40 ` Charles Berry
2014-07-24 19:41 ` Nick Dokos [this message]
2014-07-23 19:53 ` Brett Viren
2014-07-23 20:42 ` Matt Lundin
2014-07-24 22:05 ` Brett Viren
2014-07-23 16:09 ` Rick Frankel
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a97ylf3d.fsf@alphaville.bos.redhat.com \
--to=ndokos@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.