cider icon indicating copy to clipboard operation
cider copied to clipboard

Allow inspecting a class that is used as a ^TypeTag

Open alexander-yakushev opened this issue 1 year ago • 6 comments

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.

alexander-yakushev avatar May 24 '24 15:05 alexander-yakushev

Interesting

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

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

vemv avatar May 24 '24 15:05 vemv

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

alexander-yakushev avatar May 24 '24 15:05 alexander-yakushev

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

vemv avatar May 24 '24 15:05 vemv

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

alexander-yakushev avatar May 24 '24 19:05 alexander-yakushev

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.

alexander-yakushev avatar Jun 02 '24 10:06 alexander-yakushev

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed soon if no further activity occurs. Thank you for your contribution and understanding!

github-actions[bot] avatar Jan 20 '25 02:01 github-actions[bot]