Hey. I found that there is a shortcut to evaluate an expression in cider.
SPC m e e evaluates an expresssion that is before the cursor. Is there a way to evaluate an expression that is one symbol further?
i.e. an expression that ends one symbol after the cursor? Otherwise it could work the same.
Example:
'(1 2 3 [4] 5)
The [] signifies where block cursor is located. It highlights whole character 4.
In this example SPC m e e would evaluate 3 but I want to evaluate 4.
And this is a more complicated example where I want to evaluate a longer function name:
(map [i]nc '(1 2 3)) => map
So the cursor is located on i letter but it would evaluate function map instead of inc. I would like to make it so that it would evaluate inc.
But if I go one symbol further SPC m e e evaluates inc:
(map i[n]c '(1 2 3)) => incI found that there is a channel #cider and I pasted it there too: https://clojurians.slack.com/archives/C0617A8PQ/p1649772039695489
SPC m e v was what I was looking for 🙂
I was using vab to select the () form and I'll use SPC m e ( as a replacement for this. Maybe SPC m e f too as I don't see much difference between them.
And then to evaluate only a function I'll use SPC m e v
My leader key is set to - so I instead will have - e v and - e (.
I use vim style of editing and , is a search repeat key (repeat line symbol search). This was the first thing that I changed in the config long time ago 🙂
It would also be nice to have SPC m e [ and SPC m e {... hm. I'll ask about it in CIDER chat
SPC m does the same as pressing a leader key and my leader key is not , so I was mentioning the full form where possible.
My leader keys is -
;; CIDER evaluation
(evil-define-operator mm-evil-eval-region-cider (beg end)
"Eval a text object and show in the buffer."
(cider-eval-region beg end))
(spacemacs/set-leader-keys-for-major-mode 'clojure-mode "ed" 'mm-evil-eval-region-cider)
(evil-define-operator mm-evil-eval-region-cider-popup (beg end)
"Eval a text object and show in the result buffer."
(cider--pprint-eval-form (list beg end)))
(spacemacs/set-leader-keys-for-major-mode 'clojure-mode "eD" 'mm-evil-eval-region-cider-popup)
What this does is you can press this keystroke: ,edab and it will evaluate whole () form. ab is a motion that selects whole () list. And then you can use all other motions of evil mode (`[]`, {}, word, paragraph etc).