Last month, Ben Maughan wrote a very nice post on how to insert internal Org links. The problem he was solving was that he wants to insert an internal link to one of the headers in his Org file. That’s not very hard to do manually, of course, but when you do it a lot or you have a long document, a little automation can remove a lot of friction.
You can follow the link to see how he solved the problem but I want to emphasize how he leveraged the excellent Ivy library to accomplish his task. First he accumulates a list of the headings using the Worf package. Then he calls
ivy-read (a completing read) with that list so that he can choose one of them. A nice feature of
ivy-read is that you can specify an action for the selection. In his case he calls a function to grab the link and insert it at point.
The whole thing is just a few lines of code and is an excellent example of the power of Ivy. Take a look at his post and see how easy it is. The more I use Ivy, the more I like it, both for the built-in Ivy functions, such as Swiper, and the Ivy library functions for writing my own Elisp. I’ll say it again, the Ivy/Counsel/Swiper suite is the most useful set of packages I use.