org-element: Fix parsing for headlines with only a COMMENT or QUOTE keyword

* lisp/org-element.el (org-element-headline-parser): Fix parsing for
  headlines with a single COMMENT or QUOTE keyword.
* testing/lisp/test-org-element.el: Add tests.
This commit is contained in:
Nicolas Goaziou 2012-09-29 08:54:46 +02:00
parent 7a06ed790a
commit 9c92312d92
2 changed files with 12 additions and 2 deletions

View File

@ -704,10 +704,12 @@ Assume point is at beginning of the headline."
(raw-value (or (nth 4 components) ""))
(quotedp
(let ((case-fold-search nil))
(string-match (format "^%s +" org-quote-string) raw-value)))
(string-match (format "^%s\\( \\|$\\)" org-quote-string)
raw-value)))
(commentedp
(let ((case-fold-search nil))
(string-match (format "^%s +" org-comment-string) raw-value)))
(string-match (format "^%s\\( \\|$\\)" org-comment-string)
raw-value)))
(archivedp (member org-archive-tag tags))
(footnote-section-p (and org-footnote-section
(string= org-footnote-section raw-value)))

View File

@ -739,6 +739,10 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"
(org-test-with-temp-text "* TODO QUOTE Headline"
(let ((org-quote-string "QUOTE")
(org-todo-keywords '((sequence "TODO" "DONE"))))
(should (org-element-property :quotedp (org-element-at-point)))))
;; With the keyword only.
(org-test-with-temp-text "* QUOTE"
(let ((org-quote-string "QUOTE"))
(should (org-element-property :quotedp (org-element-at-point))))))
(ert-deftest test-org-element/headline-comment-keyword ()
@ -761,6 +765,10 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"
(org-test-with-temp-text "* TODO COMMENT Headline"
(let ((org-comment-string "COMMENT")
(org-todo-keywords '((sequence "TODO" "DONE"))))
(should (org-element-property :commentedp (org-element-at-point)))))
;; With the keyword only.
(org-test-with-temp-text "* COMMENT"
(let ((org-comment-string "COMMENT"))
(should (org-element-property :commentedp (org-element-at-point))))))
(ert-deftest test-org-element/headline-archive-tag ()