I would like to get the name of the file where a particular function or macro definition was last written, for various documentation & testing purposes?
I have posted an answer that works well from me, after the help of PJB on #CommonLisp (IRC.LIBERA.CHAT), but will accept any answers which provide a portable solution that does not depend on SWANK or provides additional detail on how to achieve the same in other IDEs like LispWorks, ACL, etc.
If what you seek is a portable solution – one that is written in portable CL – then the answer to that is to define wrappers for defining forms and then use the wrappers.
In real life you'd call
define-functiondefunof course, and similarly withdefine-variableetc, and then construct a conduit package for CL which exported all the CL symbols while replacing the defining forms with these ones.If what you seek is a portable solution in the sense that it exports some standard interface but has varying implementation-dependent backends, then probably looking at what SLY or SWANK do is a good start. In the case of LW you would want the backend to use DSPECs which are how it deals with location information: