Is there a way to use a variable to hold the set of let bindings for passing to a later call?

For example

(setq a '((org-export-with-toc nil)
          (blah 2)))


(let-wrapper a
  ;; Perform the export here)

This is for the goal of allowing outorg-export to add an options alist specifying how to export the indicated element.

Editing to provide clarity (@sds's answer of using cl-progv is what I needed):

I want to be able to pass a variable/alist of values as part of an 'export definition' to the org-export engine.

If NIL, nothing will be exported.  Otherwise it must be a list of
entries for sections to be exported and exporter to use.  Each entry
is a list like this:

    (headline &optional exporter file level options)

headline     Outshine commented headline to export from.  If t,
             defaults to entire file.
exporter     Org exporter format to use when exporting.  If not
             specified (blank, t or nil), defaults to an Org
             file.  This is a symbol for the exporter to use.  If
             exporting to PDF, specify `PDF' rather than `LATEX'
             otherwise it will be exported as a `.tex' file.
file         If set, specifies the export file name.  If `T', defaults
             to the name of the exported buffer.  If `NIL', defaults
             to the name of the headline being exported if specified,
             or buffer file name if entire buffer is exported.
level        By default `SECTION' will search for top level headlines
             `* '.  Level allows for exporting specific sublevels
             instead.  This integer indicates how many stars to match.
options      List of export variables to be set prior to export.
             These values are provided as a let binding around the
             export process.

An example command would be ("Documentation" ascii t 1 ((org-export-with-toc nil)))

In the export command itself each value is let bound to the appropriate field, and then in the end org-ascii-export-to-ascii performs the export (replace ascii as specified). I'd tried using :EXPORT_OPTIONS: properties but they were not being recognized when converting to outorg and exporting, and #+OPTIONS: were not either. Instead (also allowing different options based on export format, or even multiple exports to the same format with different options) I want to use the options value as a set of let-bindings around the export process to allow it to be modified.

  • Seems like you want a destructuring-bind
    – wvxvw
    Feb 11, 2015 at 17:40
  • Or perhaps let-alist.
    – PythonNut
    Feb 11, 2015 at 18:07
  • I tried let-alist, however I don't need to access the values, only have them bound. It was not binding the values, only making them accessible Feb 11, 2015 at 18:09
  • Maybe you could write a pseudo-code example of how you are going to use it? It sounds like there might be an easier solution to this problem (eg. passing a function, a special data-structure, using a macro that does something conditionally etc.)
    – wvxvw
    Feb 11, 2015 at 18:35

1 Answer 1


If I understood you correctly and what you want is run-time evaluation of the variables to be bound, then you need progv implemented in Emacs as cl-progv:

(progv (mapcar #first a) (mapcar #'second a)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.