d74fc3dab8fa

Add load-file and macroexpand middlewares
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 09 Dec 2015 17:47:41 +0000
parents d5962bdd9186
children 743c0a981785
branches/tags (none)
files nrepl.asd src/middleware/load-file.lisp src/middleware/macroexpand.lisp src/server.lisp

Changes

--- a/nrepl.asd	Wed Dec 09 16:00:46 2015 +0000
+++ b/nrepl.asd	Wed Dec 09 17:47:41 2015 +0000
@@ -31,6 +31,8 @@
                   ((:file "core")
                    (:file "describe")
                    (:file "documentation")
+                   (:file "load-file")
+                   (:file "macroexpand")
                    (:file "eval")
                    (:file "session")))))))
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/middleware/load-file.lisp	Wed Dec 09 17:47:41 2015 +0000
@@ -0,0 +1,8 @@
+(in-package #:nrepl)
+
+
+(define-middleware wrap-load-file "load-file" message
+  (let ((path (fset:lookup message "path")))
+    (load path)
+    (respond message (make-map "status" '("done")
+                               "value" "T"))))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/middleware/macroexpand.lisp	Wed Dec 09 17:47:41 2015 +0000
@@ -0,0 +1,12 @@
+(in-package #:nrepl)
+
+(define-middleware wrap-macroexpand "macroexpand" message
+  (let ((form (read-from-string (fset:lookup message "form"))))
+    (respond message
+             (make-map
+               "status" '("done")
+               "macroexpand" (format nil "~A" (macroexpand form))
+               "macroexpand-1" (format nil "~A" (macroexpand-1 form))))))
+
+
+
--- a/src/server.lisp	Wed Dec 09 16:00:46 2015 +0000
+++ b/src/server.lisp	Wed Dec 09 17:47:41 2015 +0000
@@ -24,6 +24,8 @@
     #'workaround-fireplace-fakepathsep
     #'workaround-fireplace-macroexpand-all
     #'wrap-describe
+    #'wrap-load-file
+    #'wrap-macroexpand
     #'wrap-eval
     #'wrap-documentation))