Skip to content

Instantly share code, notes, and snippets.

@lispm
Created April 9, 2015 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lispm/082860afd06a6209fc76 to your computer and use it in GitHub Desktop.
Save lispm/082860afd06a6209fc76 to your computer and use it in GitHub Desktop.
Retrieving Source Code from a running Clozure CL
(defun retrieve-source-code (&optional (package *package*))
(do-symbols (s package)
(multiple-value-bind (symbol where)
(find-symbol (symbol-name s)
package)
(declare (ignore symbol))
(when (member where '(:internal :external))
(let ((ds (find-definition-sources s)))
(when (and ds (listp ds))
(loop for (nil sn) in ds
for snt = (source-note-text sn)
when snt do (progn
(terpri)
(princ snt)
(terpri)))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment