debug-repl icon indicating copy to clipboard operation
debug-repl copied to clipboard

Made debugging available globally, without a need to require in every namespace

Open alesya-h opened this issue 8 years ago • 8 comments

It is really inconvenient having to require com.gfredericks.debug-repl in every namespace while you debugging, especially given usually one has debug-repl in their user profile, not in a project definition, so having that requires permanently in every namespace in most cases won't work.

This patch adds break!, unbreak!, unbreak!! and catch-break! to clojure.core before nrepl middleware is installed.

I chose immediate global installation rather then on-demand global installation because functions/macros will be available only to namespaces that are defined afterward unless those namespaces are manually reloaded (or unless you call (use 'clojure.core :reload) when in that namespace).

It doesn't modify any existing functions in clojure.core, only adds new ones, so it should be safe. Given debug-repl is a development tool I think it's ok to tinker with internals a little when it will lead to better development experience.

alesya-h avatar Nov 10 '17 05:11 alesya-h

This looks useful, but I don't think a library should force this on the user.

I personally solve this problem by using lein-shorthand (not just for debug-repl, but for all sorts of other utilities I want globally accessible as well), but you could also put something similar to the code in this PR in your :injections section of your user profile.

If you think it would help, I wouldn't mind a section of the README that shows users how to do that.

gfredericks avatar Nov 10 '17 12:11 gfredericks

For data, I solve this in a curious way in combination with vim.

I have a custom command LoadDebugger which does (require 'com.gfredericks.debug-repl.http-intercept 'com.gfredericks.debug-repl).

This then has the namespace loaded.

Then I have abbreviations like break! which expand to (com.gfredericks.debug-repl.http-intercept/break!).

SevereOverfl0w avatar Mar 27 '18 20:03 SevereOverfl0w

now I'm curious what the .http-intercept namespace is, since it's not part of debug-repl :)

gfredericks avatar Mar 28 '18 21:03 gfredericks

You may recall writing a ring thing a while back for someone, that was me.

I have been meaning to contribute it back sometime soon.

On March 28, 2018 10:46:16 PM GMT+01:00, Gary Fredericks [email protected] wrote:

now I'm curious what the .http-intercept namespace is, since it's not part of debug-repl :)

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/gfredericks/debug-repl/pull/6#issuecomment-377048092

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

SevereOverfl0w avatar Mar 28 '18 23:03 SevereOverfl0w

I don't! It sounds interesting :smile:

gfredericks avatar Mar 29 '18 00:03 gfredericks

https://github.com/gfredericks/debug-repl/tree/http-intercept here it is. I still actively use this. (anything I have on top is pushed up: https://github.com/SevereOverfl0w/debug-repl/tree/http-intercept)

SevereOverfl0w avatar Mar 30 '18 13:03 SevereOverfl0w

wow; that's an amazing amount of code for me to have no memory of writing

gfredericks avatar Mar 30 '18 14:03 gfredericks

Personally I solve this problem via ~/.lein/profiles.clj:

{:repl-options {:init (do (require 'com.gfredericks.debug-repl) ...

Requiring the namespace just once suffices to have the code loaded in any user namespace - whether it had a :require com.gfredericks.debug-repl or not.

Then I use snippets, just like @SevereOverfl0w:

I have abbreviations like break! which expand to (com.gfredericks.debug-repl.http-intercept/break!).

vemv avatar May 14 '19 08:05 vemv