#+Author: A. U. Thor
#+Date: [2014-01-06 Mon]
#+MACRO: version 2.1
#+BEGIN_SRC emacs-lisp :exports none :tangle no
(substring (shell-command-to-string "git rev-parse --short HEAD") 0 -1)
#+END_SRC
This document interacts with version {{{version}}} of the
StackExchange API and is maintained by {{{author}}}. It was last
modified at {{{modification-time(%Y-%m-%dT%T%z)}}} (commit ??). This
copy was exported on {{{time(%Y-%m-%dT%T%z)}}}.
生成
____________
TEST
A. U. Thor
____________
[2014-01-06 Mon]
Table of Contents
_________________
This document interacts with version 2.1 of the StackExchange API and is
maintained by A. U. Thor. It was last modified at
2014-01-06T20:32:14-0500 (commit ??). This copy was exported on
2014-01-06T20:32:16-0500.
如何将当前提交(由elisp的一小部分返回)插入??
?
据说我发现了一种方法,但它在正常输出时无效,可能只在纠结过程中起作用。
答案 0 :(得分:5)
如果您向代码块添加名称,则可以从其他位置调用该代码:
#+NAME: commit
#+BEGIN_SRC emacs-lisp :exports none :tangle no
(substring (shell-command-to-string "git rev-parse --short HEAD") 0 -1)
#+END_SRC
This corresponds to git commit call_commit().
导出时获得的输出:
这对应于git commit`2464d0a'。
有关源代码块评估的文档in the org-mode manual。