This provides single command (/show) for the EmacsIRCClient that allows you to send the result of evaluating a lisp expression to the current channel.
Usage is simple, just type
/show followed by a lisp expression, for example:
>>> /show (let ((x 'a) (y 'b)) (list x y)) (let ((x 'a) (y 'b)) (list x y)) => (a b)
You can get erc-show.el from http://purl.org/NET/wence/erc-show.el
This now also deals with errors, instead of entering the debugger, it shows the error in question: e.g.:
>>> /show (system-type) (system-type) => Error: (void-function system-type)
Here’s a version of erc-cmd-SHOW which ensures that the expression is evaluated within the correct (channel) buffer (for buffer-local values of things):
(defun erc-cmd-SHOW (&rest form) "Eval FORM and send the result and the original form as: FORM => (eval FORM)." (let* ((form-string (mapconcat 'identity form " ")) (result (condition-case err (eval (read-from-whole-string form-string)) (error (format "Error: %s" error))))) (erc-send-message (format "%s => %S" form-string result))))
I didn’t find the quoting to be satisfactory. Take this example.
>>> /show (cons "foo" "bar") (cons "foo" "bar") => (foo . bar)
It would be better to use
prin1 by using “
%S” in the call to
format, rather than the
princ version and “
>>> /show (cons "foo" "bar") (cons "foo" "bar") => ("foo" . "bar")
The following trivial patch fixes this.
--- erc-show.el 2005-09-20 09:52:36.000000000 -0400 +++ erc-show.el 2009-09-17 12:52:59.000000000 -0400 @@ -55,7 +55,7 @@ (eval form) (error (format "Error: %s" err))))) - (insert (format " => %s" res))) + (insert (format " => %S" res))) (buffer-substring-no-properties (point-min) (1- (point-max)))))) (erc-send-message string)))