This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-11
Channels
- # aws (2)
- # beginners (38)
- # boot (21)
- # boot-dev (8)
- # cider (51)
- # cljsrn (3)
- # clojars (23)
- # clojure (99)
- # clojure-austin (7)
- # clojure-brasil (1)
- # clojure-dev (8)
- # clojure-dusseldorf (1)
- # clojure-estonia (20)
- # clojure-greece (4)
- # clojure-italy (3)
- # clojure-russia (1)
- # clojure-spec (28)
- # clojure-uk (47)
- # clojurescript (47)
- # core-logic (3)
- # cursive (9)
- # data-science (1)
- # datomic (50)
- # docs (12)
- # emacs (5)
- # fulcro (60)
- # graphql (33)
- # hoplon (8)
- # jobs-discuss (1)
- # keechma (31)
- # lein-figwheel (10)
- # leiningen (4)
- # off-topic (70)
- # om (1)
- # onyx (15)
- # pedestal (5)
- # re-frame (185)
- # reagent (14)
- # remote-jobs (8)
- # ring-swagger (7)
- # rum (17)
- # shadow-cljs (193)
- # specter (6)
- # sql (51)
- # unrepl (8)
Yeah, probably that’d be the only option as you’d need to step through the code to evaluate this expression.
Another idea was suggest here https://github.com/clojure-emacs/cider/issues/2113 and it’s pretty great, but it also requires some parsing of the containing forms to figure out if something is local or not.
1. p = (point)
2. go backwards until first "^("
3. count how many unbalanced "([{" we got
4. append right number of "}})" to balance
5. evl
Yeah, that’s a simpler version of what’s discussed in the ticket - there the idea is to find all local variables, get prompted for them and replace them in the expression that will get evaluated.
You idea would work for simple scenarios, but if there’s a local coming from a higher-level let
this would break.
I don't understand. My naive reasoning is:
(let [...]
(expr I want to eval) ;; cursor here
(stuff I don't care about))
basically, I want to "find the outer most sexp", then I want to, while preserving balanced (), kill everything after the cursor
then I want to eval the modified "outermost sexp"Ah, now I get it. I thought you wanted to find the first outer let
. Should have paid more attention.
That’s actual much simpler as we already have the code that finds the top-level expression and the only thing needed it just terminate the expression after the current sexp. Should be trivial to implement.
the only thing needed it just terminate the expression after the current sexp
<-- precisely what I had in mind, even better explanation! any chance this makes it into 0.18 ? 🙂
(defun cider-debug-create-local-let (start end)
"During debugging, grab the locally bound vars and create a let
binding. Place this let binding in the kill ring for future use."
(interactive "r")
(if cider--debug-mode-response
(nrepl-dbind-response cider--debug-mode-response (locals)
(let* ((code (buffer-substring-no-properties start end))
(bindings (apply #'append locals))
(formatted-bindings (mapconcat 'identity bindings " ")))
(kill-new (format "(let [%s]\n %s)" formatted-bindings code))
(message "copied let form to kill ring")))
(message "No debugging information found.")))
while debugging, highlight some code and invoke this function. it will copy the forms you have highlighted and create a let binding binding all of the local vars in a debugging session
so in that example earlier, step through it and then highlight (+ a b)
and call that function.
(defn stuff []
(let [a 1
b 2]
(+ a b)
(+ 2 3)))
and debug it. highlight (+ a b)
and run cider-debug-create-local-let
will yankCIDER install instructions say that "Starting with version 0.11, When cider-jack-in (C-c M-j) is used, CIDER takes care of injecting [nREPL] and its other dependencies." https://cider.readthedocs.io/en/latest/installation/#ciders-nrepl-middleware Yet, I'm seeing nrepl version-string "0.2.13" in nrepl-messages while on CIDER 0.16.0. Could this indicate a problem?
(This is related to debugging an issue where running tests from CIDER hangs indefinitely when a function returns a map that has a decimal value but runs fine with an integer value in the map.)
@daveliepmann I don't think so, isn't that just the version of nrepl being injected?
not sure, it definitely could be—but I would expect version 0.16.0 to be injected, right?
yes, but aren't CIDER versions supposed to match nREPL versions? and nREPL repo says 0.16.0 is most recent and recommended https://github.com/clojure-emacs/cider-nrepl
@daveliepmann 0.2.13 is the tools.nrepl version 🙂
overloaded names are always a delight
thanks for the clarification
@qqq file a ticket and put there our conversation highlights. Then everything is possible.
@lockdown- only if you cider-connect
Indeed. CIDER simply needs some nREPL server to connect to. It doesn’t care how exactly it was started. Not sure how you can start a server with clj
, though - I though it just starts a REPL with all deps you specific.
I'm working out some kinks in tools.deps.alpha stopping us from using clj
for an internalish project (the JUXT website)
https://github.com/mrroman/devtools/ this works too
Once clj adds support for a command line edn file https://dev.clojure.org/jira/browse/TDEPS-19 you can probably have a jack in like clj -G'{:extra-deps {cider-nrepl {}}}' -m cider.main cider.nrepl/middleware …