https://github.com/brantou/ob-crystal
Org-Babel support for evaluating crystal code.
https://github.com/brantou/ob-crystal
crystal emacs-lisp org-babel
Last synced: 4 months ago
JSON representation
Org-Babel support for evaluating crystal code.
- Host: GitHub
- URL: https://github.com/brantou/ob-crystal
- Owner: brantou
- Created: 2017-08-08T09:13:06.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-26T07:54:53.000Z (over 7 years ago)
- Last Synced: 2025-01-13T06:08:38.284Z (5 months ago)
- Topics: crystal, emacs-lisp, org-babel
- Language: Emacs Lisp
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
#+TITLE: ob-crystal
[[https://travis-ci.org/brantou/ob-crystal][file:https://travis-ci.org/brantou/ob-crystal.svg?branch=master]][[https://melpa.org/#/ob-crystal][file:https://melpa.org/packages/ob-crystal-badge.svg]]* Introduction
:PROPERTIES:
:ID: f77166b9-b12f-4d0b-899e-f2775a36c6fa
:END:=ob-crystal= enables [[http://orgmode.org/worg/org-contrib/babel/intro.html][Org-Babel]] support for evaluating [[https://crystal-lang.org/][Crystal]] code.
It was created based on the usage of [[./ob-template.el][ob-template]].#+BEGIN_SRC crystal
"hello world"
#+END_SRC#+RESULTS:
: hello world* Examples
:PROPERTIES:
:ID: f35f7535-4a10-4e8e-9c41-71d24e1a5aaf
:END:
** variables
:PROPERTIES:
:ID: e4f5eca1-cbd3-4a46-a8f3-ba92a2b869f6
:END:
: #+BEGIN_SRC crystal :var a=3 b=4
: a+b
: #+END_SRC: #+RESULTS:
: : 7
** table and list
:PROPERTIES:
:ID: 58b80b9d-3337-4d7a-9872-3d88db8d3122
:END:
: #+NAME: tel-note
: | name | tel |
: |-------+--------|
: | brant | 170... |
: | ou | 138... |: #+BEGIN_SRC crystal :var tb=tel-note :results output table
: puts tb
: #+END_SRC: #+RESULTS:
: | brant | 170... |
: | ou | 138... |: #+BEGIN_SRC crystal :var lst='(1 2 3) :results output
: puts lst
: puts num for num in lst
: #+END_SRC: #+RESULTS:
: : [ 1, 2, 3 ]
: : 1
: : 2
: : 3** literate programming
:PROPERTIES:
:ID: a36c1ddb-7e37-4ffe-9399-3e8afabd8d51
:END:
: #+NAME: square
: #+BEGIN_SRC crystal
: def square(x)
: x * x
: end
: #+END_SRC: #+NAME: calc-square
: #+BEGIN_SRC crystal :var x=0 :noweb strip-export :results output
: <>
: puts square(x)
: #+END_SRC: #+CALL: calc-square(x=5)
: #+RESULTS:
: : 25* Running tests
:PROPERTIES:
:ID: 4cacd904-edb6-407e-9359-c6c2b05d45a9
: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-crystal.el \
-l test-ob-crystal.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) \
(crystal . t))))" \
-f ob-crystal-test-runall
#+END_SRC