* Bug: Matching tags: results incomplete when mixing group tags and their ancestors [9.1.7 (9.1.7-12-g74f6ed-elpaplus @ /home/martin/.emacs.d/elpa/org-plus-contrib-20180305/)]
@ 2018-03-12 7:31 Martin Kampas
2018-03-15 14:44 ` Martin Kampas
0 siblings, 1 reply; 6+ messages in thread
From: Martin Kampas @ 2018-03-12 7:31 UTC (permalink / raw)
To: emacs-orgmode
Hi,
Here is an example Org file:
------------
#+TAGS: [ tag1 : tag2 ] [ tag2 : tag3 ] [ tag3 : tag4 ]
* Tag1 :tag1:
* Tag2 :tag2:
* Tag3 :tag3:
* Tag4 :tag4:
------------
Searching headlines by tags works well unless you combine a group tag together with some of its ancestor tags in the query.
1) GOOD - Searching for "tag1" marks all four headlines.
2) GOOD - Searching for "tag3" marks headlines "Tag3" and "Tag4".
3) BAD - Searching for "tag1+tag3" marks just headline "Tag3" providing an incomplete result. Expected result: headlines "Tag3" and "Tag4" are marked.
With more complex tag set it may happen quite easily that such a search is done.
The bug seems to be in org-tags-expand.
(org-tags-expand "tag1")
#("{\\<\\(?:tag[1-4]\\)\\>}" 0 20 (grouptag t))
(org-tags-expand "tag3")
#("{\\<\\(?:tag[34]\\)\\>}" 0 19 (grouptag t))
(org-tags-expand "tag1+tag3")
#("{\\<\\(?:tag[1-4]\\)\\>}+tag3" 0 20 (grouptag t))
In the third invocation "tag3" was left unexpanded.
Best regards,
Martin
Emacs : GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.26)
of 2018-02-09
Package: Org mode version 9.1.7 (9.1.7-12-g74f6ed-elpaplus @ /home/martin/.emacs.d/elpa/org-plus-contrib-20180305/)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug: Matching tags: results incomplete when mixing group tags and their ancestors [9.1.7 (9.1.7-12-g74f6ed-elpaplus @ /home/martin/.emacs.d/elpa/org-plus-contrib-20180305/)]
2018-03-12 7:31 Bug: Matching tags: results incomplete when mixing group tags and their ancestors [9.1.7 (9.1.7-12-g74f6ed-elpaplus @ /home/martin/.emacs.d/elpa/org-plus-contrib-20180305/)] Martin Kampas
@ 2018-03-15 14:44 ` Martin Kampas
2018-03-16 22:05 ` Nicolas Goaziou
2018-03-21 1:14 ` Bastien
0 siblings, 2 replies; 6+ messages in thread
From: Martin Kampas @ 2018-03-15 14:44 UTC (permalink / raw)
To: emacs-orgmode
Hi,
This seems to fix the bug.
Best Regards,
Martin
From fef860e356a4ca75366f69ec9c2d52252c9d7d3f Mon Sep 17 00:00:00 2001
From: Martin Kampas <martin.kampas@hidden>
Date: Thu, 15 Mar 2018 15:41:53 +0100
Subject: [PATCH] Fix matching tags when mixing group tags and their ancestors
* lisp/org.el (org-expand-tags): Fix recursion stop condition
See http://lists.gnu.org/r/emacs-orgmode/2018-03/msg00228.html
---
lisp/org.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/org.el b/lisp/org.el
index 76bc60c88..7bf013390 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13960,7 +13960,7 @@ When DOWNCASE is non-nil, expand downcased TAGS."
(tag (match-string 2 return-match))
(tag (if downcased (downcase tag) tag)))
(unless (or (get-text-property 0 'grouptag (match-string 2 return-
match))
- (member tag work-already-expanded))
+ (member tag tags-already-expanded))
(setq tags-in-group (assoc tag taggroups))
(push tag work-already-expanded)
;; Recursively expand each tag in the group, if the tag hasn't
--
2.16.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: Bug: Matching tags: results incomplete when mixing group tags and their ancestors [9.1.7 (9.1.7-12-g74f6ed-elpaplus @ /home/martin/.emacs.d/elpa/org-plus-contrib-20180305/)]
2018-03-15 14:44 ` Martin Kampas
@ 2018-03-16 22:05 ` Nicolas Goaziou
2018-03-21 1:14 ` Bastien
1 sibling, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2018-03-16 22:05 UTC (permalink / raw)
To: Martin Kampas; +Cc: emacs-orgmode
Hello,
Martin Kampas <martin.kampas@ubedi.net> writes:
> This seems to fix the bug.
Thank you. Would you mind also providing a couple of tests for that?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug: Matching tags: results incomplete when mixing group tags and their ancestors [9.1.7 (9.1.7-12-g74f6ed-elpaplus @ /home/martin/.emacs.d/elpa/org-plus-contrib-20180305/)]
2018-03-15 14:44 ` Martin Kampas
2018-03-16 22:05 ` Nicolas Goaziou
@ 2018-03-21 1:14 ` Bastien
2018-03-22 5:32 ` Martin Kampas
1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2018-03-21 1:14 UTC (permalink / raw)
To: Martin Kampas; +Cc: emacs-orgmode
Hi Martin,
Martin Kampas <martin.kampas@ubedi.net> writes:
> This seems to fix the bug.
I applied the patch, thanks! If you have time to add tests,
that'd be great, as Nicolas suggested.
Best,
--
Bastien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug: Matching tags: results incomplete when mixing group tags and their ancestors [9.1.7 (9.1.7-12-g74f6ed-elpaplus @ /home/martin/.emacs.d/elpa/org-plus-contrib-20180305/)]
2018-03-21 1:14 ` Bastien
@ 2018-03-22 5:32 ` Martin Kampas
2018-03-22 8:22 ` Bastien Guerry
0 siblings, 1 reply; 6+ messages in thread
From: Martin Kampas @ 2018-03-22 5:32 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
Hi Bastien,
> If you have time to add tests, that'd be great, as Nicolas suggested.
Here you are.
Best Regards,
Martin
From bd8059e18fa3bd2977415449139fc626d03817a3 Mon Sep 17 00:00:00 2001
From: Martin Kampas <martin.kampas@hidden>
Date: Thu, 22 Mar 2018 06:20:31 +0100
Subject: [PATCH] Extend match-sparse-tree test for tag hierarchies
* test-org.el (test-org/match-sparse-tree): Extend test after commit
894ec00 (org.el: Fix recursion stop condition when expanding tags).
---
testing/lisp/test-org.el | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index e97dfe775..8d8b36f86 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -5765,6 +5765,15 @@ Paragraph<point>"
(org-match-sparse-tree nil "Lev_1")
(search-forward "H4")
(org-invisible-p2)))
+ (should-not
+ (org-test-with-temp-text
+ "#+TAGS: [ Lev_1 : Lev_2 ]\n
+#+TAGS: [ Lev_2 : Lev_3 ]\n
+#+TAGS: { Lev_3 : Lev_4 }\n
+* H\n** H1 :Lev_1:\n** H2 :Lev_2:\n** H3 :Lev_3:\n** H4 :Lev_4:"
+ (org-match-sparse-tree nil "Lev_1+Lev_3")
+ (search-forward "H4")
+ (org-invisible-p2)))
;; Match regular expressions in tags
(should-not
(org-test-with-temp-text
--
2.16.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-22 8:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-12 7:31 Bug: Matching tags: results incomplete when mixing group tags and their ancestors [9.1.7 (9.1.7-12-g74f6ed-elpaplus @ /home/martin/.emacs.d/elpa/org-plus-contrib-20180305/)] Martin Kampas
2018-03-15 14:44 ` Martin Kampas
2018-03-16 22:05 ` Nicolas Goaziou
2018-03-21 1:14 ` Bastien
2018-03-22 5:32 ` Martin Kampas
2018-03-22 8:22 ` Bastien Guerry
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.