An Application of let-alist

Since Emacs 25.1, Artur Malabarba’s excellent let-alist macro has been a built-in feature of Emacs. As the name suggests, it’s a way of dealing with alists. The idea is that instead of writing a series of assq and cdr statements, you just write .tag where tag is the car of an alist element. Malabarba’s post gives an example of its use.

There’s a nice example of its use by T. V. Raman in a post about parsing the result of a json-read. Most of the examples I’ve seen use json-read to produce the alist, but the macro can, of course, be used with any alist. It can even handle nested alists as both Malabarba’s and Raman’s examples make clear.

This entry was posted in General and tagged . Bookmark the permalink.
  • Handling the output of json APIs is pretty much the main purpose of let-alist. It was born as part of SX.el development, and it's something I still use now even in my workplace APIs.