org-element-headline-parser: Treat "* TODO" as empty title + TODO keyword

* lisp/org-element.el (org-element-headline-parser): Allow end of line
instead of space after todo keyword.
*
testing/lisp/test-org-element.el (test-org-element/headline-todo-keyword):
Add new test.
This commit is contained in:
Ihor Radchenko 2023-03-22 15:52:24 +01:00
parent cd2355a204
commit 93bf820384
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 5 additions and 2 deletions

View File

@ -1103,7 +1103,7 @@ Assume point is at beginning of the headline."
(skip-chars-forward " \t")))
(level (org-reduced-level true-level))
(todo (and org-todo-regexp
(let (case-fold-search) (looking-at (concat org-todo-regexp " ")))
(let (case-fold-search) (looking-at (concat org-todo-regexp "\\(?: \\|$\\)")))
(progn (goto-char (match-end 0))
(skip-chars-forward " \t")
(match-string 1))))

View File

@ -1206,7 +1206,10 @@ Some other text
;; Todo keyword is prefix of headlines first word.
(org-test-with-temp-text "* TODOHeadline"
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
(should-not (org-element-property :todo-keyword (org-element-at-point))))))
(should-not (org-element-property :todo-keyword (org-element-at-point)))))
(org-test-with-temp-text "* TODO"
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
(should (org-element-property :todo-keyword (org-element-at-point))))))
(ert-deftest test-org-element/headline-comment-keyword ()
"Test COMMENT keyword recognition."