Fix element property queries for inlinetasks

* lisp/org.el (org-get-tags): Do not ignore local tags in inlinetasks.
(org-in-commented-heading-p): Do not ignore commented inlinetasks.
* testing/lisp/test-org.el (test-org/get-tags): Add tests for
inlinetasks.

Fixes https://list.orgmode.org/CAKJdtO8-KkVvhcviTqhi+DMZmSK=o37jn1jJPM9qxcuXZPnGgw@mail.gmail.com/T/#u
This commit is contained in:
Ihor Radchenko 2021-11-22 19:26:26 +08:00
parent cd3e138ee5
commit 7a14d6035c
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 41 additions and 28 deletions

View File

@ -12629,34 +12629,34 @@ Inherited tags have the `inherited' text property."
(not local))
org-scanner-tags
(org-with-point-at (unless (org-element-type pos-or-element)
(or pos-or-element (point)))
(unless (and (not (org-element-type pos-or-element))
(org-before-first-heading-p))
(unless (org-element-type pos-or-element) (org-back-to-heading t))
(let ((ltags (if (org-element-type pos-or-element)
(org-element-property :tags (org-element-lineage pos-or-element '(headline) t))
(org--get-local-tags)))
itags)
(if (or local (not org-use-tag-inheritance)) ltags
(let ((cached (and (org-element--cache-active-p)
(if (org-element-type pos-or-element)
(org-element-lineage pos-or-element '(headline) t)
(org-element-at-point nil 'cached)))))
(if cached
(while (setq cached (org-element-property :parent cached))
(setq itags (nconc (mapcar #'org-add-prop-inherited
;; If we do not wrap result into `cl-copy-list', reference would
;; be returned and cache element might be modified directly.
(cl-copy-list (org-element-property :tags cached)))
itags)))
(while (org-up-heading-safe)
(or pos-or-element (point)))
(unless (or (org-element-type pos-or-element)
(org-before-first-heading-p))
(org-back-to-heading t))
(let ((ltags (if (org-element-type pos-or-element)
(org-element-property :tags (org-element-lineage pos-or-element '(headline inlinetask) t))
(org--get-local-tags)))
itags)
(if (or local (not org-use-tag-inheritance)) ltags
(let ((cached (and (org-element--cache-active-p)
(if (org-element-type pos-or-element)
(org-element-lineage pos-or-element '(headline org-data inlinetask) t)
(org-element-at-point nil 'cached)))))
(if cached
(while (setq cached (org-element-property :parent cached))
(setq itags (nconc (mapcar #'org-add-prop-inherited
(org--get-local-tags))
itags)))))
(setq itags (append org-file-tags itags))
(nreverse
(delete-dups
(nreverse (nconc (org-remove-uninherited-tags itags) ltags)))))))))))
;; If we do not wrap result into `cl-copy-list', reference would
;; be returned and cache element might be modified directly.
(cl-copy-list (org-element-property :tags cached)))
itags)))
(while (org-up-heading-safe)
(setq itags (nconc (mapcar #'org-add-prop-inherited
(org--get-local-tags))
itags)))))
(setq itags (append org-file-tags itags))
(nreverse
(delete-dups
(nreverse (nconc (org-remove-uninherited-tags itags) ltags))))))))))
(defun org-get-buffer-tags ()
"Get a table of all tags used in the buffer, for completion."
@ -20735,7 +20735,7 @@ Optional argument ELEMENT contains element at point."
(let ((el (or element (org-element-at-point nil 'cached))))
(if el
(catch :found
(setq el (org-element-lineage el '(headline) 'include-self))
(setq el (org-element-lineage el '(headline inlinetask) 'include-self))
(if no-inheritance
(org-element-property :commentedp el)
(while el

View File

@ -6788,6 +6788,19 @@ Paragraph<point>"
(should
(equal '("foo" "bar")
(org-test-with-temp-text "* Test :foo:bar:" (org-get-tags))))
;; Tags for inlinetasks.
(should
(equal '("foo" "bar")
(progn
(require 'org-inlinetask)
(org-test-with-temp-text (concat (make-string org-inlinetask-min-level ?*) " Test :foo:bar:")
(org-get-tags (org-element-at-point))))))
(should
(equal '("foo" "bar")
(progn
(require 'org-inlinetask)
(org-test-with-temp-text (concat (make-string org-inlinetask-min-level ?*) " Test :foo:bar:")
(org-get-tags nil)))))
;; Return nil when there is no tag.
(should-not
(org-test-with-temp-text "* Test" (org-get-tags)))