src/middleware/macroexpand.lisp @ cfbc5d205fbd

Add in-package option for `eval`
author Steve Losh <steve@stevelosh.com>
date Sat, 02 Jul 2016 17:20:41 +0000
parents 051685b12e07
children 6eb527beb6b9
(in-package #:nrepl)

(defun pretty-string (form)
  "Return a prettified string version of `form`, indented nicely."
  #-ccl (format nil "~A" form)
  ;; CCL's format doesn't indent forms nicely
  #+ccl (with-output-to-string (*standard-output*)
          (pprint form)))

(define-middleware wrap-macroexpand "macroexpand" message
  ;; TODO: handle mangled input
  (let ((form (read-from-string (fset:lookup message "form"))))
    (respond message
             (make-map
               "status" '("done")
               "macroexpand" (pretty-string (macroexpand form))
               "macroexpand-1" (pretty-string (macroexpand-1 form))))))