quicklisp-client
quicklisp-client copied to clipboard
Improve quickload function
Currently, quickload does an exact match for the system name. It would be nice if it did a match (possibly inexact) on both the system name as well as the tar-file name. In case of multiple choices, it could offer a choice to the user of which system he wants to load.
For example, although the 0MQ interface is named (and referred to as) "cl-zmq", the actual system name is "zeromq" and (ql:quickload "cl-zmq") fails to load anything. The tar file is named "cl-zmq-2010..." and quickload would succeed (possibly with a confirmation dialog) if it tried to match on the tar file name.
As another example, if a substring match was implemented (when an exact match fails), doing (ql:quickload "json") would offer the choice to load one of "cl-json", "cl-json.test" and "st-json".
The above should not be too difficult to implement and would provide benefit to most users especially in cases where multiple packages/libraries exist to do the same thing (XML parsers, PostgreSQL interfaces, etc.)
Here's a bit of code to add figure out names based on edit distance:
(defun system-names () (mapcan (lambda (d) (mapcar #'name (provided-systems d))) (all-dists)))
(defun closest (x &optional n) (let ((sorted (sort (loop for name in (system-names) collect (list name (length (com.gigamonkeys.prose-diff::lcs x name)))) #'> :key #'second))) (mapcar #'first (if n (ldiff sorted (nthcdr n sorted)) sorted))))