Skip to content

Conversation

alexander-yakushev
Copy link
Member

@alexander-yakushev alexander-yakushev commented Sep 11, 2025

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 this

Screenshot 2025-09-11 at 21 16 08

Yields this:

Screenshot 2025-09-11 at 21 16 20
  • You've added tests to cover your change(s)
  • You've updated the changelog (if adding/changing user-visible functionality)

Copilot

This comment was marked as resolved.

@clojure-emacs clojure-emacs deleted a comment from Copilot AI Sep 11, 2025
@clojure-emacs clojure-emacs deleted a comment from Copilot AI Sep 11, 2025
Comment on lines +129 to +132
(if-some [matched-alias (some (fn [[alias ns]]
(when (= kw-ns (name (ns-name ns)))
alias))
(ns-aliases *pov-ns*))]
Copy link
Member Author

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.

Copy link
Member

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*
Copy link
Member

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?

Copy link
Member

@bbatsov bbatsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement!

@yuhan0
Copy link
Contributor

yuhan0 commented Sep 12, 2025

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

@alexander-yakushev
Copy link
Member Author

Good point, I should take a look if something can be reused between the two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants