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))))
|
||||
(commentedp
|
||||
(and (let ((case-fold-search nil))
|
||||
(looking-at org-element-comment-string))
|
||||
(looking-at (concat org-element-comment-string "\\(?: \\|$\\)")))
|
||||
(prog1 t
|
||||
(goto-char (match-end 0))
|
||||
(when (looking-at-p "\\(?:[ \t]\\|$\\)")
|
||||
(point))))
|
||||
(title-start (prog1 (point)
|
||||
(unless (or todo priority commentedp)
|
||||
;; Headline like "* :tag:"
|
||||
(skip-chars-backward " \t"))))
|
||||
(skip-chars-forward " \t"))))
|
||||
(title-start (point))
|
||||
(tags (when (re-search-forward
|
||||
"[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
|
||||
"\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
|
||||
(line-end-position)
|
||||
'move)
|
||||
(goto-char (match-beginning 0))
|
||||
|
|
|
@ -1209,7 +1209,15 @@ Some other text
|
|||
(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))))))
|
||||
(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 ()
|
||||
"Test COMMENT keyword recognition."
|
||||
|
|
Loading…
Reference in New Issue