emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: behavior of (org-insert-heading-respect-content)


From: Marco Wahl
Subject: Re: behavior of (org-insert-heading-respect-content)
Date: Mon, 13 Sep 2021 21:21:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Victor,

> Le 09 Sep 2021, Marco Wahl <marcowahlsoft@gmail.com> a écrit :
>
>> My impression is that org-insert-heading-respect-content should be
>> called only with point in a subtree.
>>
>> The fix would be to signal an error when point is not located in a
>> subtree.
>>
>> Does this sound reasonable?
>
> In a way, yes. I guess that the error would not appear too often.
> But falling back gracefully to org-insert-heading could be even
> better, especially when org-insert-heading-respect-content is called
> from Lisp (rather than interactively).
>
> For now, I use this and it seems to do the job:
>
> #+begin_src elisp
>   (if (equal 1 (line-number-at-pos nil t))
>         (org-insert-heading)
>       (org-insert-heading-respect-content))
> #+end_src
>
> If I’m not mistaken, org-insert-heading-respect-content works as
> expected even when point is not in a subtree. It seems to only fail if
> point is on the 1st line.

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!

- If there is no heading at all in the file the heading shall be
  inserted at the bottom of the file.

Do we agree on the desired behavior of
org-insert-heading-respect-content?

With your proposition the respect for the content gets lost, doesn't it?


Ciao!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]