Get a list of user variables

I want to get a list of all the variables that I created in a lisp session. I think this should be possible if you look at all the characters interned in a general way - lisp -user. But how can I get such a list?

+4
source share
2 answers

To get related variables only from cl-user , you iterate over all related characters with do-symbols and exclude characters 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)))) 
+3
source

You can use do-symbols to find characters in the common-lisp-user package.

See the CLHS entry for macros DO-SYMBOLS, DO-EXTERNAL-SYMBOLS, DO-ALL-SYMBOLS

+2
source

Source: https://habr.com/ru/post/1384515/


All Articles