QuickLisp hacks

My take on Quicklisp who-calls and who-is-called-by analogues. Perhaps I should change the RECURSIVELY default from nil to t. Suggestions on how to cover local-projects anyone?
;;; hacks.lisp -- QuickLisp goodies

;;; patch quicklisp/dist.lisp

(in-package #:ql-dist)

(defgeneric system-apropos-list (term)
  (:method ((term symbol))
    (system-apropos-list (string-downcase term)))
  (:method ((term string))
    (loop
       with term = (string-downcase term)
       for system in (provided-systems t)
       when (or (search term (name system))
                (search term (name (release system))))
       collect system)))

;;;; patch quicklisp/misc.lisp

(in-package #:quicklisp-client)

(defun who-depends-on (system-name &optional recursively)
  "Return a list of names of systems that depend on SYSTEM-NAME.
Optional RECURSIVELY true to include indirect dependents."
  (loop
     with nam-req = (mapcar (lambda (s)
			      (cons (name s)
				    (required-systems s)))
			    (provided-systems t))
     for names = (list system-name) then (nconc names who)
     for next = names then (cdr next)
     for who = (loop
		  for (name . requirements) in nam-req
		  with required = (first next)
		  when (and (member required requirements :test 'string=)
			    (not (member name names :test 'string=)))
		  collect name)
     unless recursively return who
     unless next return (cdr names)))

(defun who-is-required-by (system-name &optional recursively)
  "Return a list of names of systems that SYSTEM-NAME depends on.
Optional RECURSIVELY true to include indirect requirements."
  (loop
     for names = (list system-name) then (nconc names who)
     for next = names then (cdr next)
     for who = (let* ((name (first next))
		      (system (system name))
		      (dependents (and system 
				       (required-systems system))))
		 (set-difference dependents names :test 'string=))
     unless recursively return who
     unless next return (cdr names)))

;;; hacks.lisp end

Devon Sean McCullough
Last modified: Wed Apr 8 14:47:15 EDT 2015