【问题标题】:verbatim output of brackets with org-babel使用 org-babel 逐字输出括号
【发布时间】:2013-10-30 15:54:53
【问题描述】:

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

#+begin_src C :includes <stdio.h> :results output verbatim :exports both
puts("[1] 2 3 3");
#+end_src

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

#+RESULTS:
: [1]

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

#+RESULTS:
: [1] 2 3 3

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

#+begin_src C :includes <stdio.h> :results outputs verbatim :exports both
puts("foo");
puts("[1] 2 3 3");
#+end_src
#+RESULTS:
: foo
: [1] 2 3 3

我使用的是 Org 模式版本 8.2 (8.2-6-gd745cd-elpa)。

【问题讨论】:

    标签: org-mode org-babel


    【解决方案1】:

    必须在源代码中添加一个字母才能使其正常工作:

    #+begin_src C :results output
    puts("[1] 2 3 3");
    #+end_src
    
    #+RESULTS:
    : [1] 2 3 3
    

    这是补丁:

    Modified   lisp/ob-C.el
    diff --git a/lisp/ob-C.el b/lisp/ob-C.el
    index e9eec93..c35b3d0 100644
    --- a/lisp/ob-C.el
    +++ b/lisp/ob-C.el
    @@ -106,7 +106,7 @@ or `org-babel-execute:C++'."
         ((lambda (results)
            (org-babel-reassemble-table
        (org-babel-result-cond (cdr (assoc :result-params params))
    -     (org-babel-read results)
    +     (org-babel-read results t)
          (let ((tmp-file (org-babel-temp-file "c-")))
            (with-temp-file tmp-file (insert results))
            (org-babel-import-elisp-from-file tmp-file)))
    

    我也向邮件列表发送了一个补丁。

    【讨论】:

    • 并且补丁已被应用。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多