I want to get a list of all variables that I have created in a lisp session. I think that this should be possible by looking at all symbols interned in common-lisp-user. But how can I get such a list?
To get bound variables only from cl-user
you iterate all bound symbols with do-symbols
and exclude the symbols, that are imported from other packages:
(let ((external-symbols (mapcan (lambda (pkg)
(let (rez)
(do-symbols (s pkg rez)
(push s rez))))
(package-use-list (find-package 'cl-user)))))
(do-symbols (s 'cl-user)
(when (and (boundp s)
(not (member s external-symbols)))
(print s))))
You can use do-symbols
to find the symbols in the common-lisp-user
package.
See the CLHS entry for Macro DO-SYMBOLS, DO-EXTERNAL-SYMBOLS, DO-ALL-SYMBOLS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With