Filter for all tiddlers whose title does not appear in the 'list' field of another tiddler?

112 views
Skip to first unread message

Ed

unread,
May 28, 2019, 4:23:38 PM5/28/19
to TiddlyWiki
Hi there

As in the title, I am trying to filter for all tiddlers whose title does not appear in the 'list' field of another tiddler, and I can't seem to figure it out.

My specific case: I am using TiddlyMap, with edges generated using tw-list:list. I want to apply custom node styling to all nodes that don't have any edges going into them.

Any help would be much appreciated!

Thank you. Ed

TonyM

unread,
May 28, 2019, 7:56:17 PM5/28/19
to TiddlyWiki
Ed,

Not an answer but a possible approach. Have a look at using the subfilter operator. A subfilter that lists the set of tiddlers, another that lists the items to exclude.

Regards
Tony

bimlas

unread,
May 29, 2019, 3:53:26 AM5/29/19
to TiddlyWiki
I'm not sure I understand how you want to use it, but the `-[listed[]]`" filter can filter out the tiddlers listed in the `list` (or any other) field of other tiddlers. For example:

[all[tiddlers]] -[listed[]]

https://tiddlywiki.com/#listed%20Operator

Ed

unread,
May 29, 2019, 6:11:52 AM5/29/19
to tiddl...@googlegroups.com
Not an answer but a possible approach. Have a look at using the subfilter operator. A subfilter that lists the set of tiddlers, another that lists the items to exclude.

Hi Tony. Thanks for your response. Would you be able to go into a little more detail? I had a look at the subfilter operator and fiddled with it for a bit but I don't think that I really understand it!

I'm not sure I understand how you want to use it, but the `-[listed[]]`" filter can filter out the tiddlers listed in the `list` (or any other) field of other tiddlers.

Hi Bimlas. Thanks for your response. I'm not sure that the listed[] filter would work for this case. It lists tiddlers that list the input tiddlers, whereas I would want to list tiddlers that are listed by the input tiddlers.

I will give an example to make it clear what I am trying to do.

Tiddler A lists Tiddler B. Tiddler B lists Tiddler C. I want a filter that returns Tiddler A, since it is not listed by any of the other tiddlers. In this case listed[] returns A and B.

bimlas

unread,
May 29, 2019, 6:43:57 AM5/29/19
to TiddlyWiki
Ed,

Ok, I think I've got the idea:

[!is[system]] -[!is[system]get[list]]

Ed

unread,
May 29, 2019, 7:17:54 AM5/29/19
to tiddl...@googlegroups.com
Thank you Bimlas!

The problem I have is that many of the entries in the list field are in double square brackets, so get[list] returns several [[things like this]].

How could I return the tiddler titles without the square brackets?

Mark S.

unread,
May 29, 2019, 10:33:39 AM5/29/19
to TiddlyWiki
The problem is that there is no equivalent of "get" for "list" fields. So it takes a more complicated approach. You have to output all the items you want to exclude, wikify them, and then substract them.
You also have to take steps to turn titles into links that will work in the final filter. Also, there may be a bug in the list operator when used in <$list> loop. It's kind of messy.

The following seems to work on my short tests (YMMV) :

\define getlists()
<$vars pre="[[" suf="]]" left="[" right="]">
<$list filter="[all[tiddlers]!is[system]addsuffix[!!list]]" variable="locallist">
<$list filter="""[list<locallist>addprefix<pre>addsuffix<suf>]"""/>
</$list>
</$vars>
\end

<$wikify name="listastext" text=<<getlists>> mode="inline" output="text" >
<<list-links """[all[tiddlers]!is[system]] -[enlist<listastext>] +[sort[]]""">>
</$wikify>

Ed

unread,
May 29, 2019, 3:15:30 PM5/29/19
to tiddl...@googlegroups.com
Thank you Mark. That doesn't seem to work for me, though I don't understand why.

I am not sure it is useful for my case though because I don't think you can use wikify within the TiddlyMap custom styling. I think it has to just be a filter.

I tried doing [!is[system]] -[!is[system]get[list]removeprefix[[[]removesuffix[]]]] but obviously there is a problem with using square brackets as parameters.

Is there an escape character to allow square brackets as the parameter of a filter? I can't see anything in the docs.

Regards, Ed

Mark S.

unread,
May 29, 2019, 4:55:13 PM5/29/19
to TiddlyWiki
I'm pretty sure my code works ... there may be more tiddlers than you think that contain references to a particular tiddler in their list field. I'd want to see the data before going further.

If you have to do it as a filter, I think you're out of luck.

You could make a global macro that defines "[[" and "]]" similar to how I did in my macro. Then you can do something like removeprefix<leftbraces> . But I think that "get" is treating the entire
contents of the list field as one long tiddler title, so if you have [[My first tiddler]] [[My second tiddler]] then what is going to generated is [[My]] [[first]] [[tiddler]] [[My]] [[second]] [[tiddler]]. It's
worth a shot, but I don't think it will work. With a regular expresion string splitter (see PR# 2963) could split on the fly.That might work.

Sometimes you can do things in two steps. So you could use my code and a action-setfield widget to tag all the items that matched the criteria output by the macro. Then you could use that tag to do your filtering.

Good luck!

Ed

unread,
May 29, 2019, 5:56:50 PM5/29/19
to tiddl...@googlegroups.com
I'm pretty sure my code works ... there may be more tiddlers than you think that contain references to a particular tiddler in their list field.

You are right sorry I was mistaken!

You could make a global macro that defines "[[" and "]]" similar to how I did in my macro. Then you can do something like removeprefix<leftbraces> . But I think that "get" is treating the entire
contents of the list field as one long tiddler title, so if you have [[My first tiddler]] [[My second tiddler]] then what is going to generated is [[My]] [[first]] [[tiddler]] [[My]] [[second]] [[tiddler]].

I tried this and got My first tiddler]] [[My second tiddler.

I think I will just have to change the way I use the list field in my wiki! Thank you for all your help.
Reply all
Reply to author
Forward
0 new messages