From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Possible to use src block to generate org headlines for export? Date: Thu, 24 Jul 2014 15:41:10 -0400 Message-ID: <87a97ylf3d.fsf@alphaville.bos.redhat.com> References: <87zjg1gddd.fsf@fastmail.fm> <87wqb4amqb.fsf@gmail.com> <8738dshkdw.fsf@fastmail.fm> <8761io2jnz.fsf@fastmail.fm> <87ha27a5ip.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAOtO-0007i6-2s for emacs-orgmode@gnu.org; Thu, 24 Jul 2014 15:41:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAOtF-0005QW-OY for emacs-orgmode@gnu.org; Thu, 24 Jul 2014 15:41:30 -0400 Received: from plane.gmane.org ([80.91.229.3]:56836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAOtF-0005Q8-He for emacs-orgmode@gnu.org; Thu, 24 Jul 2014 15:41:21 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XAOtE-0008TA-HN for emacs-orgmode@gnu.org; Thu, 24 Jul 2014 21:41:20 +0200 Received: from nat-pool-bos-t.redhat.com ([66.187.233.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Jul 2014 21:41:20 +0200 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Jul 2014 21:41:20 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Charles Berry writes: > Nick Dokos gmail.com> writes: > >> >> Charles Berry ucsd.edu> writes: >> >> > Matt Lundin 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