Subject: Re: finding package name of a symbol at execution time
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 29 Aug 2007 03:08:17 -0500
Newsgroups: comp.lang.lisp
Message-ID: <irCdndNnqZXstEjbnZ2dnUVZ_ofinZ2d@speakeasy.net>
Pillsy  <pillsbury@gmail.com> wrote:
+---------------
| Frank Goenninger DG1SBG <dont-email...@nomail.org> wrote:
| > I currently only get the current package I am *using* the symbol
| > in.
| 
| You can get a list of all the packages it might be defined in, and
| then see which package (if any) it's actually defined in. First check
| to see if it's an :INTERNAL or :EXTERNAL symbol of *PACKAGE*, and then
| see if it's an :EXTERNAL symbol of any of the packages that *PACKAGE*
| uses. Like so:
| 
| (defun find-package-defining-symbol (designator)
|   (let ((name (string designator)))
|     (labels ((in-package-p (package)
| 	      (nth-value 1 (find-symbol name package))))
|      (if (member (in-package-p *package*) '(:external :internal))
| 	 *package*
| 	 (find :external (package-use-list *package*) :key #'in-package-p)))))
+---------------

More generally, don't forget about APROPOS-LIST.
Not applicable to the OP's problem, but can often
be useful in user-written debugging aids.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607