Skip to content

Commit 6676a97

Browse files
committed
org-tags-expand: Fix handling of downcased group tags
* lisp/org.el (org-tags-expand): Support using an upper- or mix-case tag as MATCH when SINGLE-AS-LIST and DOWNCASED are non-nil, fixing a regression from v9.2. * testing/lisp/test-org.el (test-org/tags-expand): Add test. org-agenda-filter-by-tag reads a case-sensitive tag from the user, and downstream code passes this tag as is to org-tags-expand along with non-nil values for SINGLE-AS-LIST and DOWNCASED. As of 9df82be (Fix tag groups expansion as a regexp, 2018-11-08), org-tags-expand fails to return the group tags in this scenario for queries that contains an uppercase letter, breaking org-agenda-filter-by-tag. Downcase MATCH if SINGLE-AS-LIST and DOWNCASED are non-nil. Reported-by: Leon Weber <leon.weber@net2.ch> Ref: https://orgmode.org/list/c1f8cc32-dc16-697c-c24d-e5e05124bd66@net2.ch
1 parent f8ae0cd commit 6676a97

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lisp/org.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11742,7 +11742,9 @@ When DOWNCASED is non-nil, expand downcased TAGS."
1174211742
(if (not downcased) g
1174311743
(mapcar (lambda (s) (mapcar #'downcase s)) g)))))
1174411744
(cond
11745-
(single-as-list (org--tags-expand-group (list match) tag-groups nil))
11745+
(single-as-list (org--tags-expand-group
11746+
(list (if downcased (downcase match) match))
11747+
tag-groups nil))
1174611748
(org-group-tags
1174711749
(let* ((case-fold-search t)
1174811750
(tag-syntax org-mode-syntax-table)

testing/lisp/test-org.el

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7106,7 +7106,14 @@ Paragraph<point>"
71067106
(equal "{A+}"
71077107
(org-test-with-temp-text "#+TAGS: [ A : B C ]"
71087108
(org-mode-restart)
7109-
(let ((org-tag-alist-for-agenda nil)) (org-tags-expand "{A+}"))))))
7109+
(let ((org-tag-alist-for-agenda nil)) (org-tags-expand "{A+}")))))
7110+
;; Uppercase MATCH works with a non-nil DOWNCASED and SINGLE-AS-LIST.
7111+
(should
7112+
(equal (list "a" "b" "c")
7113+
(org-test-with-temp-text "#+TAGS: [ A : B C ]"
7114+
(org-mode-restart)
7115+
(let ((org-tag-alist-for-agenda nil))
7116+
(sort (org-tags-expand "A" t t) #'string-lessp))))))
71107117

71117118

71127119
;;; TODO keywords

0 commit comments

Comments
 (0)