TW5 list filter that returns tiddlers with both of two tags

1,526 views
Skip to first unread message

David Gifford

unread,
Jan 1, 2014, 1:16:55 PM1/1/14
to tiddl...@googlegroups.com
Hi

I think the TiddlerFilters tiddler needs an example of how to list tiddlers that are tagged with both x and y. All the examples, that I can see, return tiddlers tagged either x or y or both. But I would like to limit filtering to tiddlers tagged both x and y.

Dave

Stephan Hradek

unread,
Jan 1, 2014, 1:38:43 PM1/1/14
to tiddl...@googlegroups.com
I think there is an example under "Runs"

Runs

Operators are combined into runs that function as logically ANDed expressions by bashing them together and merging the square brackets:

[tag[one]] [tag[two]] ---> [tag[one]tag[two]]



Jeremy Ruston

unread,
Jan 1, 2014, 1:38:50 PM1/1/14
to TiddlyWiki
Hi Dave

I've added some more examples:


The short answer:

[tag[x]tag[y]] --> all tiddlers tagged with both x and y

[tag[x]] [tag[y]] --> all tiddlers tagged either x or y

Best wishes

Jeremy



--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

David Gifford

unread,
Jan 1, 2014, 6:42:48 PM1/1/14
to tiddl...@googlegroups.com
Thanks guys!

Dave


--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/hpPGVORx8UQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.



--
David Gifford
Christian Reformed World Missions, Mexico City

Rustem

unread,
Oct 28, 2015, 9:27:40 PM10/28/15
to tiddl...@googlegroups.com, jeremy...@gmail.com

[tag[x]] [tag[y]] --> all tiddlers tagged either x or y

(Old thread, I know, but …) How do I filter SOME tiddlers tagged either x or y?

Two runs separated by a space, as shown above, both take the list of all tiddlers as their input.

But what if I want to pre-filter on some other criteria first, and then return only those of the pre-filtered that are tagged either x or y?

Is this the only way:

[prefilter[]tag[x]] [prefilter[]tag[y]]

My “prefilter” is rather complex, I’d like to avoid repeating it unless there is no other way.

Thanks!

—R

Matabele

unread,
Oct 29, 2015, 12:11:57 AM10/29/15
to TiddlyWiki, jeremy...@gmail.com
Hi

This logic should work but I haven't tested this in TW -- remove all items from the prefiltered list that are not tagged x and not tagged y
 
[prefilter[]] -[!tag[x]!tag[y]]

regards

Tobias Beer

unread,
Oct 29, 2015, 1:07:59 AM10/29/15
to tiddl...@googlegroups.com, jeremy...@gmail.com
Hi Rustem, 

My “prefilter” is rather complex, I’d like to avoid repeating it unless there is no other way.

One option to streamline might be to use a macro(/variable)
into which you stuff your prefilter so as to not repeat it:

\define fx(pre, a, b, post) [$pre$$a$] [$pre$$b$] $post$

<$list filter=<<fx "tag[HelloThere]" "search[finding]" "search[never]" "+[sort[title]]">>/>

Best wishes,

— tb

Rustem

unread,
Oct 29, 2015, 6:34:10 AM10/29/15
to TiddlyWiki, jeremy...@gmail.com
Matabele's way works. Thanks everyone.


On Wednesday, October 28, 2015 at 10:07:59 PM UTC-7, Tobias Beer wrote:
Hi Rustem, 

My “prefilter” is rather complex, I’d like to avoid repeating it unless there is no other way.

I think your only option to streamline might be to use a macro(/variable)

Tobias Beer

unread,
Oct 29, 2015, 8:51:37 AM10/29/15
to TiddlyWiki, jeremy...@gmail.com
Ah, must've been too late to not overlook that double negation. :D

Best wishes,

— tb

Tobias Beer

unread,
Oct 29, 2015, 9:42:38 AM10/29/15
to tiddl...@googlegroups.com, jeremy...@gmail.com
Hi Rustem,

One thing that may be helpful at some point is this.

Consider a tiddler called action to which action tags are tagging, e.g.#future#next#waiting, #done... and then there are tiddlers that tag to those individual status tags.

This can already be done using:

{{{ [[action]tagging[]tagging[]] }}}

...returns only tiddlers that have any action-status tag. Not sure how to do negation on that one.

Anyhow, there is a ticket I once opened for tag-any and tag-all:


#1216 tagged any, tagged all

https://github.com/Jermolene/TiddlyWiki5/issues/1216


What do you think about my last comment there?


Best wishes,


— tb

Matabele

unread,
Oct 30, 2015, 1:21:10 AM10/30/15
to TiddlyWiki, jeremy...@gmail.com
Hi Tobias

Perhaps this should be generalised for any list (not only the tags field.) As in, list all tiddlers that contain any of the items specified, in the targeted list.

The syntax for this becomes problematic, as both the reference pointing to the field being targeted and the array of items to search for must be passed. One option is to first specify the list by way of a filter, then search that list for the items in a referenced array:

"[[prefilter[]] +[listhas:{mylist!!ofitems}]"

The other is to first set up the list of items to search for, then specify the reference pointing to the list to be search (perhaps by generalising the tagging[] operator):

"[[my list]] [[of items]] +[tagging{my!!list}]"

Would either of these address your original usage case?

regards

Tobias Beer

unread,
Oct 30, 2015, 5:26:39 AM10/30/15
to TiddlyWiki, jeremy...@gmail.com
Hi Matabele,

Thanks for your valuable input.
 
Perhaps this should be generalised for any list (not only the tags field.)

I very much agree. The more general, the better.

"[[prefilter[]] +[listhas:{mylist!!ofitems}]"

This would not be quite sufficient as we have not yet specified what list-field to actually check against.

Perhaps...

"[contains:some-list-field:any{these!!listed-items}]"

"[contains:tags:all{my-special!!tags}]"
 
Since one of any or all will be the default, we can skip the "secondary" suffix for that.
I suspect any to be the more common use case, so:

"[contains:tags{any-of!!these-tags}]"

I would be fine with a secondary suffix, it's just as good as any other suffix. But, if we really want the duplication we could also have a separate filter:

"[containsall:tags{all-of!!these-tags}]"

The other is to first set up the list of items to search for, then specify the reference pointing to the list to be search (perhaps by generalising the tagging[] operator):

"[[my list]] [[of items]] +[tagging{my!!list}]"

I would want to avoid this syntax altogether as it is difficult, if not impossible, to combine it with any preceding or subsequent filters. For one, it would have to always be at the beginning of a filter expression.

I have updated the issue on GitHub to cover a more general list-matching approach accordingly:

renamed: #1216 filter operator for "list contains any or all items of another list"
https://github.com/Jermolene/TiddlyWiki5/issues/1216

Best wishes,

— tb 

Pope Innocent III

unread,
Jan 16, 2017, 12:05:56 PM1/16/17
to TiddlyWiki

Sorry for the necrobump, but does anyone know how to do this in TiddlyWiki Classic?

Eric Shulman

unread,
Jan 16, 2017, 4:00:47 PM1/16/17
to TiddlyWiki
On Monday, January 16, 2017 at 9:05:56 AM UTC-8, Pope Innocent III wrote:

Sorry for the necrobump, but does anyone know how to do this in TiddlyWiki Classic?

Install this TWClassic plugin: http://www.tiddlytools.com/#MatchTagsPlugin

Once installed, you can then use Boolean tag operators (AND, OR, NOT) within the "[tags[...]]" filter of the TW core TW <<list>> macro, like this:

 <<list filter "[tags[foo AND bar]]">

and you can create complex expressions using multiple operators and parentheses as needed:

<<list filter "[tag[foo OR bar AND NOT(foo AND bar)]]">>

For flexibility in formatting the list output, you can use the plugin-define <<matchTags>> macro, which provides additional output options.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals

Reply all
Reply to author
Forward
0 new messages