43 lines
1.3 KiB
Org Mode
43 lines
1.3 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='() :var all-parens=0 :results code pp
|
|
`(,(make-symbol use-call)
|
|
,@(mapcar (lambda (x)
|
|
(let ((splits (split-string x)))
|
|
(if (and (length= splits 1)
|
|
(= 0 all-parens))
|
|
(make-symbol (car splits))
|
|
(mapcar (lambda (y) (make-symbol y))
|
|
splits))))
|
|
entries))
|
|
#+end_src
|
|
|
|
Converting Org lists into Scheme symbol lists.
|
|
|
|
#+NAME: org-to-scheme-sym-list
|
|
#+begin_src emacs-lisp :var input='() :results code pp
|
|
`(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 pp
|
|
`(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
|