Fork me on GitHub
#emacs
<
2017-11-15
>
hkjels19:11:23

is it possible to set a breakpoint and use a REPL with the context of that point?

dpsutton19:11:58

in cider there's a few options e Eval code in current context

dpsutton21:11:14

you're welcome! i'm glad that's working out for you

dpsutton21:11:20

give me one second, i've got a function you might like

dpsutton21:11:33

(defun cider-debug-create-local-let (start end)
  (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.")))

dpsutton21:11:52

while debugging, you can highlight code you want to inspect and this will form a let binding with all of the debugger locals

dpsutton22:11:46

so while stepping through, call this function with some text highlighted and then quit debugging. it grabs the locals from the debugger and formats a let statement with all of those locals bound to what they were in teh environment and the body of the let is the code you highlighted

hkjels22:11:13

Ahh, that’s perfect! thanks