Skip to content

Instantly share code, notes, and snippets.

@informatimago
Created January 4, 2019 18:49
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 informatimago/ed244752d63a01e70f6d0f326b200b5b to your computer and use it in GitHub Desktop.
Save informatimago/ed244752d63a01e70f6d0f326b200b5b to your computer and use it in GitHub Desktop.
(defun function-names (fun)
"
RETURN: A list of function names fbound to the function FUN.
NOTE: We only scan symbols and (setf symbols). Functions could also
be bound to slots or to various other lisp objects.
"
(let ((names '()))
(dolist (pack (list-all-packages) (delete-duplicates names))
(do-symbols (sym pack)
(when (and (fboundp sym) (eql fun (symbol-function sym)))
(push sym names))
(let ((setter `(setf ,sym)))
(when (and (fboundp setter) (eql fun (fdefinition setter)))
(push setter names)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment