mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 20:37:51 +00:00
org: Fix functionality of org-insert-heading
* lisp/org.el (org-insert-heading): Fix insertion of headings when point is before any heading in the case of "respect content" insertion. Kudos to Victor Stoichita. https://orgmode.org/list/87lf4594t3.fsf@svictor.net/
This commit is contained in:
parent
b02f1eae19
commit
069bcba529
|
@ -7039,7 +7039,9 @@ unconditionally."
|
|||
(org-before-first-heading-p)))
|
||||
(insert "\n")
|
||||
(backward-char))
|
||||
(unless level (backward-char))
|
||||
(when (and (not level) (not (eobp)) (not (bobp)))
|
||||
(when (org-at-heading-p) (insert "\n"))
|
||||
(backward-char))
|
||||
(unless (and blank? (org-previous-line-empty-p))
|
||||
(org-N-empty-lines-before-current (if blank? 1 0)))
|
||||
(insert stars " ")
|
||||
|
|
|
@ -1602,6 +1602,21 @@
|
|||
;; When called with one universal argument, insert a new headline at
|
||||
;; the end of the current subtree, independently on the position of
|
||||
;; point.
|
||||
(should
|
||||
(equal
|
||||
"* "
|
||||
(org-test-with-temp-text ""
|
||||
(let ((org-insert-heading-respect-content nil))
|
||||
(org-insert-heading '(4)))
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal
|
||||
"entry
|
||||
* "
|
||||
(org-test-with-temp-text "entry"
|
||||
(let ((org-insert-heading-respect-content nil))
|
||||
(org-insert-heading '(4)))
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal
|
||||
"* H1\n** H2\n* "
|
||||
|
|
Loading…
Reference in a new issue