首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么会导致所有noweb代码块评估结果为零?

什么会导致所有noweb代码块评估结果为零?
EN

Stack Overflow用户
提问于 2022-07-18 10:39:59
回答 1查看 119关注 0票数 1

我正在对一些配置文件使用识字编程,并希望从elisp代码块评估中获得一些部分。我试着用:noweb tangle计算命名的代码块,但是它们总是结果为零,并且我没有在*Messages*中看到任何错误。下面是一个简化的hello world示例,以及我得到的结果。

Org文件

代码语言:javascript
复制
#+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

混淆结果

代码语言:javascript
复制
(print "Hello world") -> nil
"Hello world" -> nil

我还检查了org-link-elisp-confirm-functionorg-confirm-babel-evaluate都有零值,所以它们不应该阻止评估。

编辑:我忘了提到我使用的是org-auto-挂图。当直接调用org-bable-挂件时,不会出现问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-08 01:23:57

我有同样的问题,下面为我解决了它。

根据org-auto-tangle的代码,默认情况下不会对代码进行评估。为了自动评估代码,您需要将组织文件添加到org-auto-tangle-babel-safelist中。我已经发布了变量的定义和到自述文件的链接,并举例说明了如何设置变量。

代码语言:javascript
复制
(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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73020994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档