ob-hy
ob-hy copied to clipboard
Org-Babel support for evaluating hylang code.
#+TITLE: ob-hy [[https://travis-ci.org/brantou/ob-hy][file:https://travis-ci.org/brantou/ob-hy.svg?branch=master]] [[https://melpa.org/#/ob-hy][file:https://melpa.org/packages/ob-hy-badge.svg]][[https://stable.melpa.org/#/ob-hy][file:https://stable.melpa.org/packages/ob-hy-badge.svg]]
-
Introduction :PROPERTIES: :ID: 614a110c-77b2-41f8-9714-ce311ff1acb0 :END:
=ob-hy= enables [[http://orgmode.org/worg/org-contrib/babel/intro.html][Org-Babel]] support for evaluating [[http://hylang.org/][Hy]] code. It was created based on the usage of [[./ob-template.el][ob-template]].
#+BEGIN_SRC hy :results output (print "hello world") #+END_SRC
#+RESULTS: : hello world
-
Examples :PROPERTIES: :ID: 98dc532f-d354-4d5e-a4ba-2489ad02730b :END: ** variables :PROPERTIES: :ID: e4f5eca1-cbd3-4a46-a8f3-ba92a2b869f6 :END: : #+BEGIN_SRC hy :var a=3 b=5 : (+ a b) : #+END_SRC
: #+RESULTS: : : 8 ** table and list :PROPERTIES: :ID: 7beff92a-3dc6-47ad-9898-0dbbad5b090f :END: : #+NAME: tel-note : | name | tel | : |-------+--------| : | brant | 170... | : | ou | 138... |
: #+BEGIN_SRC hy :var tb=tel-note :results output table : (print tb) : #+END_SRC
: #+RESULTS: : : ((u'brant' u'170...') (u'ou' u'138...'))
: #+BEGIN_SRC hy :var lst='("1" "2" "3") :results output : (print lst) : #+END_SRC
: #+RESULTS: : : (u'1' u'2' u'3')
** literate programming :PROPERTIES: :ID: 92a873f1-0fd5-46de-8e3c-104bc2c91c01 :END: : #+NAME: square : #+BEGIN_SRC hy : (defn square [x] : (* x x)) : #+END_SRC
: #+NAME: calc-square
: #+BEGIN_SRC hy :var x=0 :noweb strip-export :results output
: <
: #+RESULTS: calc-square : : 0
: #+CALL: calc-square(x=5)
: #+RESULTS: : : 25
** session :PROPERTIES: :ID: ea79d97b-4b6c-48f6-8154-6de10ee5e40c :END: : #+BEGIN_SRC hy :session hylang :results output : (print "hello world") : (defn square [x] : (* x x)) : (print (square 5)) : #+END_SRC
: #+RESULTS: : : hello world : : ... 25
-
Running tests :PROPERTIES: :ID: 82cd12e6-b401-439a-9da5-03f0cf6e8e89 :END:
Tests can be executed by /make test/ or invoking emacs directly with the command-line below:
#+BEGIN_SRC shell emacs -Q --batch -q
-L .
-l ob-hy.el
-l test-ob-hy.el
--eval "(progn
(setq org-confirm-babel-evaluate nil)
(org-babel-do-load-languages
'org-babel-load-languages '((emacs-lisp . t)
(sh . t)
(org . t)
(hy . t))))"
-f ob-hy-test-runall #+END_SRC