-
-
Notifications
You must be signed in to change notification settings - Fork 649
Debug on exception #3337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug on exception #3337
Conversation
@yuhan0 I guess you'll take this from here, right? |
How do you feel about this proposal of overloading cider-eval-defun with a negative argument? ;; * Insert #break / #dbg reader forms
(defun +cider-insert-dbg (ex)
"Insert #dbg reader.
If EX is non nil or called with prefix arg, insert #dbg! to break on exception.
Automatically reevaluates form if inside a defn."
(interactive "P")
(unless (looking-at-p "(")
(backward-up-list))
(cider-insert-fragile-reader-macro
(if ex "#dbg!"
(concat "#dbg"
(let ((cond (cider-read-from-minibuffer "Condition: ")))
(unless (equal "" cond)
(format " ^{:break/when %s}" cond))))))
(when (clojure-top-level-form-p "defn")
(cider-eval-defun-at-point)))
(defun +cider-insert-breakpoint (ex)
"Insert #break reader.
If EX is non nil or called with prefix arg, insert #break! to break on exception."
(interactive "P")
(cider-insert-fragile-reader-macro
(if ex "#break!"
(concat "#break"
(let ((cond (cider-read-from-minibuffer "Condition: ")))
(unless (equal "" cond)
(format " ^{:break/when %s}" cond)))))))
|
A quick demo of what that looks like in practice |
I'm not a big fan of prefix arguments in general, but from time to time they fit in nicely. Definitely not a big fan of the negative argument, as it's probably the hardest to discover organically by users. I'm ok with adding some special commands and I guess we can have something with prefix arguments as well, for whoever prefers them, given that it adds little complexity. The demo looks good to me. |
@yuhan0 Any chance you'll have time for this soon? I think it's the only feature remaining for the next CIDER release. |
Yes, I have the working code for this feature but unfortunately don't have much time over the next couple of days to work on testing / refining it into a PR. If it's a blocker for a release maybe I'll push those commits now and see if anyone can take it from there? Might be able to do something over the weekend too. |
Add support on the cider side to go with clojure-emacs/cider-nrepl#769
passing a negative argument to
cider-eval-defun-at-point
will instrument it with #dbgexnalso added some documentation to the debugger docs describing the new feature
Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):
eldev test
)eldev lint
) which is based onelisp-lint
and includescheckdoc
, check-declare, packaging metadata, indentation, and trailing whitespace checks.Thanks!
If you're just starting out to hack on CIDER you might find this section of its
manual extremely useful.