一千萬個為什麽

搜索

使用變量來確定let綁定

有沒有辦法使用變量來保存let綁定集以傳遞給以後的調用?

例如

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

然後

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

這是為了允許 outorg-export 添加選項 alist指定如何導出指定的元素。

編輯以提供清晰度( @sds 使用 cl-progv 的答案是我需要的):

我希望能夠將值的變量/列表作為“導出定義”的一部分傳遞給組織導出引擎。

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 然後 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.

最佳答案

如果我理解正確,你想要的是運行時評估 要綁定的變量,那麽你需要 progv 在Emacs中實現為 cl-progv

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

轉載註明原文: 使用變量來確定let綁定