问题标签 [org-babel]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
11646 浏览

emacs - 在 org-babel src 块中缩进代码

在 org-mode 文件中,代码如下:

我希望 TAB 键缩进代码,就像它在 lisp 模式下的缓冲区中一样。

我需要的是:

  • 一种判断光标是否在 src 块内的方法。它不需要在标题行本身上触发,因为在这种情况下应该发生默认的组织折叠。
  • 一种根据标头中指定的模式(在本例中为 emacs-lisp)缩进代码的方法。

Org 已经可以根据模式语法高亮 src 块,并且 TAB 钩子在那里。这看起来可行。

0 投票
2 回答
2182 浏览

emacs - org-mode 导出时获取 src 块的内容

这是我正在尝试做的事情:

我有一段 JavaScript 代码,我想在从 org 文档生成的 HTML 中显示它,并且我希望在 HTML 页面中执行该代码。对于一个简单的例子,让它像

但这抱怨 undefined symbol block-name

我发现了这个问题,它非常相似,但是那里给出的答案对我不起作用。在 Emacs org-mode 中将源代码从一个代码块输入到另一个代码块

引用块的内容/名称的语法是什么?

编辑:

我越来越近了,但还没有:

这有两个问题。script变量的值是nil并且脚本标签被转义(尖括号被替换为<and>规则(如果脚本中有小于或大于符号,它们将被替换)。

编辑1:

差不多好了!

建议org-babel-get-src-block-info让它在本地存储代码块的内容,如果它被命名为变量<name>-text,那么我以后可以得到它。

示例用法:

转义是用:results html选项处理的——这会导致 Org 逐字插入 HTML。


这是失败的最小示例。

但这将起作用并产生“预期”的结果:

<script>your script could be here</script>在 eLisp 代码块的注释中输出和 JavaScript 代码。

0 投票
2 回答
1188 浏览

clojure - Can org-mode babel tangle produce leiningen directories?

We want to automate the production of a Leiningen project tree entirely from an org-mode babel file. We want to do this so that we can also create beautiful, typeset documentation via org-latex-export-to-pdf. We want no less than full literate programming in Clojure from org-mode.

The following command:

produces a tree that looks like this:

We want to do the identical thing just by running org-babel-tangle, and no more, in our org-mode buffer in emacs.

A difficulty arises: whereas tangle is happy to produce files in existing subdirectories like src and test, it seems reluctant to produce the subdirectories if they don't exist. That means we must create the directory structure by some other means -- unless we can get tangle to do it for us, and that's the subject of this StackOverflow question.

There are six files in the directory structure created by Leiningen. I can remove them all and re-create them from my org-file with BEGIN_SRC blocks such as the following

Notice particularly the name of the subdirectory path

All is well if our directory structure already exists. org-mode's tangle will create or update all six files described above and create new files in any existing directory. We don't know how to get tangle to produce the directories; it complains that there is no such directory.

A copy of the desired .org file can be found here if you would like more details.

0 投票
3 回答
3305 浏览

emacs - Emacs org-mode:在缓冲区中定义变量并访问变量

我想在 org 文件中定义一个缓冲区宽变量,并稍后使用该变量中的值,例如,为乳胶导出定义图像的宽度。

有没有办法做到这一点?

这可以使用#+CONSTANTS:吗?

理想情况下,它应该像这样工作:

image_width我在缓冲区中定义了一个变量,例如

并将此变量用于#+ATTR_LATEX:设置,例如#+ATTR_LATEX: :width $image_width.

0 投票
1 回答
3185 浏览

emacs - 使用 org-babel 初始化 emacs:调试器进入——Lisp 错误:(void-function cl-member)

我已将我的 init.el 迁移到 org-mode 文件,以使用 org-mode 与 babel 结合的灵活性。

但是,我无法让它工作。我怀疑存在一些依赖错误,已经尝试了很多方法来修复它,但我没有能力了解哪里出了问题:

  1. 这里我的 init.el --- 除了调用一个包含所有初始化代码的 org 文件之外什么也不做

    /li>
  2. 这是 org 文件 --- 即使是最小的它也会引发错误

    /li>
  3. 这里是生成的 emacs-and-org.el --- 第一个“org babel 代码部分”在这里,但第二个不见了

    /li>
  4. 抛出的错误:

    /li>

谁能帮忙?

0 投票
1 回答
373 浏览

org-mode - 使用 org-babel 逐字输出括号

将 babel 与 org-mode 一起使用,我正在尝试获取以下 C 代码的输出:

不幸的是,点击C-cC-c这个块只会产生:

似乎尽管我使用了:results verbatim, is 输出以某种方式被解释并且之后的所有内容都[1]被忽略了。 我想知道如何配置 org-babel 以便上面的结果包含完整的输出,即我期望:

请注意,如果我的输出不是以 开头[.*],它会按我的预期显示:

我正在使用组织模式版本 8.2 (8.2-6-gd745cd-elpa)。

0 投票
1 回答
409 浏览

emacs - 将 org-mode 升级到 org-version-8.2.1-15 后,来自 http://emacsformacosx.com/ 的 emacs 24.3 无法导出 html

我做了什么: OS X 的 emacs 24.3 是从http://emacsformacosx.com/下载的,它附带捆绑的 org-mode 版本 7.9.3f。

我按照这里的方法升级了 org-mode:http: //orgmode.org/manual/Installation.html#Installation with the method#1 Using Emacs package system。

我将 (package-initialize) 包含在我的 .emacs 配置文件中。

问题:我不再可以运行 org-babel Cc、Ce、b 来导出选定的部分以进行 html 导出。

当我运行 Cc Ce hh 时,它显示“无效密钥”

当我运行 Mx org-publish-project 时,它显示“无效函数:(......)”。

任何人都可以阐明这个问题吗?

0 投票
2 回答
90 浏览

emacs - 忽略 html 导出中的 noweb 语法

我有一个组织文档,其中包含:

而且我想实际上忽略<<refresh>>它,以便在我导出 HTML 时正确导出为实际文本<<refresh>>(这是一篇演示 org-babel 和 noweb 的文章)。相反,它导出为空白,我怎样才能让它逐字导出?

0 投票
1 回答
76 浏览

org-mode - 当前缓冲区名称作为 org babel 源块的参数

如何将当前文件及其路径传递到 org-babel 中的源块之一?例如:

我希望命令在缓冲区的当前目录中执行。

0 投票
1 回答
1113 浏览

python - org babel 代码块不能从 org 表中调用

我无法使用 sbe. 以下是一些对我不起作用的最小示例:

当我使用C-c C-c块中的点评估代码块时,代码块起作用(因此#+RESULTS输出如上所示)。

我查看了邮件列表(例如)并看到有些人可以将 babel 错误输出到*Org Babel Error Output*缓冲区,我想这将有助于调试,但我看不到在哪里打开它(toggle-debug-on-error没用)

我正在使用 org-version: 8.2.3c。我还在新的 emacs 中尝试了上述方法,-q可以选择在启动时忽略我的配置。我已确保启用 python 进行评估: