mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 20:07:46 +00:00
Fix: Prevent spurious newlines when inserting a new heading
* lisp/org.el (org-insert-heading): Do not insert spurious newline characters when inserting a headline. * testing/lisp/test-org.el (test-org/insert-heading): Add tests. Reported-by: Kyle Sherman <kylewsherman@gmail.com> <http://permalink.gmane.org/gmane.emacs.orgmode/112205>
This commit is contained in:
parent
82c3039ce4
commit
542890cd3f
|
@ -7855,13 +7855,12 @@ unconditionally."
|
|||
(when blank? (insert "\n"))
|
||||
(insert "\n" stars " ")
|
||||
(when (org-string-nw-p split) (insert split))
|
||||
(insert "\n")
|
||||
(forward-char -1)))
|
||||
(when (eobp) (save-excursion (insert "\n")))))
|
||||
(t
|
||||
(end-of-line)
|
||||
(when blank? (insert "\n"))
|
||||
(insert "\n" stars " \n")
|
||||
(forward-char -1))))
|
||||
(insert "\n" stars " ")
|
||||
(when (eobp) (save-excursion (insert "\n"))))))
|
||||
;; On regular text, turn line into a headline or split, if
|
||||
;; appropriate.
|
||||
((bolp)
|
||||
|
|
|
@ -1331,6 +1331,16 @@
|
|||
(should
|
||||
(equal "* \n* \n"
|
||||
(org-test-with-temp-text "* <point>"
|
||||
(org-insert-heading)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(org-test-with-temp-text "* <point>\n"
|
||||
(org-insert-heading)
|
||||
(looking-at-p "\n\\'")))
|
||||
;; Do not insert spurious headlines when inserting a new headline.
|
||||
(should
|
||||
(equal "* H1\n* H2\n* \n"
|
||||
(org-test-with-temp-text "* H1\n* H2<point>\n"
|
||||
(org-insert-heading)
|
||||
(buffer-string)))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue