Question about a filter

I’m sorry to ask so many questions about filters, but sadly I can’t get around to them yet, despite having studied the documentation several times. This one should be quite easy though:

I want a filter that outputs the list of all tags of a tiddler but excluding from this list the tags that are named in its field

This filter can be found in $:/core/ui/ViewTemplate/tags:

filter="[all[current]tags[]sort[title]]"

I would like to make a working filter that is something like this:

filter="[all[current]tags[]sort[title]] -[list[current!!test]] 

(or <currentTiddler>?)"

Basically if I have a tiddler “A” tagged with Tag1 Tag2 Tag3 Tag4 and in the “test” field i have Tag2 and Tag4 the output of the filter should be Tag1 Tag3.

I hope you understand what I mean

1 Like

Give this a try:

<$list filter="[<currentTiddler>tags[]sort[title]] :except[<currentTiddler>get[test]enlist-input[]]">

</$list>

I got this result:

image

1 Like

It works, thanks!
(interesting the enlist-input Operator btw, I am reading the documentation now, it’s handy)

current is a especial parameter used in all operator and other(s). But it doesn’t work in list operator (and many others). In your case you need to use the name of tiddler (A in your example) and the field with the list A!!test, but it doesn’t fit in your needs.

(As far I know) There are two alternatives that return a list as output: enlist-input or enlist operators. The first is used by @Brian_Radspinner in his code. The alternative could use text reference and it would be:

<$list filter="[<currentTiddler>tags[]sort[title]] -[enlist{!!test}]">

</$list>
1 Like

Interesting! I did not know about this :except named filter run prefix.

The :except filter run prefix is indeed documented incidentally at Tiddlywiki.com.
(Searching for :except yields two results.)

Alas, except as search string does not give an Except Filter Run Prefix (which would be analogous to Intersection Filter Run Prefix and the like).

Since filter run prefixes are so useful, an exhaustive list of them would be helpful!

The issue is in -[list[current!!test]]

Use

<$list filter="[all[current]tags[]] -[list[!!test]]"> </$list>

By the way I myself like the solution by Brian, as it is more compatible with modern TW.

Another approach to except is to use the subfilter operator, I like the original - prefix rather than except in this case;

\define exception-filter() [enlist{!!test}]
<$list filter="[<currentTiddler>tags[]sort[title]] -[subfilter<exception-filter>] ">

</$list>
  • Untested but illustrates the pattern
  • It removes the titles matching the subfilter

In 5.3.0 we can do this

\function .exceptions() [enlist{!!test}]
<$list filter="[<currentTiddler>tags[]sort[title]!.exception-filter[]] ">

</$list>
  • Untested but illustrates the pattern
  • Note I negate the custom filter with !