Not a big deal, but here is a slightly better fix that avoids adding some spaces before the closing }. The difference wrt to the previous one is just: - (unless (memq (caar tbl) '(:endgroup :endgrouptag)) (insert "\n")) - (when (or ingroup intaggroup) (insert " ")) + (unless (memq (caar tbl) '(:endgroup :endgrouptag)) + (insert "\n") + (when (or ingroup intaggroup) (insert " "))) That is, the when clause is inside the unless clause.