Mickey Petersen has another great post up at Mastering Emacs. In the post, Mickey notes that Emacs 29 is going to have first class support for emoji. I don’t use emoji much so I don’t care but Mickey’s post was still very interesting to me because he shows how to implement essentially the same functionality using an input method.
Input methods are a way of temporarily switching to a specialized keyboard so that you can enter special symbols or diacritical marks. I use the TeX input method all the time when I’m writing blog posts and find it an easy and convenient way of dealing with LaTeX symbols in a non-TeX buffer. Until I read Mickey’s post, I didn’t know much about input methods other than that the TeX method allowed me to enter LaTeX commands.
It turns out that it’s easy to implement an input method as Mickey shows by using it to make a simple emoji mode. He implements only four emoji but it’s easy to add as many as you like. The TL;DR is that you use quail-define-package
to define the mode and quail-define-rules
to establish the mappings between the key sequences and the symbols you want to insert.
The method is more powerful than I’ve described as you can see by reading the documentation but it’s simple in the simple case and worth knowing about in case you have need of such a facility.