diff --git a/lisp/org.el b/lisp/org.el index f26b02431..fbd6810f2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -23609,7 +23609,9 @@ depending on context." (skip-chars-forward " \r\t\n")))) (narrow-to-region (org-element-property :contents-begin element) contents-end)) - (call-interactively #'forward-sentence)))))) + ;; End of heading is considered as the end of a sentence. + (let ((sentence-end (concat (sentence-end) "\\|^\\*+ .*$"))) + (call-interactively #'forward-sentence))))))) (define-key org-mode-map "\M-a" 'org-backward-sentence) (define-key org-mode-map "\M-e" 'org-forward-sentence) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index a185cff1f..fbe053fbb 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -3414,8 +3414,8 @@ SCHEDULED: <2017-05-06 Sat> (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2." (org-forward-sentence) (eobp))) - ;; On a headline, stop at the end of the line, unless point is - ;; already there. + ;; Headlines are considered to be sentences by themselves, even if + ;; they do not end with a full stop. (should (equal "* Headline" @@ -3425,7 +3425,11 @@ SCHEDULED: <2017-05-06 Sat> (should (org-test-with-temp-text "* Headline\nSentence." (org-forward-sentence) - (eobp)))) + (eobp))) + (should + (org-test-with-temp-text "Sentence.\n\n* Headline\n\nSentence 2." + (org-forward-sentence) + (and (org-at-heading-p) (eolp))))) (ert-deftest test-org/backward-sentence () "Test `org-backward-sentence' specifications."