60462d4304de

Use in-package for arglist lookup
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 02 Jul 2016 23:19:07 +0000
parents cfbc5d205fbd
children 6eb527beb6b9
branches/tags (none)
files src/middleware/documentation.lisp src/middleware/eval.lisp src/utils.lisp

Changes

--- a/src/middleware/documentation.lisp	Sat Jul 02 17:20:41 2016 +0000
+++ b/src/middleware/documentation.lisp	Sat Jul 02 23:19:07 2016 +0000
@@ -20,7 +20,7 @@
       t)
     (values nil nil)))
 
-(defun find-symbol-harder (name)
+(defun find-symbol-harder (name &optional in-package)
   "Return the symbol object with the given `name`.
 
   This should work with names like:
@@ -40,11 +40,12 @@
                (cons nil s)))))
     (destructuring-bind (package-name . symbol-name)
         (split-string (string-upcase name) #\:)
-      (find-symbol symbol-name
-                   (cond
-                     ((null package-name) *package*) ; no : at all
-                     ((string= "" package-name) (find-package "KEYWORD")) ; :keyw
-                     (t (find-package package-name))))))) ; pack:sym
+      (find-symbol
+        symbol-name
+        (cond
+          ((null package-name) (parse-in-package in-package)) ; no : at all
+          ((string= "" package-name) (find-package "KEYWORD")) ; :keyw
+          (t (find-package package-name))))))) ; pack:sym
 
 
 (define-middleware wrap-documentation "documentation" message
@@ -64,10 +65,12 @@
                    (princ-to-string (cons s arglist))))))))
 
 (define-middleware wrap-arglist "arglist" message
-  (let ((s (find-symbol-harder (fset:lookup message "symbol"))))
+  (let ((s (find-symbol-harder
+             (fset:lookup message "symbol")
+             (fset:lookup message "in-package"))))
     (respond message
              (with-when
-                 (make-map "status" '("done"))
+               (make-map "status" '("done"))
                "function-arglist"
                (multiple-value-bind (arglist foundp)
                    (find-lambda-list s)
--- a/src/middleware/eval.lisp	Sat Jul 02 17:20:41 2016 +0000
+++ b/src/middleware/eval.lisp	Sat Jul 02 23:19:07 2016 +0000
@@ -69,10 +69,6 @@
                                         #-sbcl "dunno"))))))
       (eval form))))
 
-(defun parse-in-package (in-package)
-  (if (null in-package)
-    *package*
-    (find-package (read-from-string in-package))))
 
 (defun evaluate-forms (message forms &optional in-package)
   "Evaluate each form in `forms` and shuttle back the responses.
--- a/src/utils.lisp	Sat Jul 02 17:20:41 2016 +0000
+++ b/src/utils.lisp	Sat Jul 02 23:19:07 2016 +0000
@@ -73,3 +73,7 @@
                 :using (hash-value value)
                 :collect (list key value))))
 
+(defun parse-in-package (in-package)
+  (if (null in-package)
+    *package*
+    (find-package (read-from-string in-package))))