Fork me on GitHub
#cider
<
2020-04-09
>
bozhidar07:04:38

@mitchell_clojure I think @qythium had some version of eval-in-context which would infer the local bindings.

bozhidar07:04:57

There’s nothing built-in in CIDER yet.

Mitch13:04:51

cool, thanks all. Might be a good way to learn elisp

yuhan15:04:28

@mitchell_clojure Hey I just saw the mention, here's my custom fn:

(defun cider--guess-evaluation-context ()
  "returns list of let-binding strings from the inside out, without closing parens
     \"(let [...]\""
  (save-excursion
    (let ((res ()))
      (condition-case er
          (while t
            (backward-up-list)
            (when (looking-at (rx "(" (or "when-let" "if-let" "let") (opt "*")
                                  symbol-end (* space)
                                  (group "["))) ;; binding vector
              (let ((beg (match-beginning 0))
                    (end (save-excursion
                           (goto-char (match-beginning 1))
                           (forward-sexp 1)
                           (point))))
                (push (buffer-substring-no-properties beg end) res))))
        (scan-error res)))))

(defun cider-eval-dwim ()
  (interactive)
  (let ((ctx (cider--guess-evaluation-context))
        (bounds (cider-sexp-at-point 'bounds)))
    (cider-interactive-eval (concat (apply #'concat ctx)
                                    (buffer-substring-no-properties (car bounds) (cadr bounds))
                                    (make-string (length ctx) ?\)))
                            nil bounds
                            (cider--nrepl-pr-request-map))))

yuhan15:04:14

cider-eval-dwim is the interactive command, bind it to something convenient and it'll automatically splice the form you're evaluating with all its enclosing let forms

yuhan15:04:40

it's still in a somewhat rough state, I'll use it myself for a while more before deciding whether to contribute it upstream (maybe as part of cider-eval-in-context)

Mitch15:04:11

woah, sick! thank you very much. I'll incorporate this in my workflow and let you know if I come up with any interesting tweaks

bozhidar17:04:36

That’s a pretty cool news - our sibling project Calva has implemented cider-nrepl’s debugger https://clojureverse.org/t/calva-gets-a-debugger/5751 Now we know for sure that CIDER’s debugger is editor agnostic! 😄

cider 16
pez18:04:34

Calva is distilled from cider, as all civilized people know. 😎

cider 8
calva 16
didibus18:04:41

What's the recommended way to have all the necessary cider deps in a REPL when the REPL is started remotely or outside cider?

didibus18:04:56

I always struggle to find all the right combo of packages and versions

didibus18:04:21

To match the version of Cider I also use

pez18:04:40

Jack in to a similar project and see what cider injects.

didibus18:04:07

Ya, but that's annoying 😛

didibus18:04:52

I have to jack in to some local project, see what it injects, it injects multiple things,then I have to modify my project.clj with all of it, and I have to keep up with this as I update cider

Mitch18:04:42

Is this the usecase for nrepl's sideloading feature?

didibus18:04:29

Ouuu! Hope so! I think it might, you'd just depend on nrepl and everything else can be side loaded

bozhidar18:04:32

@didibus Yeah, that’s the plan. Haven’t had time to implement support for the sideloader in CIDER, though.

bozhidar18:04:59

Generally, CIDER works even without cider-nrepl, at least the core functionality works.