Created
February 23, 2012 22:28
-
-
Save nicferrier/1895385 to your computer and use it in GitHub Desktop.
child process lisps for fun and profit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun nic-child-lisp-hook (child-lisp) | |
;; version of a hook function which wraps child-lisp | |
`((flet ((my-func (x) (message "hello!"))) | |
,@child-lisp))) | |
(defun nic-child-lisp-hook (child-lisp) | |
;; version of a hook function which just returns child-lisp for | |
;; interpolation | |
child-lisp) | |
(macrolet | |
((childlisp | |
(out bindings &rest body) | |
(let ((childlispvar (make-symbol "child-lisp")) | |
(outvar (make-symbol "output-stream"))) | |
`(let* ((,outvar ,out) | |
(,childlispvar ; the lisp to run | |
(concat | |
(replace-regexp-in-string | |
"\n" | |
"\\\\n" | |
(format "(progn (setq load-path (quote %S)) (let %S %S))" | |
load-path | |
(list | |
,@(loop | |
for f in bindings collect | |
(list 'list | |
`(quote ,(car f)) | |
`(format "%s" ,(cadr f))))) | |
'(progn ,@(nic-child-lisp-hook body)))) | |
"\n"))) | |
(print ,childlispvar))))) | |
(childlisp | |
t | |
((x 1)) | |
(let ((a 10)) a))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is working out details around elnode's worker elisp stuff... I need to provide facilities to rewrite the child-lisp so that an flet can introduce mocking into stuff being done in child-emacsen. For example, the wiki stuff. The wiki renders creole in a child emacs. When I write an end to end test (a request level test) for the wiki I need to be able to flet the child-lisp so that it passes through stuff to the child-lisp to cause the wiki's file handling to be mocked with stuff that just returns a string.