我正在对一些配置文件使用识字编程,并希望从elisp代码块评估中获得一些部分。我试着用:noweb tangle计算命名的代码块,但是它们总是结果为零,并且我没有在*Messages*中看到任何错误。下面是一个简化的hello world示例,以及我得到的结果。
Org文件
#+title: Hello
#+PROPERTY: header-args :tangle hello.txt :cache no :exports none
#+auto_tangle: t
#+name: hello-world-output
#+begin_src emacs-lisp :tangle no :eval no-export :results output
(print "Hello world")
#+end_src
#+name: hello-world-value
#+begin_src emacs-lisp :tangle no :eval no-export :results value
"Hello world"
#+end_src
#+begin_src text :noweb tangle
<<hello-world-output>> -> <<hello-world-output()>>
<<hello-world-value>> -> <<hello-world-value()>>
#+end_src混淆结果
(print "Hello world") -> nil
"Hello world" -> nil我还检查了org-link-elisp-confirm-function和org-confirm-babel-evaluate都有零值,所以它们不应该阻止评估。
编辑:我忘了提到我使用的是org-auto-挂图。当直接调用org-bable-挂件时,不会出现问题。
发布于 2022-08-08 01:23:57
我有同样的问题,下面为我解决了它。
根据org-auto-tangle的代码,默认情况下不会对代码进行评估。为了自动评估代码,您需要将组织文件添加到org-auto-tangle-babel-safelist中。我已经发布了变量的定义和到自述文件的链接,并举例说明了如何设置变量。
(defvar org-auto-tangle-babel-safelist '()
"List of full path of files for which code blocks need to be evaluated.
By default, code blocks are not evaluated during the auto-tangle to avoid
possible code execution from unstrusted source. To enable code blocks evaluation
for a specific file, add its full path to this list.")https://github.com/yilkalargaw/org-auto-tangle#babel-auto-tangle-safelist
https://stackoverflow.com/questions/73020994
复制相似问题