How 'distribute' filter operator on list?

126 views
Skip to first unread message

Mat

unread,
Oct 2, 2017, 8:00:22 AM10/2/17
to TiddlyWiki
I have thos ToC, i.e using the root tag "menu" and below it an arbitrary number of children and grandchildren (i.e two levels below root, but not more)

menu
 - house 
  ---House of Lannister
  ---House of Stark
- place
  ---Winterfell
  ---Kings Landing
- ...


I want to complete this with a listing (i.e not part of the ToC) for all things that are NOT tagged "house", "place", "...". 

Naively I attempted this:

<$set name=listed filter="[tag[menu]]" >
<<list-links "[is[tiddler]!is[system]] +[!tag<listed>]">>
</$set>

...hoping for "!tag" to distribute to all elements in 'listed'. OK, I'm not surprised it doesn't work, but what should I do?

Thanks!

<:-)


Background, mostly off-topic: I almost never watch TV and especially avoid TV-series for fear of getting addicted. My brother insisted I watch GoT (Game of Thrones) ... and I managed to concoct an excuse for myself that "GoT is now part of todays common knowledge", much like classical plays once were. (Actually, most old "classics" are today more of an intellectual oddity than common knowledge or general knowledge. A left over from a time when intellectual food was scarce. That is not to say they are bad... but most would not stand a chance had they been produced today.) Anyway, it turns out GoT is fantastic - but had it not been for a TiddlyWiki to note things in, I would frankly not have been capable of following it. There are more names and places than in the Russian classics and I'd be lost even a few episodes in. 



Jed Carty

unread,
Oct 2, 2017, 9:02:23 AM10/2/17
to TiddlyWiki
I have run into this problem myself a few times and never came up with a satisfactory answer.

The closest I came up with was to define, using $set with a filter, the parts that you want to remove and then just subtracting them. I haven't come up with a way to make this work well.

PMario

unread,
Oct 2, 2017, 9:51:43 AM10/2/17
to TiddlyWiki
On Monday, October 2, 2017 at 2:00:22 PM UTC+2, Mat wrote:
I have thos ToC, i.e using the root tag "menu" and below it an arbitrary number of children and grandchildren (i.e two levels below root, but not more)

menu
 - house 
  ---House of Lannister
  ---House of Stark
- place
  ---Winterfell
  ---Kings Landing
- ...


I want to complete this with a listing (i.e not part of the ToC) for all things that are NOT tagged "house", "place", "...". 

Hi Mat,


I did an experimental bundle. Download it from the link.

Since it "hardcore" overwrites the core TOC macros and not everything works, as I'd like it, I didn't create a plugin.

Feedback would be very welcome. ..

Is it worth to create a tocM plugin, out of this experiement?

have fun!
mario 

Mat

unread,
Oct 2, 2017, 12:36:27 PM10/2/17
to TiddlyWiki
On Monday, October 2, 2017 at 3:02:23 PM UTC+2, Jed Carty wrote:
I have run into this problem myself a few times and never came up with a satisfactory answer.

Hm, that's surprising to hear.
 
The closest I came up with was to define, using $set with a filter, the parts that you want to remove and then just subtracting them. I haven't come up with a way to make this work well.

But that is what my failed attempt tried. How would you do it with the above case?

....

@everyone: Would it make sense to make a github request for this (let a lone a PR of course).
It occurs to me that a times character (*) would make syntactic sense for distribution:

"[op*[a b c]]" = "[op[a]] [op[b]] [op[c]]"


<:-)

Mat

unread,
Oct 2, 2017, 3:29:49 PM10/2/17
to TiddlyWiki
PMario - appreciated, but without having looked yet at your solution I kind of doubt it will solve my question above since the general point of my question is about filters or filter operators rather than about ToC's. 

That said, I do think there is much room for improvement on ToC and actually created a thing over these past weeks (for an enhancement to the Batch Manipulator) that I might present at some later point. Who knows, maybe your solution solves a problem I have with my variant.

<:-)

Mark S.

unread,
Oct 2, 2017, 4:33:44 PM10/2/17
to TiddlyWiki
Hi Mat,

As long as you are content with a solution where you have to know the number of generations in advance, then I think this will work.

What I did for my test was to take "HelloThere" and everything that descended from it and put it into an empty TW. Then I untagged some of the tiddlers.

Here's the code:

<$list filter="[all[tiddlers]!is[system]!title[HelloThere]sort[]]">
<$list filter="[[HelloThere]] -[
<currentTiddler>tags[]] -[<currentTiddler>tags[]tags[]] -[<currentTiddler>tags[]tags[]tags[]]" variable="tag">
<$view field="title"/>
<br/>
</$list>
</$list>

In the outer loop I find all eligible tiddlers that are not "HelloThere". In the inner loop, I insert "HelloThere" in the filter and then look at each passed tiddler. For each passed tiddler I subtract it's tags, then it's tag's tags, then it's tags' tag's tags etc. If there is anything left, then that means "HelloThere" was not subtracted out and so the tiddler is not in the tree and it gets listed.

Hopefully the logic holds up ;-)

Good luck!
Mark

BJ

unread,
Oct 2, 2017, 5:35:29 PM10/2/17
to tiddl...@googlegroups.com
maybe like this?

\define mylist(x)
<<list-links "[is[tiddler]!is[system]] - [tag[menu]] $x$">>
\end
<$wikify name="x" text ="""<$list filter="[tag[menu]]">-[tag[<<currentTiddler>>]]</$list>""">

<$macrocall $name="mylist" x=<<x>>/>
</$wikify>


On Monday, October 2, 2017 at 2:00:22 PM UTC+2, Mat wrote:

RichardWilliamSmith

unread,
Oct 2, 2017, 6:28:24 PM10/2/17
to TiddlyWiki
Hi Mat,

I do something similar. I use this tiddler (which I call nonTOC)

<$list filter="[!is[system]!tag[TOC]]-[[TOC]tagging[]tagging[]]-[[TOC]tagging[]tagging[]tagging[]]-[[TOC]tagging[]tagging[]tagging[]tagging[]]">
</$list>

and transclude it at the bottom of the TOC Tiddler. I just use it to show me which ones are missing from my hierarchy.

Regard,
Richard

PMario

unread,
Oct 2, 2017, 7:34:51 PM10/2/17
to TiddlyWiki
On Monday, October 2, 2017 at 9:29:49 PM UTC+2, Mat wrote:
.. but without having looked yet at your solution

hmm, ... The OP says:

I want to complete this with a listing (i.e not part of the ToC) for all things that are NOT tagged "house", "place", "...".

IMO this can easily be achieved with my proposal. With a simple "out of the box" filter and a merged toc.
You just would have to have a look at the implementation.

I kind of doubt it will solve my question above since the general point of my question is about filters or filter operators rather than about ToC's. 

IMO it's not a filtering problem. It's a problem how the existing toc builds the structure. With the experiment you can combine as may filters as you want.

-m

Reply all
Reply to author
Forward
0 new messages