Le 13 Sep 2021, Marco Wahl <marcowahls...@gmail.com> a écrit :
> As far is I see it, the intended behavior of > org-insert-heading-respect-content with point before the first heading > is to > > - insert the new heading immediately before the first heading. Respect > the content! Hi Marco ! I agree with you. But this does not work. Say I have a buffer with this content : --8<---------------cut here---------------start------------->8--- put point HERE and C-<return> Some more stuff * Heading content --8<---------------cut here---------------end--------------->8--- When point is at HERE and I C-<return>, org inserts a new asterisk on the after "stuff", but on the same line → not a proper heading. > > - If there is no heading at all in the file the heading shall be > inserted at the bottom of the file. Yes. But I get the same behavior with --8<---------------cut here---------------start------------->8--- put point HERE and C-<return> Some more stuff --8<---------------cut here---------------end--------------->8--- The asterisk is inserted right after "stuff", on the same line → not a proper heading. > > Do we agree on the desired behavior of > org-insert-heading-respect-content? Yes, we do! > > With your proposition the respect for the content gets lost, > doesn't it? Yes, you’re right. It currently does not respect the content before first heading. Therefore it’s not a fix for the behavior of org-insert-heading-respect-content. It’s just the quickest workaround I’ve come up with to make my own function work (in my use-case, when I call that function, either point is at point-min in a brand new buffer, or point is below the first heading). Regards, Victor