Hi Bastien,
Just to follow up on the error, reverting commit 0ca4092 fixes the bug that I mentioned in my last email and reverting the fourth hunk of commit b8c85a1 should fix the bug that you tried to fix with that commit. Carsten had added an 'unless (bolp)' condition to the function that
controls inserting new lines outside of headlines to avoid deleting
whitespace. However, so far as I can tell, the other measures Carsten
put in place with that commit made adding this condition unnecessary. Outside of the
contexts where it produces the first bug I mentioned it does not seem to
affect headline insertion behaviour.
Anyway, reverting those commits should get headline insertion to work as advertised.