Implementing a TeX-style unicode input method

Dear all,

for some programming languages like Ada and Coq it is very common to use unicode symbols such as Γ, α, etc…

Most users input these symbols using variants of emacs TeX-input-method, which is basically a method that will recognize \alpha and insert α, providing autocompletion whenever the user presses \.

I’d like to give this feature a go in CodeMirror, any particular advice?


[update: a first version of such an addon is at:]

You should be able to do this by listening to "inputRead" events and scanning backwards to see if there’s a matching backslash-name there, and then if there is, replacing it with the appropriate character.

Thanks @marijn, very interesting. I was thinking however of using hint/show-hint.js, do you think that is not possible?

Sorry if I wasn’t very clear before, (discuss ate my backslash), in TeX-input-method, when the user presses \, this has the effect of activating the TeX completion command, and if they enter a recognized symbol, it is then replaced.

You can see it in action here:

Thanks again!

Ah, sure, you can do that too.

Cool thanks! I’ll try the completion route then and see how it goes; from a quick scan the API should work well.

Ok, so I was able to hack something, it seems to work well. Would a PR make sense?

Something I couldn’t figure out was how to make this a general hint for all modes, now I do:

    CodeMirror.registerHelper("hint", "coq", TeX_input_hint);

but ideally we’d like this input completion to be available to any mode that wants it. In emacs we would achieve so by using a minor-mode.

Nope, I don’t want to further extend the scope of my distribution. But putting it on github and NPM so that others can use it would be a great idea.

ok thanks!

Just for reference to future readers, the code lives now at: