This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-12
Channels
- # beginners (47)
- # boot (5)
- # bristol-clojurians (1)
- # cider (45)
- # clara (2)
- # cljs-dev (11)
- # cljsrn (47)
- # clojure (169)
- # clojure-brasil (2)
- # clojure-dusseldorf (22)
- # clojure-finland (1)
- # clojure-italy (9)
- # clojure-nl (3)
- # clojure-poland (2)
- # clojure-russia (4)
- # clojure-spec (79)
- # clojure-uk (105)
- # clojurescript (59)
- # core-async (41)
- # cursive (31)
- # datomic (10)
- # devcards (1)
- # duct (6)
- # editors (9)
- # emacs (12)
- # figwheel (1)
- # fulcro (50)
- # java (4)
- # mount (1)
- # off-topic (47)
- # onyx (33)
- # pedestal (1)
- # protorepl (1)
- # re-frame (32)
- # reagent (45)
- # ring-swagger (6)
- # shadow-cljs (100)
- # tools-deps (6)
- # uncomplicate (27)
- # vim (3)
ah brilliant didn't know about the ,
trick @dpsutton
Am I the only one occasionally capturing a value in the REPL? Did someone make emacs helpers for this? (I am aware of https://github.com/vvvvalvalval/scope-capture btw, not really what I am after) In other words, how do I go from:
(defn test-fn [a b]
(let [c [a b]]
;; <- cursor there
[(+ a b) c]))
to
(defn test-fn [a b]
(let [c [a b]]
(def a a)
(def b b)
(def c c)
[(+ a b) c]))
Using a bit of elisp?
I could type for instance “my-emacs-def-insert-cmd”
“a” ENTER “b” ENTER “c” ENTER ENTER
and have this generated? That would be a welcome addition to my particular workflow.
Anyone doing this?@nha I think @dpsutton has something like that and I probably have the same. Not at the keyboard now, will check and write later.
(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 in the debugger, get to a stack frame that includes the vars you want to capture. then invoke this function. it grabs the local state from the debugger and formats them into a let bindingwith a region, it will capture that region as the body of the let and the locals in your debugger state as the let bindings above it
Oh I see. Interesting, I don’t use the debugger though (I probably should, although I am quite sure some of our params are too big for it)
I suspect what I am after is simpler (ie. does not require any of cider’s functionality) - but my elisp is still fairly weak