Fix: (--tags-at) Respect tag inheritance options

Respect org-use-tag-inheritance and org-tags-exclude-from-inheritance.

Fixes #43.  Thanks to Josiah Schwab (@jschwab) for reporting.
This commit is contained in:
Adam Porter 2019-09-06 11:55:59 -05:00
parent bf20251e93
commit 8a812323fc

View file

@ -652,16 +652,24 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)."
;; Not found in cache: get tags and cache them.
(let* ((local-tags (or (org-ql--get-tags position 'local)
'org-ql-nil))
(inherited-tags (or (save-excursion
(when (org-up-heading-safe)
(-let* (((inherited local) (org-ql--tags-at (point))))
(when (or inherited local)
(cond ((and (listp inherited)
(listp local))
(->> (append inherited local)
-non-nil -uniq))
((listp inherited) inherited)
((listp local) local))))))
(inherited-tags (or (when org-use-tag-inheritance
(save-excursion
(when (org-up-heading-safe)
(-let* (((inherited local) (org-ql--tags-at (point)))
(tags (when (or inherited local)
(cond ((and (listp inherited)
(listp local))
(->> (append inherited local)
-non-nil -uniq))
((listp inherited) inherited)
((listp local) local)))))
(cl-typecase org-use-tag-inheritance
(list (setf tags (-intersection tags org-use-tag-inheritance)))
(string (setf tags (--select (string-match org-use-tag-inheritance it)
tags))))
(pcase org-tags-exclude-from-inheritance
('nil tags)
(_ (-difference tags org-tags-exclude-from-inheritance)))))))
'org-ql-nil))
(all-tags (list inherited-tags local-tags)))
;; Check caches again, because they may have been set now.