org-element-headline-parser: Fix empty headings with tags
* lisp/org-element.el (org-element-headline-parser): Allow empty title with tags. Do not consider space after COMMENT to be a part of title. * testing/lisp/test-org-element.el (test-org-element/headline-todo-keyword): Add tests. Reported-by: Leo Butler <Leo.Butler@umanitoba.ca> Link: https://orgmode.org/list/87zg8t4zgo.fsf@localhost
This commit is contained in:
parent
93bf820384
commit
20b33106cd
|
@ -1114,16 +1114,13 @@ Assume point is at beginning of the headline."
|
||||||
(aref (match-string 0) 2))))
|
(aref (match-string 0) 2))))
|
||||||
(commentedp
|
(commentedp
|
||||||
(and (let ((case-fold-search nil))
|
(and (let ((case-fold-search nil))
|
||||||
(looking-at org-element-comment-string))
|
(looking-at (concat org-element-comment-string "\\(?: \\|$\\)")))
|
||||||
(goto-char (match-end 0))
|
(prog1 t
|
||||||
(when (looking-at-p "\\(?:[ \t]\\|$\\)")
|
(goto-char (match-end 0))
|
||||||
(point))))
|
(skip-chars-forward " \t"))))
|
||||||
(title-start (prog1 (point)
|
(title-start (point))
|
||||||
(unless (or todo priority commentedp)
|
|
||||||
;; Headline like "* :tag:"
|
|
||||||
(skip-chars-backward " \t"))))
|
|
||||||
(tags (when (re-search-forward
|
(tags (when (re-search-forward
|
||||||
"[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
|
"\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
|
||||||
(line-end-position)
|
(line-end-position)
|
||||||
'move)
|
'move)
|
||||||
(goto-char (match-beginning 0))
|
(goto-char (match-beginning 0))
|
||||||
|
|
|
@ -1209,7 +1209,15 @@ Some other text
|
||||||
(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"
|
(org-test-with-temp-text "* TODO"
|
||||||
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
|
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
|
||||||
(should (org-element-property :todo-keyword (org-element-at-point))))))
|
(should (org-element-property :todo-keyword (org-element-at-point)))))
|
||||||
|
(org-test-with-temp-text "* :tag:"
|
||||||
|
(should (member "tag" (org-element-property :tags (org-element-at-point)))))
|
||||||
|
(org-test-with-temp-text "* COMMENT"
|
||||||
|
(should (org-element-property :commentedp (org-element-at-point))))
|
||||||
|
(org-test-with-temp-text "* COMMENT title"
|
||||||
|
(should (equal "title" (org-element-property :raw-value (org-element-at-point)))))
|
||||||
|
(org-test-with-temp-text "* COMMENT:tag:"
|
||||||
|
(should-not (org-element-property :commentedp (org-element-at-point)))))
|
||||||
|
|
||||||
(ert-deftest test-org-element/headline-comment-keyword ()
|
(ert-deftest test-org-element/headline-comment-keyword ()
|
||||||
"Test COMMENT keyword recognition."
|
"Test COMMENT keyword recognition."
|
||||||
|
|
Loading…
Reference in New Issue