summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-18 23:14:16 (GMT)
committer Nicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-18 23:22:49 (GMT)
commit6dc6eb3b029ec00c10e20dcfaa0b6e328bf36e03 (patch)
tree3eed056fd1ffd659680f8c4d567ef38cb7626970
parent53ee147f4537a051bfde366ea1459f059fdc13ef (diff)
downloadorg-mode-master.zip
org-mode-master.tar.gz
Fix failing testHEADmaster
* lisp/org.el (org-link-search): Remove priority cookie from headlines during a fuzzy search. Tiny optimization. * testing/lisp/test-org.el (test-org/get-heading): Add tests.
-rw-r--r--etc/ORG-NEWS3
-rw-r--r--lisp/org.el5
-rw-r--r--testing/lisp/test-org.el41
3 files changed, 45 insertions, 4 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 99952a9..bb3020c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -202,6 +202,9 @@ that doesn't exist in the target file, save positon before raising an
error. As a consequence, it is possible to jump back to the original
document with ~org-mark-ring-goto~ (default binding =C-c &=).
+*** ~org-get-heading~ accepts two more optional arguments
+
+See docstring for details.
* Version 9.0
** Incompatible changes
diff --git a/lisp/org.el b/lisp/org.el
index 44320b8..0413d83 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11146,7 +11146,8 @@ of matched result, which is either `dedicated' or `fuzzy'."
org-comment-string
(mapconcat #'regexp-quote words ".+")))
(cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]")
- (comment-re (format "\\`%s[ \t]+" org-comment-string)))
+ (comment-re (eval-when-compile
+ (format "\\`%s[ \t]+" org-comment-string))))
(goto-char (point-min))
(catch :found
(while (re-search-forward title-re nil t)
@@ -11155,7 +11156,7 @@ of matched result, which is either `dedicated' or `fuzzy'."
(replace-regexp-in-string
cookie-re ""
(replace-regexp-in-string
- comment-re "" (org-get-heading t t)))))
+ comment-re "" (org-get-heading t t t)))))
(throw :found t)))
nil)))
(beginning-of-line)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 49e9477..9008e6b 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1513,12 +1513,21 @@
(equal "H"
(org-test-with-temp-text "* H\nText<point>"
(org-get-heading))))
- ;; Without any optional argument, return TODO keywords and tags.
+ ;; Without any optional argument, return TODO keyword, priority
+ ;; cookie, COMMENT keyword and tags.
(should
(equal "TODO H"
(org-test-with-temp-text "#+TODO: TODO | DONE\n* TODO H<point>"
(org-get-heading))))
(should
+ (equal "[#A] H"
+ (org-test-with-temp-text "* [#A] H"
+ (org-get-heading))))
+ (should
+ (equal "COMMENT H"
+ (org-test-with-temp-text "* COMMENT H"
+ (org-get-heading))))
+ (should
(equal "H :tag:"
(org-test-with-temp-text "* H :tag:"
(org-get-heading))))
@@ -1545,11 +1554,39 @@
(equal "Todo H"
(org-test-with-temp-text "#+TODO: TODO | DONE\n* Todo H<point>"
(org-get-heading nil t))))
+ ;; With NO-PRIORITY, ignore priority.
+ (should
+ (equal "H"
+ (org-test-with-temp-text "* [#A] H"
+ (org-get-heading nil nil t))))
+ (should
+ (equal "H"
+ (org-test-with-temp-text "* H"
+ (org-get-heading nil nil t))))
+ (should
+ (equal "TODO H"
+ (org-test-with-temp-text "* TODO [#A] H"
+ (org-get-heading nil nil t))))
+ ;; With NO-COMMENT, ignore COMMENT keyword.
+ (should
+ (equal "H"
+ (org-test-with-temp-text "* COMMENT H"
+ (org-get-heading nil nil nil t))))
+ (should
+ (equal "H"
+ (org-test-with-temp-text "* H"
+ (org-get-heading nil nil nil t))))
+ (should
+ (equal "TODO [#A] H"
+ (org-test-with-temp-text "* TODO [#A] COMMENT H"
+ (org-get-heading nil nil nil t))))
;; On an empty headline, return value is consistent.
(should (equal "" (org-test-with-temp-text "* " (org-get-heading))))
(should (equal "" (org-test-with-temp-text "* " (org-get-heading t))))
(should (equal "" (org-test-with-temp-text "* " (org-get-heading nil t))))
- (should (equal "" (org-test-with-temp-text "* " (org-get-heading t t)))))
+ (should (equal "" (org-test-with-temp-text "* " (org-get-heading nil nil t))))
+ (should
+ (equal "" (org-test-with-temp-text "* " (org-get-heading nil nil nil t)))))
(ert-deftest test-org/in-commented-heading-p ()
"Test `org-in-commented-heading-p' specifications."