Code expansion in org mode prose text
Say I want to write about the count of my system’s processors at the time of my writing. Or my current location’s weather or stock shares or …use your imagination. Now I do it like that:
> At this very moment I’m writing this text on a machine with 4
processors.
Verbatim:
At this very moment I'm writing this text on a machine with src_bash{cat /proc/cpuinfo | grep processor | wc -l} processors.
Practically I expand a snippet, write any bash command into the curly braces and instantly have it’s evaluated result written into my prose.
Python example
Inline
Two plus two equals 4
Verbatim:
> Two plus two equals src_python{return(2+2)} {{{results(=4=)}}}
Code block
Expand any code block’s result as well: 12
Verbatim:
> Expand any [[python_example][code block]]'s result as well: call_python_example()
#+name: python_example
#+begin_src python
def func():
return 1+1+2+3+5
return func()
#+end_src