2014-01-07 78 views
2
#+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)}}}. 

产生如何将当前的git提交插入组织模式缓冲区以便在导出时进行评估?

       ____________ 

            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

将解决这个git而不是emacs是一个选项?如果是这样,你可以看看基于过滤器的关键字扩展:http://git-scm.com/book/ch7-2.html#Keyword-Expansion – Carsten

+0

@Carsten如果它可以被强制为一个组织宏(或任何将会删除'Id:'工件),那将会更好。 :) –

回答

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的承诺`2464d0a”。

对于源代码块评估,这被记录为in the org-mode manual

相关问题