Skip to content

[inspect] Add support for printing compact qualified keywords#354

Merged
alexander-yakushev merged 2 commits into
masterfrom
inspect-ns-kws
Sep 19, 2025
Merged

[inspect] Add support for printing compact qualified keywords#354
alexander-yakushev merged 2 commits into
masterfrom
inspect-ns-kws

Conversation

@alexander-yakushev
Copy link
Copy Markdown
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)

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 thread src/orchard/print.clj
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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/orchard/print.clj
"When displaying collection diffs, whether to hide matching values."
false)

(def ^:dynamic *pov-ns*
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

@alexander-yakushev
Copy link
Copy Markdown
Member Author

Looks like they are far enough after all. I will try to reconcile them some other day.

@alexander-yakushev alexander-yakushev merged commit c6e12a4 into master Sep 19, 2025
18 checks passed
@alexander-yakushev alexander-yakushev deleted the inspect-ns-kws branch September 19, 2025 07:31
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.

4 participants