Function: org-get-tags
org-get-tags is a byte-compiled function defined in org.el.gz.
Signature
(org-get-tags &optional POS-OR-ELEMENT LOCAL)
Documentation
Get the list of tags specified in the current headline.
When argument POS-OR-ELEMENT is non-nil, retrieve tags for headline at POS.
According to org-use-tag-inheritance, tags may be inherited
from parent headlines, and from the whole document, through
org-file-tags. In this case, the returned list of tags
contains tags in this order: file tags, tags inherited from
parent headlines, local tags. If a tag appears multiple times,
only the most local tag is returned.
However, when optional argument LOCAL is non-nil, only return tags specified at the headline.
Inherited tags have the inherited text property.
Aliases
org-get-tags-at (obsolete since 9.2)
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-get-tags (&optional pos-or-element local)
"Get the list of tags specified in the current headline.
When argument POS-OR-ELEMENT is non-nil, retrieve tags for headline at
POS.
According to `org-use-tag-inheritance', tags may be inherited
from parent headlines, and from the whole document, through
`org-file-tags'. In this case, the returned list of tags
contains tags in this order: file tags, tags inherited from
parent headlines, local tags. If a tag appears multiple times,
only the most local tag is returned.
However, when optional argument LOCAL is non-nil, only return
tags specified at the headline.
Inherited tags have the `inherited' text property."
(save-match-data
(if (and org-trust-scanner-tags
(or (not pos-or-element) (eq pos-or-element (point)))
(not local))
org-scanner-tags
(org-with-point-at (unless (org-element-type pos-or-element)
(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
;; If we do explicitly copy the result, reference would
;; be returned and cache element might be modified directly.
(mapcar #'copy-sequence (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))))))))))