emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marco Wahl <marcowahlsoft@gmail.com>
To: "Victor A. Stoichita" <victor@svictor.net>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: behavior of (org-insert-heading-respect-content)
Date: Mon, 13 Sep 2021 21:21:48 +0200	[thread overview]
Message-ID: <875yv4uvqr.fsf@gmail.com> (raw)
In-Reply-To: 87ilz98s5a.fsf@svictor.net

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	other threads:[~2021-09-13 19:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 14:55 behavior of (org-insert-heading-respect-content) Victor A. Stoichita
2021-09-09 18:54 ` Marco Wahl
2021-09-09 19:29   ` Victor A. Stoichita
2021-09-13 19:21     ` Marco Wahl [this message]
2021-09-17 15:23       ` Victor A. Stoichita
2021-09-18 13:08         ` Marco Wahl
2021-09-26 11:13           ` Bastien
2021-09-26 12:13             ` Marco Wahl
2021-09-26 12:31               ` Bastien
2021-09-26 19:57           ` Victor A. Stoichita

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yv4uvqr.fsf@gmail.com \
    --to=marcowahlsoft@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=victor@svictor.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).