Org Babel functions for Elvish
This package provides the ability to execute source code blocks written in the Elvish shell language within an org-mode buffer.
Clone this repo, add it to your load path and load the package using `require`:
(add-to-list 'load-path "~/src/ob-elvish/")
(require 'ob-elvish)
(in process, will update this section when it’s available)
For an excellent introduction to literate programming using org-mode, see Howard Abrams’ Introduction to Literate Programming.
Once you have both org-mode and ob-elvish loaded, you can type Elvish code inside an org-mode src block. For example:
#+begin_src elvish put "This is Elvish" #+end_src
If you press Ctrl-c Ctrl-c
to execute the block, you will see the
output in a results block below:
#+RESULTS: : ▶ 'This is Elvish'
You can specify variables using the standard :var
header argument:
#+begin_src elvish :var n=3 put "The result is "(* $n 5) #+end_src #+RESULTS: : ▶ 'The result is 15'
You can use the :use
header argument to specify modules which should
be loaded with use
before executing the code. You can specify multiple
packages by separating them with commas:
#+begin_src elvish :use re,str :exports none pprint (re:find '^(\S+)' (str:to-lower "Hello there")) #+end_src #+RESULTS: #+begin_example [ &text= hello &start= 0 &end= 5 &groups= [ [ &text= hello &start= 0 &end= 5 ] [ &text= hello &start= 0 &end= 5 ] ] ] #+end_example