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))