Fix failing test

* 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.
This commit is contained in:
Nicolas Goaziou 2017-01-19 00:14:16 +01:00
parent 53ee147f45
commit 6dc6eb3b02
3 changed files with 45 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -1513,11 +1513,20 @@
(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:"
@ -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."