From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: Possible to use src block to generate org headlines for export? Date: Thu, 24 Jul 2014 18:40:24 +0000 (UTC) Message-ID: 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; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XANwZ-0006df-8F for emacs-orgmode@gnu.org; Thu, 24 Jul 2014 14:40:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XANwT-0003RV-F4 for emacs-orgmode@gnu.org; Thu, 24 Jul 2014 14:40:43 -0400 Received: from plane.gmane.org ([80.91.229.3]:45333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XANwT-0003RJ-5Y for emacs-orgmode@gnu.org; Thu, 24 Jul 2014 14:40:37 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XANwQ-0008EK-GP for emacs-orgmode@gnu.org; Thu, 24 Jul 2014 20:40:34 +0200 Received: from 137.110.37.167 ([137.110.37.167]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Jul 2014 20:40:34 +0200 Received: from ccberry by 137.110.37.167 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Jul 2014 20:40:34 +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 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 Chuck