This Counterclockwise plugin demonstrates how to write user plugins targeted at dealing with the REPL.