org-insert-subheading: Never insert sub-heading above current

* lisp/org.el (org-insert-subheading): When at bol, do not insert
heading above (default behavior of `org-insert-heading').  Instead,
force `org-insert-heading' to insert below.  Improve docstring,
explaining how the prefix arguments are used and the new different
with `org-insert-heading'.
* etc/ORG-NEWS (~org-insert-subheading~ no longer inserts a
sub-heading above current when point is at the beginning of line):
Document the breaking change.

Reported-by: Michael Dauer <mick.dauer@gmail.com>
Link: https://list.orgmode.org/CAP7OBx+whiB8Jo_hEcfL6MajDU1EH=E5j0ZOvHB3dPRK+Aj4mQ@mail.gmail.com/
This commit is contained in:
Ihor Radchenko 2024-02-10 16:57:59 +01:00
parent 9ddfb66996
commit cbfe1354b3
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 26 additions and 1 deletions

View File

@ -13,6 +13,27 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** ~org-insert-subheading~ no longer inserts a sub-heading above current when point is at the beginning of line
Previously, calling ~org-insert-subheading~ on
: * Heading 1
: <point>* Heading 2
yielded
: * Heading 1
: ** <point>
: * Heading 2
This is no longer the case. The sub-heading is always created below
current heading (prefix arguments have the same meaning as in
~org-insert-heading~):
: * Heading 1
: * Heading 2
: ** <point>
*** Org mode now fontifies whole table lines (including newline) according to ~org-table~ face
Previously, leading indentation and trailing newline in table rows

View File

@ -6633,8 +6633,12 @@ unchecked check box."
(defun org-insert-subheading (arg)
"Insert a new subheading and demote it.
Works for outline headings and for plain lists alike."
Works for outline headings and for plain lists alike.
The prefix argument ARG is passed to `org-insert-heading'.
Unlike `org-insert-heading', when point is at the beginning of a
heading, still insert the new sub-heading below."
(interactive "P")
(when (bolp) (forward-char))
(org-insert-heading arg)
(cond
((org-at-heading-p) (org-do-demote))