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


Chuck


Reply via email to