Custom Functions In Org Tables

Most Org users know that there are built in functions that can do things like sum some or all of the entries in a row or column of a table. The set of functions is actually much richer than simply adding up a column’s entries. It can, in fact, be any algebraic expression understood by Emacs Calc

But wait, there’s more. If you need something not covered by the builtin functions, you can define your own. It’s actually pretty simple and worth being aware of.

525G7bKV over at the Emacs subreddit has a short post that shows how to do it. The function part is an ordinary Elisp function that can make pretty much any calculation you need. That part shouldn’t present any problem to those familiar with Elisp.

The trickier—but not by much—part is specifying how to call the function in the table’s TBLFM line. Specifying what cells to use is done as usual and the function to call is placed in a '(...) construct. Check out 525G7bKV’s post and the documentation for the details.

Given the richness of operations accepted by Calc, you wouldn’t think you’d need a custom function but it comes up occasionally for me. It is, in any event, worth knowing that the capability exists in case the need arises.

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