将串行函数输出重定向到结果

Redirect sereral functions outputs to results

在 python、

的源代码中工作时
#+BEGIN_SRC python :session test :results output
print('testing1')
print('testing2')
#+END_SRC

#+RESULTS:
: testing1
: testing2

设置:results作为输出然后得到2个结果,

试试 elisp

#+begin_src emacs-lisp  :results output
(+ 21 35 12 7)
(* 25 4 12)
#+end_src

#+RESULTS:

如何让 elisp 代码将输出重定向到结果

这些源代码块有不同的行为——您的 python 代码打印到 stdout 而 elisp 只计算表达式。

等效的 elisp 块可能是

#+BEGIN_SRC elisp :results output
(princ (+ 21 35 12 7))
(print (* 25 4 12))
#+END_SRC

#+RESULTS:
: 75
: 1200

如果您想捕获两个表达式的结果,可以将它们包装在一个列表中,

#+BEGIN_SRC elisp :results value verbatim
(list (+ 1 1) (* 2 2))
#+END_SRC

#+RESULTS:
: (2 4)

#+BEGIN_SRC python :session test :results value verbatim
1 + 1, 2 + 2
#+END_SRC

#+RESULTS:
: (2, 4)