40 lines
1.1 KiB
Org Mode
40 lines
1.1 KiB
Org Mode
|
#+TITLE: Babel Library
|
||
|
|
||
|
This library contains code blocks to be used by other files in this repository.
|
||
|
|
||
|
* Converting Lists
|
||
|
|
||
|
Converting org lists into guix ~use-~ calls.
|
||
|
|
||
|
#+NAME: list-to-use
|
||
|
#+begin_src emacs-lisp :var use-call="use-modules" :var entries='() :results code
|
||
|
`(,(make-symbol use-call)
|
||
|
,@(mapcar (lambda (x)
|
||
|
(mapcar (lambda (y) (make-symbol y))
|
||
|
(split-string x)))
|
||
|
entries))
|
||
|
#+end_src
|
||
|
|
||
|
Converting Org lists into Scheme symbol lists.
|
||
|
|
||
|
#+NAME: org-to-scheme-sym-list
|
||
|
#+begin_src emacs-lisp :var input='() :results code
|
||
|
`(list
|
||
|
,@(mapcar (lambda (x) (make-symbol x)) input))
|
||
|
#+end_src
|
||
|
|
||
|
* Converting Tables
|
||
|
|
||
|
#+NAME: service-converter
|
||
|
#+begin_src emacs-lisp :var input='() :colnames yes :results code
|
||
|
`(list
|
||
|
,@(mapcar
|
||
|
(lambda (row)
|
||
|
(let ((service-name (cl-first row))
|
||
|
(configuration (cl-second row)))
|
||
|
`(,(make-symbol (s-concat service-name "-service-type"))
|
||
|
(,(make-symbol (s-concat service-name "-configuration"))
|
||
|
,@(car (read-from-string configuration))))))
|
||
|
input))
|
||
|
#+end_src
|