I wanted to display a list of strings in the emacs completing-read style, which displays a list of completion strings in a nicely aligned multi-column display. But I could not find an easy answer or example on the web.
For example, tracing the source of describe-function
I ended up in C code. (I used ESC-x describe-function "table-" TAB TAB
to show a multi-column display.
I came across this SO posting on align-regexp, which was useful, but it only spoke about keyboard macros. I needed an elisp function for use in code.
In the end I wrote my own function to do the job, after hours spent learning about align-regexp and doing experiments with various args. It always feels like I took too much time to learn something so simple, when I look at the final code. Anyhow, I post my answer here in case someone else can use it one day.
The problem I want to solve is to take a 1-column list of strings in a buffer, like this:
one
two
one
three
four
three
five
xix
boxy
and turn it into 2 or more aligned columns like this
one two
one three
four three
five xix
boxy
or this
one two one
three four three
five xix boxy
It would be nice to space out the columns to fill the buffer width better, but that's a separate problem.