From cbfe1354b37f267f2e2526c28710f05a95fcac23 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 10 Feb 2024 16:57:59 +0100 Subject: [PATCH] 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 Link: https://list.orgmode.org/CAP7OBx+whiB8Jo_hEcfL6MajDU1EH=E5j0ZOvHB3dPRK+Aj4mQ@mail.gmail.com/ --- etc/ORG-NEWS | 21 +++++++++++++++++++++ lisp/org.el | 6 +++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 1d69d9b99..8e15d91b2 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -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 +: * Heading 2 + +yielded + +: * Heading 1 +: ** +: * 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 +: ** + *** Org mode now fontifies whole table lines (including newline) according to ~org-table~ face Previously, leading indentation and trailing newline in table rows diff --git a/lisp/org.el b/lisp/org.el index d09699388..911194797 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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))