Skip to content
/ ob-hy Public

Org-Babel support for evaluating hylang code.

Notifications You must be signed in to change notification settings

brantou/ob-hy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ob-hy

https://travis-ci.org/brantou/ob-hy.svg?branch=master https://melpa.org/packages/ob-hy-badge.svghttps://stable.melpa.org/packages/ob-hy-badge.svg

Introduction

ob-hy enables Org-Babel support for evaluating Hy code. It was created based on the usage of ob-template.

(print "hello world")

Examples

variables

#+BEGIN_SRC hy :var a=3 b=5
  (+ a b)
#+END_SRC
#+RESULTS:
: 8

table and list

#+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

#+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
<<square>>
(print (square x))
#+END_SRC
#+RESULTS: calc-square
: 0
#+CALL: calc-square(x=5)
#+RESULTS:
: 25

session

#+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

Tests can be executed by make test or invoking emacs directly with the command-line below:

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