summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-10-08 10:35:22 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-10-08 10:35:22 +0200
commitd747e51fbf3f88751800981c1cfa4dabfcf174ec (patch)
treefaed482460f19855572b07bc865b52008b504479
parent6432fcd433896e06bc1d0fefd9115952a9ae8ff7 (diff)
downloadorg-mode-d747e51fbf3f88751800981c1cfa4dabfcf174ec.tar.gz
Consider headlines as sentences by themselves
* lisp/org.el (org-forward-sentence): Consider headlines as sentences by themselves. * testing/lisp/test-org.el (test-org/forward-sentence): Add test. Reported-by: Mat Vibrys <vibrysec@gmail.com> <http://lists.gnu.org/archive/html/emacs-orgmode/2017-10/msg00130.html>
-rw-r--r--lisp/org.el4
-rw-r--r--testing/lisp/test-org.el10
2 files changed, 10 insertions, 4 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 41fa685..89addac 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -23618,7 +23618,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 0ac3e60..3bc8c7b 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.<point>\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<point>\nSentence."
(org-forward-sentence)
- (eobp))))
+ (eobp)))
+ (should
+ (org-test-with-temp-text "Sentence.<point>\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."