-
-
Notifications
You must be signed in to change notification settings - Fork 54
[inspect] Add support for printing compact qualified keywords #354
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
base: master
Are you sure you want to change the base?
Conversation
9f0884f
to
57cb7ef
Compare
57cb7ef
to
3e2d15b
Compare
(if-some [matched-alias (some (fn [[alias ns]] | ||
(when (= kw-ns (name (ns-name ns))) | ||
alias)) | ||
(ns-aliases *pov-ns*))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stuff is O(N) from the number of namespace aliases in the POV-ns, so it banks on the assumption that people don't alias hundreds of namespaces. I think it is good enough for now, can improve later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that's fine. Perhaps you can leave this in the code as a comment for future reference.
@@ -52,6 +52,13 @@ | |||
"When displaying collection diffs, whether to hide matching values." | |||
false) | |||
|
|||
(def ^:dynamic *pov-ns* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe mention in the docstring that pov stands for "point-of-view", so people don't wonder about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement!
Isn't this conceptually similar to the notion of 'tidy' output from the macroexpand middleware? https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/macroexpand.clj I haven't looked into it closely, but this might be a good opportunity to extract some common logic or at least compare the impls for semantic alignment - eg whether keywords and symbols should be handled differently and how |
Good point, I should take a look if something can be reused between the two. |
This is an idea to address clojure-emacs/cider#3841. I think most of the time when people use long qualified keywords, it happens when using shortened syntax
::foo
or::alias/foo
. The proposed feature tries to reconstruct the shortened syntax by providing a config paramter:pov-ns
(Point-of-View namespace) from where the inspection is initiated. Example, inspecting thisYields this: