Skip to content

Instantly share code, notes, and snippets.

@bhyde
Last active April 26, 2016 15:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bhyde/5896565 to your computer and use it in GitHub Desktop.
Save bhyde/5896565 to your computer and use it in GitHub Desktop.
A few things for playing with quicklisp metadata. Note that this reveals assorted things that make life interesting; so use 'em in a clean discardable session. Probably ccl only.
(in-package #:cl-user)
(eval-when (:compile-toplevel :load-toplevel :execute)
(ql:quickload "cl-ppcre")
(ql:quickload "optima")
(ql:quickload "optima.ppcre")
(use-package '#:optima)
(use-package '#:optima.ppcre))
(defun ensure-all-system-are-downloaded ()
"Download and unpack the tar files of all distributions."
(map nil #'ql-dist:ensure-installed (ql:system-list)))
(defmacro ignore-errors-but-trace (me &body body)
`(handler-case (progn ,@body)
(error (e) (format *error-output* "~&Error(~A): ~A" ,me e)))
#+nil
`(flet ((thunk () ,@body))
(block :ignore
(handler-bind
((error #'(lambda (e)
(format *error-output* "~&Error: ~A" e)
(return-from :ignore nil))))
(funcall #'thunk)))))
(defparameter *systems-to-ignore*
'("cl-fuse" ;; don't recall why this got on this list.
"cl-v4l2" ;; don't recall why this got on this list.
;; gsll is impossible without other stuff installed
"gsll"
;; teepeedee2 loads obsolete and troublesome versions of alexandria and trival-garbage
"teepeedee2"
))
(defvar *current-for-debug*)
(defun map-over-ql-system-definitions (ql-systems function)
"QL-systems is a list of ql-dist:system objects. The function is invoked on the
asdf define-system form of each of the one. This is done via find-system (so all
kinds of side effects are possible), and a bit of hackery using advise. Everything
is wrapeed in ignore-errors-but-trace."
(asdf/find-system:clear-defined-systems) ;; bang!
(macrolet ((with-advice ((function-name advice &rest details) &body body)
`(unwind-protect
(progn
(advise ,function-name ,advice ,@details)
,@body)
(unadvise ,function-name))))
(with-advice (asdf/defsystem:register-system-definition
(funcall function arglist)
:when :before)
(loop
for *current-for-debug* in ql-systems
as system-name = (or (ignore-errors-but-trace "ql-dist:name"
(ql-dist::name *current-for-debug*))
(continue))
unless (member system-name *systems-to-ignore* :test #'string=)
do
#+nil (format *error-output* "~&-- ~A --" system-name)
(let ((p *package*))
(ignore-errors-but-trace "asdf:find-system"
(asdf:find-system system-name))
(unless (eq p *package*)
(format *error-output* "~&DAMN: ~A changed package to ~A" system-name *package*)))
))))
(defmacro do-ql-systems ((def ql-systems) &body body)
"Convinence wrapper for map-over-asdf-system-definitions."
`(map-over-ql-system-definitions ,ql-systems #'(lambda (,def) ,@body)))
(defun ql-system-of-name (name)
(find name (ql:system-list) :key 'ql-dist:name :test #'string=))
(defparameter zzz
(loop with zzz = '("big-string"
"cl-css"
"cl-curlex"
"enchant" ; akd "cl-enchant"
"cl-geoip"
"cl-performance-tuning-helper"
"tcod" ; aka "cl-tcod"
"cl-template"
"clache"
"clinch"
"clite"
"clobber"
"delorean"
"generators"
"gettext"
"inner-conditional"
"lowlight"
"new-op"
"petit.package-utils"
"policy-cond"
"pretty-function"
"rectangle-packing"
"stmx"
"track-best"
"treedb"
"utilities.print-items"
"weblocks-stores"
"weblocks-utils")
for n in zzz
as s = (ql-system-of-name n)
unless s do (format t "~&Error: ~a not found." n)
when s collect s))
(defun properties-in-systems (&optional (ql-systems (ql:system-list)))
"Find out what properties people are using."
(ensure-all-system-are-downloaded)
(let ((count 0)
(result ()))
(do-ql-systems (system-definition ql-systems)
(incf count)
(ignore-errors-but-trace "study system"
(loop
with (nil . details) = system-definition
for (key nil) on details by #'cddr
do (incf (getf result key 0)))))
(values count result)))
;; > (properties-in-systems)
;; ... much noise ..
;; 2190
;; (:long-name 1 :test-system 1 :test-name 3 :package-name 8 :weakly-depends-on 1
;; :encoding 44 :default-component-class 47 :around-compile 4 :pathname 73
;; :systems-required 21 :class 117 :maintainer 422 :in-order-to 110
;; :defsystem-depends-on 18 :license 394 :perform 67 :properties 48 :long-description 213
;; :licence 981 :version 971 :name 451 :author 1433 :serial 509 :components 2167
;; :depends-on 1859 :description 1548)
(defun ql-system-of-designation (system-designation)
(typecase system-designation
(ql-dist:system system-designation)
(t (ql-system-of-name
(asdf:component-name
(asdf:find-system system-designation))))))
(defun defsystem-of-system (system-designation)
(block nil
(do-ql-systems (def (list (ql-system-of-designation system-designation)))
(return def))))
(defun get-source-of-system (system-name)
(let ((pathname (probe-file (format nil "/Users/bhyde/w/quicklisp-projects/~a/source.txt" system-name))))
(when pathname
(ematch (cl-ppcre:split " " (with-open-file (s pathname) (read-line s)))
((list kind url)
(list (intern (string-upcase kind) (symbol-package :key))
url))
((list kind url param)
(list (intern (string-upcase kind) (symbol-package :key))
url
param))))))
(defun get-assorted-urls (system-name)
(ematch (get-source-of-system system-name)
(nil nil)
((list :git (and url (ppcre "^git://github([-/.\\w]+).git$" x)))
(list :git
url
(concatenate 'string "https://github" x "#readme")))
((list :git (and url (ppcre "^git://([-/.\\w]+).git/$" _)))
(list :git url nil))
((list :git (and url (ppcre "^http://([-/.\\w]+).git/$" _)))
(list :git url nil))
((list :git (and url (ppcre "^git://common-lisp.net(/[-/.\\w]+)/[-.\\w]+.git$" x)))
(list :git url (concatenate 'string "http://common-lisp.net"
(cl-ppcre:regex-replace "projects" x "project"))))
((list :mercurial (and url (ppcre "^https://bitbucket.org" _)))
(list :mercurial url url))
((list :mercurial url)
(list :mercurial url nil))
((list :branched-git url _)
(list :branched-git url nil #+nil branch))))
(defun summarize-a-system (system-designation)
"Note hand editting the output before posting is advised."
(let* ((qs (ql-system-of-designation system-designation))
(ds (defsystem-of-system qs))
(system-name (first ds))
(props (rest ds)))
(destructuring-bind (&key license licence description long-description author maintainer &allow-other-keys) props
(format t "~2&~A -- ~A~& ~A"
system-name (or license licence "No license specified?")
(or long-description description "No description provided."))
(when (and author
(< (length author) 50))
(format t "~& author: ~A" author))
(when (and maintainer
(not (equal author maintainer))
(< (length maintainer) 37))
(format t "~& maintained by: ~A" maintainer))
(match (get-assorted-urls system-name)
((list kind src readme?)
(format t "~& ~a: ~A" kind src)
(when readme?
(format t "~& more: <a href=\"~A\">~A</a>" readme? readme?)))))))
(defun summarize-zzz ()
"Note hand editting the output before posting is advised."
(loop
initially (format t "~&<pre>")
finally (format t "~&</pre>")
for qs in zzz
do (summarize-a-system qs)))
<pre>
big-string -- BSD 3-clause (see LICENSE)
Big strings, similar to Java's StringBuilder.
author: Robert Smith <quad@symbo1ics.com>
mercurial: https://bitbucket.org/tarballs_are_good/big-string
more: <a href="https://bitbucket.org/tarballs_are_good/big-string">https://bitbucket.org/tarballs_are_good/big-string</a>
cl-css -- MIT-style
Simple inline CSS generator
author: leo.zovic@gmail.com
git: git://github.com/Inaimathi/cl-css.git
more: <a href="https://github.com/Inaimathi/cl-css#readme">https://github.com/Inaimathi/cl-css#readme</a>
cl-curlex -- GPL
Leak *LEXENV* variable from compilation into runtime
author: Alexander Popolitov <popolit@gmail.com>
git: git://github.com/mabragor/cl-curlex.git
more: <a href="https://github.com/mabragor/cl-curlex#readme">https://github.com/mabragor/cl-curlex#readme</a>
enchant -- Public Domain
Bindings for Enchant spell-checker library
author: Teemu Likonen <tlikonen@iki.fi>
cl-geoip -- WTFPL 2.0
Wrapper around libGeoIP
git: git://github.com/dasuxullebt/cl-geoip.git
more: <a href="https://github.com/dasuxullebt/cl-geoip#readme">https://github.com/dasuxullebt/cl-geoip#readme</a>
cl-performance-tuning-helper -- MIT
A simple performance tuning helper tool box for Common Lisp
author: SUZUKI Shingo
git: git://github.com/ichimal/cl-performance-tuning-helper.git
more: <a href="https://github.com/ichimal/cl-performance-tuning-helper#readme">https://github.com/ichimal/cl-performance-tuning-helper#readme</a>
tcod -- No license specified?
Common Lisp bindings for libtcod, a truecolour
terminal-emulation library written in C.
author: Paul Sexton <eeeickythump@gmail.com>
cl-template -- MIT
A simple output-agnostic templating system for Common Lisp.
author: Peter Cannici <turkchess123@gmail.com>
git: git://github.com/alpha123/cl-template.git
more: <a href="https://github.com/alpha123/cl-template#readme">https://github.com/alpha123/cl-template#readme</a>
clache -- LLGPL
No description provided.
author: Tomohiro Matsuyama
git: git://github.com/html/clache.git
more: <a href="https://github.com/html/clache#readme">https://github.com/html/clache#readme</a>
clinch -- BSD
Describe CLinch here
author: Brad Beer (WarWeasle)
git: git://github.com/BradWBeer/CLinch.git
more: <a href="https://github.com/BradWBeer/CLinch#readme">https://github.com/BradWBeer/CLinch#readme</a>
clite -- ISC
Lite weight testing framework
author: Andreas Wild <lispy.stuff@gmail.com>
git: git://github.com/lispy-stuff/clite.git
more: <a href="https://github.com/lispy-stuff/clite#readme">https://github.com/lispy-stuff/clite#readme</a>
clobber -- No license specified?
No description provided.
git: git://github.com/robert-strandh/Clobber.git
more: <a href="https://github.com/robert-strandh/Clobber#readme">https://github.com/robert-strandh/Clobber#readme</a>
delorean -- No license specified?
Delorean is a time machine for unit tests
author: Andy Chambers
git: git://github.com/cddr/delorean.git
more: <a href="https://github.com/cddr/delorean#readme">https://github.com/cddr/delorean#readme</a>
generators -- BSD
A common lisp package providing python style generators based
on delimited continuations
author: <programmers@acceleration.net>
git: git://github.com/AccelerationNet/generators.git
more: <a href="https://github.com/AccelerationNet/generators#readme">https://github.com/AccelerationNet/generators#readme</a>
gettext -- GNU Lesser General Public Licence 3.0
A port of gettext runtime to Common Lisp
author: Thomas Bakketun <thomas.bakketun@copyleft.no>
git: git://github.com/copyleft/gettext.git
more: <a href="https://github.com/copyleft/gettext#readme">https://github.com/copyleft/gettext#readme</a>
inner-conditional -- LLGPL
Series of macros which optimizes out the inner conditional jumping
author: Masataro Asai
git: git://github.com/guicho271828/inner-conditional.git
more: <a href="https://github.com/guicho271828/inner-conditional#readme">https://github.com/guicho271828/inner-conditional#readme</a>
lowlight -- MIT
A simple and flexible syntax highlighter
author: Christoph Finkensiep <chfin@freenet.de>
git: git://github.com/chfin/lowlight.git
more: <a href="https://github.com/chfin/lowlight#readme">https://github.com/chfin/lowlight#readme</a>
new-op -- No license specified?
No description provided.
git: git://common-lisp.net/projects/new-op/new-op.git
more: <a href="http://common-lisp.net/project/new-op">http://common-lisp.net/project/new-op</a>
petit.package-utils -- MIT
petit tool box for packaging
author: SUZUKI Shingo
git: git://github.com/ichimal/petit.package-utils.git
more: <a href="https://github.com/ichimal/petit.package-utils#readme">https://github.com/ichimal/petit.package-utils#readme</a>
policy-cond -- Public Domain
A macro to insert code based on compiler policy.
author: Robert Smith <quad@symbo1ics.com>
mercurial: https://bitbucket.org/tarballs_are_good/policy-cond
more: <a href="https://bitbucket.org/tarballs_are_good/policy-cond">https://bitbucket.org/tarballs_are_good/policy-cond</a>
pretty-function -- No license specified?
No description provided.
git: git://github.com/nallen05/pretty-function.git
more: <a href="https://github.com/nallen05/pretty-function#readme">https://github.com/nallen05/pretty-function#readme</a>
rectangle-packing -- LLGPL, but I am flexible, ask me if you want something else.
Code to pack rectangles into a bigger rectangle. Useful for texture packing for OpenGL.
author: Willem Rein Oudshoorn <woudshoo@xs4all.nl>
git: git://github.com/woudshoo/rectangle-packing.git
more: <a href="https://github.com/woudshoo/rectangle-packing#readme">https://github.com/woudshoo/rectangle-packing#readme</a>
stmx -- LLGPL
Composable Software Transactional Memory
author: Massimiliano Ghilardi
branched-git: git://github.com/cosmos72/stmx.git
track-best -- Free
Macros/functions for tracking the best items. See the README.md for more details.
author: Patrick Stein <pat@nklein.com>
git: http://git.nklein.com/lisp/libs/track-best.git/
treedb -- MIT
A hierarchical key-value-database
author: Christoph Finkensiep <chfin@freenet.de>
git: git://github.com/chfin/treedb.git
more: <a href="https://github.com/chfin/treedb#readme">https://github.com/chfin/treedb#readme</a>
utilities.print-items -- LLGPLv3; see COPYING file for details.
This system provides some generic condition classes in
conjunction with support functions and macros.
author: Jan Moringen <jmoringe@techfak.uni-bielefeld.de>
git: git://github.com/scymtym/utilities.print-items.git
more: <a href="https://github.com/scymtym/utilities.print-items#readme">https://github.com/scymtym/utilities.print-items#readme</a>
weblocks-stores -- LLGPL
A base for weblocks stores
author: Olexiy Zamkoviy
maintained by: Olexiy Zamkoviy, Scott L. Burson
git: git://github.com/html/weblocks-stores.git
more: <a href="https://github.com/html/weblocks-stores#readme">https://github.com/html/weblocks-stores#readme</a>
weblocks-utils -- Public Domain
Utils for weblocks framework
author: Olexiy Zamkoviy
git: git://github.com/html/weblocks-utils.git
more: <a href="https://github.com/html/weblocks-utils#readme">https://github.com/html/weblocks-utils#readme</a>
</pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment