This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-12
Channels
- # announcements (76)
- # babashka (10)
- # beginners (39)
- # biff (2)
- # calva (51)
- # chlorine-clover (8)
- # cider (6)
- # clj-kondo (15)
- # clj-on-windows (13)
- # cljdoc (26)
- # cljs-dev (8)
- # clojure (196)
- # clojure-austin (17)
- # clojure-europe (36)
- # clojure-nl (4)
- # clojure-spec (8)
- # clojure-uk (2)
- # clojurescript (18)
- # community-development (4)
- # conjure (1)
- # core-typed (38)
- # cursive (5)
- # datalevin (17)
- # datomic (19)
- # docker (1)
- # events (2)
- # interop (2)
- # jobs (4)
- # kaocha (28)
- # lsp (22)
- # nyc (1)
- # off-topic (10)
- # pedestal (1)
- # portal (22)
- # re-frame (22)
- # react (10)
- # shadow-cljs (19)
- # spacemacs (7)
- # tools-deps (11)
- # vim (14)
- # xtdb (7)
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))
=> inc
I 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).