I would like every expression I type at the REPL to be surrounded by a wrapper before evaluation. For instance, when I type:
(+ 2 3)
I want it to become:
(wrap (+ 2 3))
How can I do that?
* Philippe-André Lorin [2006-06-29 09:36+0200] writes:
How can I do that?
There's a variable swank::*slime-repl-eval-hooks*. E.g. the following does some extra printing.
(setq swank::*slime-repl-eval-hooks* (list (lambda (form) (format t "<= ~S~%" form) (let ((v (eval form))) (format t "=> ~S~%" v) v))))
Doesn't seem to work very well if the form returns multiple values, though.
Helmut.
Philippe-André Lorin wrote:
I would like every expression I type at the REPL to be surrounded by a wrapper before evaluation. For instance, when I type:
(+ 2 3)
I want it to become:
(wrap (+ 2 3))
How can I do that?
I wrote this [1] elisp a while back. It might work.
I put [1] in my .emacs, and
(local-set-key "\C-c\C-w\C-w" 'insert-wrapping-sexp)
in lisp-mode-hook.
Put your cursor on the left-paren of the expression to wrap & hit C-c C-w C-w.
-Denis
[1] (defun insert-wrapping-sexp () "Insert an s-expression which wraps around the nearest s-expression. For best results, place the point on the left-parenthesis of the to-be-wrapped s-expression. (See `insert-wrapping-expression'.)" (interactive) (insert-wrapping-expression "(" ")" t))
(defun insert-wrapping-expression (ldelim rdelim &optional space) "Insert an expression which wraps around another expression. Place the point on the left-most element of the to-be-wrapped expression. See insert-wrapping-sexp for an example of use." (interactive) (forward-sexp 1) (insert rdelim) (backward-char 1) (backward-sexp 1) (insert ldelim) (when space (insert " ")) (backward-char 1))