Created
September 28, 2023 13:28
-
-
Save Bike/5c9e1b091efd31bdc51070b498eeb7f5 to your computer and use it in GitHub Desktop.
regex-based who-whatevers search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; example use: | |
;;; (who-regex:who-calls "^MAP.*") | |
;;; => ((MAPCAR (SWANK::APPLICABLE-METHODS-KEYWORDS . #<SPI>) | |
;;; (SWANK::ENCODE-ARGLIST . #<SPI>) | |
;;; ...) | |
;;; (MAPHASH (SWANK::HASH-TABLE-TO-ALIST . #<SPI>) ...) | |
;;; ...) | |
(eval-when (:compile-toplevel :load-toplevel :execute) | |
(ql:quickload :cl-ppcre)) | |
(defpackage #:who-regex | |
(:use #:cl) | |
(:local-nicknames (#:e #:ext) (#:re #:cl-ppcre)) | |
(:export #:who-calls #:who-binds #:who-references #:who-sets | |
#:who-macroexpands #:who-specializes-directly)) | |
(in-package #:who-regex) | |
(defun who-whats (regex searcher) | |
(let ((result nil) | |
(regex (cl-ppcre:create-scanner regex))) | |
(do-all-symbols (s result) | |
(when (re:scan regex (symbol-name s)) | |
(let ((sub (funcall searcher s))) | |
(when sub | |
(push (cons s sub) result))))))) | |
(macrolet ((def (name) | |
`(defun ,name (regex) | |
(who-whats regex #',(intern (symbol-name name) "E"))))) | |
(def who-calls) | |
(def who-binds) | |
(def who-references) | |
(def who-sets) | |
(def who-macroexpands) | |
(def who-specializes-directly)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment