Álvaro Ramírez is back with a new video in his Bending Emacs series. This time it’s about the super useful and flexible completing read function. The basic idea is that you supply a prompt and a list of possible answers. The user can scroll to select an answer or use fuzzy matching to pick the desired option.
There are, of course, various flags to fine tune its behavior. The most useful is probably a flag to insist that the option be from the list rather than anything the user wants to enter. To me, one of the nicest things about completing-read function is that it can—almost magically—automatically adjust to whatever framework you’re using. Ramírez and I both use the Ivy framework, which provides an nicer interface to the function. There are other frameworks as well and the completing-read function automatically adapts to the one in use. Ramírez demonstrates this by turning off Ivy and completing-read falls back to its default behavior. This is especially nice when you’re developing an application because you can just write to the default and Emacs will automatically adjust to whatever framework is active.
Ramírez covers all this and shows several applications of completing read that he uses on his system. He even shows how to use it for command line utilities.
I use completing-read all the time in my own development and can’t recommend it enough. The list of choices can be calculated on the fly so it’s very flexible and doesn’t depend on your knowing what the choices are in advance. If you aren’t already using it, give it a try.
The video is 17 minutes, 4 seconds long so plan accordingly.