Understanding emacs / light table "display of type data, and annotation snippets" features

29 views
Skip to first unread message

Laurent PETIT

unread,
Dec 28, 2014, 6:04:36 PM12/28/14
to clojure-core-typed
Hello,

I'd like some help from emacs / light table users which have installed the corresponding core-typed plugins.

While I think I easily understand the "namespace typechecking" and "error navigation" features they provide, I'm not sure I correctly understand the next two:

"display of type data":
- I don't understand which user command triggers a call to core-typed which would then gather the data (I guess it's maybe via the :file-mapping option of check-ns-info, but am not totally certain).
- I don't understand how the type data is visually presented to the user inside the editor. If someone could help me save time by explaining how this works in their editor and even better, take a screenshot, I would be grateful (maybe this could even be something added to the relevant projects README pages).

"annotation snippets":
- I'm not sure I understand what it does. It looks like magic to me, I don't understand if it's just a command to quickly add an empty "(ann |)" on top of the current form, with the cursor placed at the right position (and maybe guessing that it should add e.g. "(t/ann |)" if typed.core is aliased to "t". Or if it does some more magic like calling some core.typed function that could infer as much as possible for the type signature?

Asking these questions because I am currently working on the Eclipse/Counterclockwise port of these features, and would like to learn from what's done in other editors as fast as possible, to be able to focus on coding instead of installing emacs, etc. ;-)

Thanks in advance,

--
Laurent Petit

Peter Fraenkel

unread,
Jan 8, 2015, 2:08:41 PM1/8/15
to clojure-c...@googlegroups.com
I'm in the process of adding type data display to my flycheck checker, and I'm in approximately the same position as you.  I believe the following to be true:
1. The emacs typed-clojure-mode doesn't display inferred types; it just checks for errors.
2. The vim plugin, which Ambrose wrote, indeed uses :file-mapping, producing a whole bunch of type strings and associated line/column position, which is then cached in vim memory for subsequent lookup.
3. What I remember from seeing the vim plugin in a talk is that the type was displayed in a line at the very bottom of the screen, analogous to the emacs minibuffer.
4. Turning on :file-mapping causes check-ns-info to take 5-10x longer to run, which is probably unacceptable for users hoping to be alerted of their mistakes, but...
5. You can run have multiple check-ns-info operations running simultaneously.  The only part of the operation that actually consumes CPU is the file-mapping, so you could just have checks with and without running at different duty cycles.  That's what I'm planning on doing, which, um, decomplects things a tad, as the type display won't rely on a side-effect of the error highlighting.

Re display: I'm initially planning on showing the type, exactly as reported in the string from the :file-mapping, in the minibuffer at the bottom of the screen, when keystroke is issued with the cursor over a symbol.  For ccw, it would seem more natural to do the standard eclipse thing and show a borderless, wheat-colored popup below and to the right of the symbol after a period of hovering.  I'll have that as an option, as I currently do for type errors (per the picture in the Squiggly Clojure README).  

Re annotation snippets: Personally, I don't see the point if you've got reasonable sexp handling already.
Reply all
Reply to author
Forward
0 new messages