fix(org,cli): tangle: filter by tag properly

Org files with tagged headlines weren't tangled correctly.

Also improves filtering by tag as in current shape it is not working at all.

Fix: #8622
This commit is contained in:
Sergey Trofimov 2026-02-10 04:53:54 +01:00 committed by GitHub
parent eeb66ed0e0
commit 29dad16dea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,7 +49,7 @@ EXAMPLES:
(setq last-heading-pos current-heading-pos)))
(unless (or (org-in-commented-heading-p)
(org-in-archived-heading-p))
(let* ((tags (org-get-tags-at))
(let* ((headline-tags (org-get-tags))
(info (org-babel-get-src-block-info 'no-eval))
(src-lang (nth 0 info))
(src-tfile (cdr (assq :tangle (nth 2 info))))
@ -66,16 +66,14 @@ EXAMPLES:
((let* ((tags (seq-group-by (fn! (equal (car %) "--or")) tags))
(or-tags (mapcar #'cdr (cdr (assq t tags))))
(and-tags (mapcar #'cdr (cdr (assq nil tags))))
(all-tags (append or-tags and-tags)))
(and-tags (mapcar #'cdr (cdr (assq nil tags)))))
(and (or or-tags and-tags)
(or (not and-tags)
(let ((a (cl-intersection and-tags all-tags :test #'string=))
(let ((a (cl-intersection and-tags headline-tags :test #'string=))
(b and-tags))
(not (or (cl-set-difference a b :test #'equal)
(cl-set-difference b a :test #'equal)))))
(cl-set-exclusive-or a b :test #'equal)))
(or (not or-tags)
(cl-intersection or-tags all-tags :test #'string=))
(not (cl-intersection or-tags headline-tags :test #'string=)))
t)))
((or (not src-tfile)