Hi Nate,
What do you mean by passing "the right argument". Which argument do you want to pass?
At first, I thought the direct way to fix your function would be
(defun njn-subheading-respect-content ()
(interactive "")
(org-next-visible-heading 1)
(org-insert-heading nil)
)
because in your original example, the heading did already have a child.
However, that is not guaranteed, and in the above implementation, the
new heading is created with the level of the next headline, and that
next headline might be a sibling, a child or a parent. So we need to
explicitly set the level:
(defun njn-subheading-respect-content ()
(interactive "")
(let ((level (car (org-heading-components))))
(org-next-visible-heading 1)
(org-insert-heading nil)
(while (<= (car (org-heading-components)) level)
(org-demote))))
I am using (possibly repeated) calls to `org-demote', because this will
do everything correct, also with stuff like org-odd-levels only etc.
Hope this helps.
- Carsten