I have been trying during my free time to create a small Emacs package to automatically display the type of the element under the point after a small delay. You move the cursor on a word, wait 0.5s and it will do the same thing as M-x merlin-type-enclosing
. The package is of coursed based on merlin.
This is inspired by what exist in the emacs-lisp mode (which displays information about the value at point in the message box), tide (which displays the type under the point) and what exist in other editors.
The result is here https://github.com/Khady/merlin-auto-hl/blob/master/merlin-auto-hl.el
This is not very clean or nice. But it covers basic usage (I think). And I am now seeking for help.
What is necessary to make it really usable:
- Make it a real mode. I don’t know how to do that exactly. I mostly copy/pasted this part, so it needs a refresh.
- Stop the auto display when an action is going on. For example if the cursor is moved in a string, then execute
C-h k RET C-c C-t
, the help for the keybinding is not displayed. The action is interrupted. - Publish on melpa or something like this.
Nice improvements that I would like to have:
- Highlight of all occurrences. The position of all occurrences can be taken from
merlin-occurrences
so it shouldn’t be too hard to too. But I don’t know yet how to handle highlighting of multiple values and how to remove the highlight later. I think I need to import more pieces frommerlin--type-enclosing-after
. - Cleanup the code to follow good emacs lisp practices.
If you know some emacs lisp and can give advice or if you can contribute a patch, it would be very cool.
The name of the package is not definitive. Ideas are welcomed for this too.
I hope this presentation is clear enough. Not a native english speaker. Please ask any question is something needs more details.
Some links related to this work:
- https://github.com/ocaml/merlin/issues/796
- https://github.com/ananthakumaran/tide/blob/master/tide.el#L1991-L2096
- https://github.com/ocaml/merlin/issues/500
- https://github.com/infinity0/l33tutils/blob/master/devel/emacs/site-lisp/merlin-extra.el
- https://github.com/fsharp/emacs-fsharp-mode/blob/master/fsharp-doc.el