After some search, i don't found example corresponding to my use case.

Writing a research text, i'm interested to mix source blocks code and text with results using inline mode, for example this simple example :

Open a terminal and write git --version returning git version 2.20.1

git version 2.20.1 is the simple result of src_sh[:results value :exports code]{git --version}. But using this command it's impossible to inject text (here the word returning) between the exported code git --version and the result of git -- version evaluation.

Is it possible to reproduce this behaviour using org-mode and org-babel ?


A short example of behaviour i want to achieve :

Open your terminal and run the command src_sh[exports:code]{git --version} which return $1, go to src_sh[exports: code]{cd /home/xxx/myproject} and count the number of commit using src_sh[exports:code]{git rev-list --all --count && git branch | wc -l } returning $1 commit(s) on $2 branche(s).

  • What version of Org mode are you using? M-x org-version will tell you.
    – NickD
    Commented Jan 7, 2020 at 18:49
  • Hi Nick, it's 9.3 version
    – reyman64
    Commented Jan 8, 2020 at 8:40

1 Answer 1


When I evaluate the inline src block:

src_sh[:results value :exports code]{git --version}

I get the following in my org mode buffer:

src_sh[:results value :exports code]{git --version} {{{results(=git version 2.24.1=)}}}

If you get the same thing, then the only thing you have to do is define a macro that will do what you want:

#+MACRO: results returning $1

When you export, you should get exactly what you want.

UPDATE: For your updated question, I would use src code blocks, not inline ones, but then call them inline. This is not quite what you want, but it is close:

#+MACRO: results $1

* Instructions

Open your terminal and run the command =git --version= which returns
call_gitversion[:exports results](), =cd /home/nick/emacs/emacs= and
count the number of commits using =git rev-list --all --count && git
branch | wc -l= returning call_ncommits[:exports results]() commit(s)
on call_nbranches[:exports results]() branch(es).

* Code                                                    :noexport:
#+name: gitversion
#+begin_src shell :exports none
git --version

#+RESULTS: gitversion
: git version 2.24.1

#+name: ncommits
#+begin_src shell :exports none
cd /home/nick/src/emacs/emacs
git rev-list --all --count

#+RESULTS: ncommits
: 145317

#+name: nbranches
#+begin_src shell :exports none
cd /home/nick/src/emacs/emacs
git branch | wc -l

#+RESULTS: nbranches
: 2

And this was done in a hurry: caveat emptor.

  • Thanks for your quick answer @NickD, it works, but syntax is weird if you need to add cut your long text with #+Macro which each time start on a new line, do you think there is a way to simplify/generify this syntax ?
    – reyman64
    Commented Jan 8, 2020 at 8:59
  • Sorry, I don't understand what you are saying: maybe edit your question and add an example?
    – NickD
    Commented Jan 8, 2020 at 13:16
  • I update with an example of readable syntax i'm interested to obtain
    – reyman64
    Commented Jan 8, 2020 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.