Selecting tiddlers tagged with any tags from a dynamic list

I have the following filter to select all the tiddlers that have one or more tags matching the values in the list variable my-tags:

[enlist<my-tags>] :map:flat[all[tiddlers]tag<currentTiddler>] +[unique[]sort[]]

Am I missing something simpler to handle this? It feels as though there’s probably something built in.

You could test it by adding this to a tiddler on tiddlywiki.com:

<$let my-tags="Features Filters Languages">
<<list-links filter:"[enlist<my-tags>] :map:flat[all[tiddlers]tag<currentTiddler>] +[unique[]sort[]]" >>
</$let>

It should show you all tiddlers tagged Features, Filters, or Languages.

I’m not sure if the unique operator is necessary. Is it? (I stripped it out, but maybe it needs to be put back in?)

I added a little HTML to do side-by-side sanity testing:

<$let my-tags="Features Filters Languages">
<table><tr>
<td style="vertical-align:top;">
<<list-links filter:"[enlist<my-tags>] :map:flat[all[tiddlers]tag<currentTiddler>] +[sort[]]" >>
</td>
<td style="vertical-align:top;">
<<list-links filter:"[<my-tags>split[ ]tagging[]sort[]]">>
</td>
</tr></table>
</$let>

And now that I look at it, that “split” will mess things up if a tag in square brackets has a space in there. Back in a couple of minutes.

1 Like

This is better:

<$let my-tags="Features Filters Languages">
<table><tr>
<td style="vertical-align:top;">
<<list-links filter:"[enlist<my-tags>] :map:flat[all[tiddlers]tag<currentTiddler>] +[sort[]]" >>
</td>
<td style="vertical-align:top;">
<<list-links filter:"[enlist<my-tags>tagging[]sort[]]">>
</td>
</tr></table>
</$let>
2 Likes

Yes, that is exactly what I was looking for! Thank you very much!

I think you’re right; it may not be. I’ll probably test this evening just out of curiosity, but now I need to catch a bus.

I tested, and it is necessary for my approach. If you replace Languages with Learning, you will find in the first column two copies of Introduction to Filter Notation.

Not that it matters since you’ve supplied a much better approach, but it’s still good to know.

Thank you once again for the help

– Scott

Well, to me: better depends.

If you are often using “map”, nothing wrong with that. I’m a big fan of using what one knows really well, especially if it matches one’s thought processes. (i.e. it is important that what one looks at reflects what is in one’s head!)

1 Like

Sure, except that I did ask the question because I wasn’t happy with my initial version.

I much prefer tagging here. It feels much more elegant. I am a huge fan of map in many contexts, but when I wrote my version, it felt like I must be missing something simpler. I was, and thank you providing it!