On Thu, Mar 17, 2011 at 7:32 PM, Martin Blais <[email protected]> wrote: > Emacs-using Clojurians may enjoy the following tidbit of > Slime I just dreamed of: > > > (defun slime-eval-at-register (reg) > "Take the cursor to a register's location and eval > the expression there. Useful for testing stuff without > having to 'go there' first." > (interactive "cEval at register: ") > (save-excursion > (jump-to-register reg) > (slime-eval-last-expression))) > > ;; Note: slime-interactive-eval is also available on C-c :, > ;; so we override it for something that looks like C-x C-e. > (define-key slime-mode-map "\C-c\C-e" 'slime-eval-at-register)
I'm curious. How does this work? I'll take a stab at it: 1. (interactive ...) is a macro that expands to nothing. 2. (define-key ...) parses the source of the named function, and if it sees (interactive ...), binds the key to a closure that presents the prompt string after interactive, gets a response from the user, and then calls that function with that response as the parameter. 3. (save-excursion ...) is a macro that wraps its body in code to push and pop the cursor location, so the insertion point returns to where it was immediately. Am I close? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
