Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2019-02-15 22:47:53 +01:00
commit 7e98c5c4cc
2 changed files with 19 additions and 22 deletions

View File

@ -7543,7 +7543,6 @@ unconditionally."
(unless (and blank? (org-previous-line-empty-p)) (unless (and blank? (org-previous-line-empty-p))
(org-N-empty-lines-before-current (if blank? 1 0))) (org-N-empty-lines-before-current (if blank? 1 0)))
(insert stars " ") (insert stars " ")
(when (eobp) (save-excursion (insert "\n")))
;; When INVISIBLE-OK is non-nil, ensure newly created headline ;; When INVISIBLE-OK is non-nil, ensure newly created headline
;; is visible. ;; is visible.
(unless invisible-ok (unless invisible-ok
@ -7570,13 +7569,11 @@ unconditionally."
(end-of-line) (end-of-line)
(when blank? (insert "\n")) (when blank? (insert "\n"))
(insert "\n" stars " ") (insert "\n" stars " ")
(when (org-string-nw-p split) (insert split)) (when (org-string-nw-p split) (insert split))))
(when (eobp) (save-excursion (insert "\n")))))
(t (t
(end-of-line) (end-of-line)
(when blank? (insert "\n")) (when blank? (insert "\n"))
(insert "\n" stars " ") (insert "\n" stars " "))))
(when (eobp) (save-excursion (insert "\n"))))))
;; On regular text, turn line into a headline or split, if ;; On regular text, turn line into a headline or split, if
;; appropriate. ;; appropriate.
((bolp) ((bolp)

View File

@ -1267,13 +1267,13 @@
(buffer-string)))) (buffer-string))))
;; In the middle of a headline, split it if allowed. ;; In the middle of a headline, split it if allowed.
(should (should
(equal "* H\n* 1\n" (equal "* H\n* 1"
(org-test-with-temp-text "* H<point>1" (org-test-with-temp-text "* H<point>1"
(let ((org-M-RET-may-split-line '((headline . t)))) (let ((org-M-RET-may-split-line '((headline . t))))
(org-insert-heading)) (org-insert-heading))
(buffer-string)))) (buffer-string))))
(should (should
(equal "* H1\n* \n" (equal "* H1\n* "
(org-test-with-temp-text "* H<point>1" (org-test-with-temp-text "* H<point>1"
(let ((org-M-RET-may-split-line '((headline . nil)))) (let ((org-M-RET-may-split-line '((headline . nil))))
(org-insert-heading)) (org-insert-heading))
@ -1281,19 +1281,19 @@
;; However, splitting cannot happen on TODO keywords, priorities or ;; However, splitting cannot happen on TODO keywords, priorities or
;; tags. ;; tags.
(should (should
(equal "* TODO H1\n* \n" (equal "* TODO H1\n* "
(org-test-with-temp-text "* TO<point>DO H1" (org-test-with-temp-text "* TO<point>DO H1"
(let ((org-M-RET-may-split-line '((headline . t)))) (let ((org-M-RET-may-split-line '((headline . t))))
(org-insert-heading)) (org-insert-heading))
(buffer-string)))) (buffer-string))))
(should (should
(equal "* [#A] H1\n* \n" (equal "* [#A] H1\n* "
(org-test-with-temp-text "* [#<point>A] H1" (org-test-with-temp-text "* [#<point>A] H1"
(let ((org-M-RET-may-split-line '((headline . t)))) (let ((org-M-RET-may-split-line '((headline . t))))
(org-insert-heading)) (org-insert-heading))
(buffer-string)))) (buffer-string))))
(should (should
(equal "* H1 :tag:\n* \n" (equal "* H1 :tag:\n* "
(org-test-with-temp-text "* H1 :ta<point>g:" (org-test-with-temp-text "* H1 :ta<point>g:"
(let ((org-M-RET-may-split-line '((headline . t)))) (let ((org-M-RET-may-split-line '((headline . t))))
(org-insert-heading)) (org-insert-heading))
@ -1320,14 +1320,14 @@
;; point. ;; point.
(should (should
(equal (equal
"* H1\n** H2\n* \n" "* H1\n** H2\n* "
(org-test-with-temp-text "* H1\n** H2" (org-test-with-temp-text "* H1\n** H2"
(let ((org-insert-heading-respect-content nil)) (let ((org-insert-heading-respect-content nil))
(org-insert-heading '(4))) (org-insert-heading '(4)))
(buffer-string)))) (buffer-string))))
(should (should
(equal (equal
"* H1\n** H2\n* \n" "* H1\n** H2\n* "
(org-test-with-temp-text "* H<point>1\n** H2" (org-test-with-temp-text "* H<point>1\n** H2"
(let ((org-insert-heading-respect-content nil)) (let ((org-insert-heading-respect-content nil))
(org-insert-heading '(4))) (org-insert-heading '(4)))
@ -1335,7 +1335,7 @@
;; When called with two universal arguments, insert a new headline ;; When called with two universal arguments, insert a new headline
;; at the end of the grandparent subtree. ;; at the end of the grandparent subtree.
(should (should
(equal "* H1\n** H3\n- item\n** H2\n** \n" (equal "* H1\n** H3\n- item\n** H2\n** "
(org-test-with-temp-text "* H1\n** H3\n- item<point>\n** H2" (org-test-with-temp-text "* H1\n** H3\n- item<point>\n** H2"
(let ((org-insert-heading-respect-content nil)) (let ((org-insert-heading-respect-content nil))
(org-insert-heading '(16))) (org-insert-heading '(16)))
@ -1343,7 +1343,7 @@
;; When optional TOP-LEVEL argument is non-nil, always insert ;; When optional TOP-LEVEL argument is non-nil, always insert
;; a level 1 heading. ;; a level 1 heading.
(should (should
(equal "* H1\n** H2\n* \n" (equal "* H1\n** H2\n* "
(org-test-with-temp-text "* H1\n** H2<point>" (org-test-with-temp-text "* H1\n** H2<point>"
(org-insert-heading nil nil t) (org-insert-heading nil nil t)
(buffer-string)))) (buffer-string))))
@ -1354,32 +1354,32 @@
(buffer-string)))) (buffer-string))))
;; Obey `org-blank-before-new-entry'. ;; Obey `org-blank-before-new-entry'.
(should (should
(equal "* H1\n\n* \n" (equal "* H1\n\n* "
(org-test-with-temp-text "* H1<point>" (org-test-with-temp-text "* H1<point>"
(let ((org-blank-before-new-entry '((heading . t)))) (let ((org-blank-before-new-entry '((heading . t))))
(org-insert-heading)) (org-insert-heading))
(buffer-string)))) (buffer-string))))
(should (should
(equal "* H1\n* \n" (equal "* H1\n* "
(org-test-with-temp-text "* H1<point>" (org-test-with-temp-text "* H1<point>"
(let ((org-blank-before-new-entry '((heading . nil)))) (let ((org-blank-before-new-entry '((heading . nil))))
(org-insert-heading)) (org-insert-heading))
(buffer-string)))) (buffer-string))))
(should (should
(equal "* H1\n* H2\n* \n" (equal "* H1\n* H2\n* "
(org-test-with-temp-text "* H1\n* H2<point>" (org-test-with-temp-text "* H1\n* H2<point>"
(let ((org-blank-before-new-entry '((heading . auto)))) (let ((org-blank-before-new-entry '((heading . auto))))
(org-insert-heading)) (org-insert-heading))
(buffer-string)))) (buffer-string))))
(should (should
(equal "* H1\n\n* H2\n\n* \n" (equal "* H1\n\n* H2\n\n* "
(org-test-with-temp-text "* H1\n\n* H2<point>" (org-test-with-temp-text "* H1\n\n* H2<point>"
(let ((org-blank-before-new-entry '((heading . auto)))) (let ((org-blank-before-new-entry '((heading . auto))))
(org-insert-heading)) (org-insert-heading))
(buffer-string)))) (buffer-string))))
;; Corner case: correctly insert a headline after an empty one. ;; Corner case: correctly insert a headline after an empty one.
(should (should
(equal "* \n* \n" (equal "* \n* "
(org-test-with-temp-text "* <point>" (org-test-with-temp-text "* <point>"
(org-insert-heading) (org-insert-heading)
(buffer-string)))) (buffer-string))))
@ -1405,7 +1405,7 @@
;; Properly handle empty lines when forcing a headline below current ;; Properly handle empty lines when forcing a headline below current
;; one. ;; one.
(should (should
(equal "* H1\n\n* H\n\n* \n" (equal "* H1\n\n* H\n\n* "
(org-test-with-temp-text "* H1\n\n* H<point>" (org-test-with-temp-text "* H1\n\n* H<point>"
(let ((org-blank-before-new-entry '((heading . t)))) (let ((org-blank-before-new-entry '((heading . t))))
(org-insert-heading '(4)) (org-insert-heading '(4))
@ -1421,14 +1421,14 @@
;; Add headline at the end of the first subtree ;; Add headline at the end of the first subtree
(should (should
(equal (equal
"* TODO \n" "* TODO "
(org-test-with-temp-text "* H1\nH1Body<point>\n** H2\nH2Body" (org-test-with-temp-text "* H1\nH1Body<point>\n** H2\nH2Body"
(org-insert-todo-heading-respect-content) (org-insert-todo-heading-respect-content)
(buffer-substring-no-properties (line-beginning-position) (point-max))))) (buffer-substring-no-properties (line-beginning-position) (point-max)))))
;; In a list, do not create a new item. ;; In a list, do not create a new item.
(should (should
(equal (equal
"* TODO \n" "* TODO "
(org-test-with-temp-text "* H\n- an item\n- another one" (org-test-with-temp-text "* H\n- an item\n- another one"
(search-forward "an ") (search-forward "an ")
(org-insert-todo-heading-respect-content) (org-insert-todo-heading-respect-content)