I'm new to Emacs (after 10+ years of Vim) and want to use it primarily for clojure.
Coming from Lighttable, one thing I absolute liked was the way it evaluated just the right sections of code no matter where I am. This is basically: Evaluating a paragraph surrounding the cursor position. Some examples (||
represents the cursor, $FROM ... TO$
represents what I'd like to have evaluated):
(comment
$FROM
(my-func ||[:test :one])
(xy)TO$
$FROM
(defn [y]
(let [x y]
(println|| "xy")))
)TO$
)
So basically I want to evaluate the paragraph (Note: Not necessarily a top level form since I surround them in (comment)
). I have no knowledge of Elisp. I tried this as an effort.
(defun my-cider-eval-paragraph ()
(interactive )
(safe-excursion
(mark-paragraph)
(command-execute 'cider-eval-region)))
But I'm clearly making many mistakes. Edit: Actually, my example works if I just change safe-excursion
to save-excursion
. Funny, I actually think both spellings makes sense.
Thanks for reading.
cider-eval-defun-at-point
not do what you want? – Dan♦ Jan 30 '15 at 17:12cider-eval-region
and perhaps this will work:(cider-eval-region (save-excursion (backward-paragraph) (point)) (save-excursion (forward-paragraph) (point))
instead of using command-execute and mark-paragraph, the source of cider-eval-region is very simple, so it may be a problem with the region. What exactly goes wrong with your example? – Jordon Biondo Jan 30 '15 at 17:19pprint-region
which I guess makes sense since a region might contain multiple forms. If you submit it as an answer (and possibly note why mine doesnt work) I'll accept the answer. – ClojureMostly Jan 30 '15 at 18:33