clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.52k stars 643 forks source link

Allow inspecting a class that is used as a ^TypeTag #3679

Open alexander-yakushev opened 1 month ago

alexander-yakushev commented 1 month ago

Quite often I want to inspect a class that is written with ^ in the source file. To inspect it with the regular inspect-last-expr, I have to remove the ^ first. I noticed that C-c C-d C-d handles type tags fine. Can we have something like that for the inspector too?

This can be handled on the orchard.inspect side but I don't think it's the best place to do that.

vemv commented 1 month ago

Interesting

What's the current behavior if you don't manually remove ^?

What's C-c C-d C-d?

alexander-yakushev commented 1 month ago

C-c C-d C-d is cider-doc. The current behavior for cider-inspect is to read and inspect the next form after the type tag

vemv commented 1 month ago

I'd say that this would be a harmless/DWIM 'breaking' change to do - I'd fail to imagine people intentionally hovering over T in ^T x and expecting the inspector to go over x.

Most likely it's a byproduct of whatever the original impl was

alexander-yakushev commented 1 month ago

I also think so.Most of the code type hints local variables anyway which can't be inspected.

alexander-yakushev commented 1 month ago

I've fixed this for myself using this hack:

(defun cider-inspect-last-sexp ()
  (interactive)
  (if-let (type-tag (cider-symbol-at-point))
    (cider-inspect-expr type-tag (cider-current-ns))
    (cider-inspect-expr (cider-last-sexp) (cider-current-ns))))

I check if (cider-symbol-at-point) returns something meaningful. If so, I inspect that, otherwise I inspect (cider-last-sexp). cider-symbol-at-point is what cider-doc uses to strip ^ symbol from the classname.

But I'm not so sure if I'm comfortable pushing this to other people, and I don't know all implications yet.