mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-06 22:23:42 +01:00
60 lines
1.5 KiB
Org Mode
60 lines
1.5 KiB
Org Mode
#+begin_src elisp tangle: no :results none :exports none
|
|
(setq pwd (file-name-directory buffer-file-name))
|
|
(setq name (file-name-nondirectory (substring buffer-file-name 0 -4)))
|
|
(setq lib (concat pwd "lib/"))
|
|
(setq testdir (concat pwd "test/"))
|
|
(setq mli (concat lib name ".mli"))
|
|
(setq ml (concat lib name ".ml"))
|
|
(setq test-ml (concat testdir name ".ml"))
|
|
(org-babel-tangle)
|
|
#+end_src
|
|
|
|
* Intall printers
|
|
:PROPERTIES:
|
|
:header-args: :noweb yes :comments both
|
|
:END:
|
|
|
|
Installs printers in the top-level environment.
|
|
|
|
All printers are fetched automatically using the following script:
|
|
|
|
#+NAME: printers
|
|
#+begin_src sh :results output raw
|
|
grep "val pp " ../*/*.org \
|
|
| grep -v docs \
|
|
| cut -d ":" -f 1 \
|
|
| sed 's|^../||' \
|
|
| sed 's|.org|.pp" ;|' \
|
|
| sed 's|/| |' \
|
|
| sed 's/[^ ]*/\u&/g' \
|
|
| sed 's| |.|' \
|
|
| sed 's|^|"|' \
|
|
| grep -v Top.Install_printers.pp
|
|
#+end_src
|
|
|
|
|
|
#+begin_src ocaml :tangle (eval ml) :exports none
|
|
let printers =
|
|
[
|
|
<<printers()>>
|
|
]
|
|
|
|
let eval_exn str =
|
|
let lexbuf = Lexing.from_string str in
|
|
let phrase = !Toploop.parse_toplevel_phrase lexbuf in
|
|
Toploop.execute_phrase false Format.err_formatter phrase
|
|
|
|
|
|
let rec install_printers = function
|
|
| [] -> eval_exn "#require \"lacaml.top\";;"
|
|
| printer :: printers ->
|
|
let cmd = Printf.sprintf "#install_printer %s;;" printer in
|
|
eval_exn cmd && install_printers printers
|
|
|
|
let () =
|
|
if not (install_printers printers) then
|
|
Format.eprintf "Problem installing QCaml-printers@."
|
|
|
|
#+end_src
|
|
|