From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Talmage Subject: Re: Insert git hash into exported document Date: Wed, 28 Dec 2016 14:12:57 -0500 Message-ID: References: <87k2aqh099.fsf@toel.it> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c05e5ccba35360544bcc110 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMJen-0002KS-K7 for emacs-orgmode@gnu.org; Wed, 28 Dec 2016 14:13:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMJem-0002a6-Gv for emacs-orgmode@gnu.org; Wed, 28 Dec 2016 14:13:01 -0500 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:34749) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cMJem-0002Zh-B5 for emacs-orgmode@gnu.org; Wed, 28 Dec 2016 14:13:00 -0500 Received: by mail-qk0-x232.google.com with SMTP id h201so113845390qke.1 for ; Wed, 28 Dec 2016 11:12:58 -0800 (PST) In-Reply-To: <87k2aqh099.fsf@toel.it> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Daniele Pizzolli Cc: Org Mode Mailing List --94eb2c05e5ccba35360544bcc110 Content-Type: text/plain; charset=UTF-8 On Fri, Dec 23, 2016 at 3:13 PM, Daniele Pizzolli wrote: > > David Talmage writes: > > > I'd like to insert the git hash of HEAD in the org-mode documents that I > > export. Is there an easy way? I'm exporting to LaTeX. > > ... #+NAME: hash-from-lisp > #+BEGIN_SRC emacs-lisp > (shell-command-to-string "git rev-parse HEAD" ) > #+END_SRC > > #+RESULTS: hash-from-lisp > : 099b6ceee7264832b8e13f1156974b8017e6e4bb > > You can hide the result using proper headers or the noexport tag and > then print the result in a verbose way: > > The latest commit hash is src_emacs-lisp[:var i=hash-from-lisp]{(format > "%s" i)} > > Thanks! That does what I want. Alas, it has a side effect. When I put all that in my document, I get the hash I desire but I also get this Emacs LISP code in my document: \begin{verbatim} (shell-command-to-string "git rev-parse HEAD" ) \end{verbatim} I added :exports results to the BEGIN_SRC block to remove the code. ... --94eb2c05e5ccba35360544bcc110 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Fri, Dec 23, 2016 at 3:13 PM, Daniele Pizzolli <= ;dan@toel.it> wrote:

David Talmage writes:

> I'd like to insert the git hash of HEAD in the org-mode documents = that I
> export.=C2=A0 Is there an easy way?=C2=A0 I'm exporting to LaTeX.<= br>

...=C2=A0
#+NAME: hash-from-lisp
#+BEGIN_SRC emacs-lisp
=C2=A0 (shell-command-to-string "git rev-parse HEAD" )
#+END_SRC

#+RESULTS: hash-from-lisp
: 099b6ceee7264832b8e13f1156974b8017e6e4bb

You can hide the result using proper headers or the noexport tag and
then print the result in a verbose way:

The latest commit hash is src_emacs-lisp[:var i=3Dhash-from-lisp]{(format &= quot;%s" i)}


Thanks!=C2=A0 That does what I want.= =C2=A0 Alas, it has a side effect.=C2=A0 When I put all that in my document= , I get the hash I desire but I also get this Emacs LISP code in my documen= t:

\begin{verbatim}
(shell-command-= to-string "git rev-parse HEAD" )
\end{verbatim}

I added :exports results to the BEGIN_SRC block to = remove the code.



...= =C2=A0
--94eb2c05e5ccba35360544bcc110--