Writing a format-like Function

Marcin Borkowski (mbork) has an interesting post on something I didn’t know about. He needed to write his own format-like function, presumably with %-tags not defined by the format function. It’s not too hard to write something like that but he asked about it on the Emacs help mailing list and got pointed to format-spec. That was just what he needed.

All the values are ultimately printed by princ so you can use it to print just about any Elisp object. You probably aren’t going to have a lot of use for format-spec but when you do need it, it’s just what you want. As Borkowski notes, you can use format-spec-make to help build the value list. I found the documentation for the two functions a bit ambiguous but the code is short and easy to read and resolved the questions I had about the functions.

This entry was posted in General and tagged . Bookmark the permalink.