I used a similar “composite filter” technique when I wrote TiddlyTools/Panels/Images. However, since it was before the new \function
syntax was available, I used the older subfilter<...>
syntax to produce equivalent results. While I could now switch over to using \function
syntax, I decided to leave the older syntax in place so that my code is backward compatible and can still be used with versions of the TWCore before v5.3.0.
Here’s the definitions I used in TiddlyTools/Panels/Images:
\define isimage() [is[image]] [tag[$:/tags/Image]] [type[video/webm]] [type[audio/mpeg]] [has[error]] -[type[application/pdf]] -[has[draft.of]]
...
\define prefixfilter() [enlist{$(config)$##prefix}] :map:flat[all<include>prefix<currentTiddler>]
\define suffixfilter() [enlist{$(config)$##suffix}] :map:flat[all<include>suffix<currentTiddler>]
\define tagsfilter() [enlist{$(config)$##tags}] :map:flat[all<include>tag<currentTiddler>]
\define extrafilter() [subfilter{$(config)$##filter}] ~[!match[]]
\define imagefilter() [subfilter<prefixfilter>] [subfilter<suffixfilter>] [subfilter<tagsfilter>] ~[all<include>] +[subfilter<extrafilter>] -[subfilter{$(config)$##exclude}] +[subfilter<isimage>] $(sortFilter)$
which is then used in the rest of the TiddlyTools/Panels/Images code with:
<$list filter="[subfilter<imagefilter>]" ...>
...
</$list>
Note how each filter uses [enlist{$(config)$##something}]
so that they can be easily reconfigured for different user-entered prefix, suffix, and tag values, and the :map:flat[...]
syntax uses all<include>
, where <include>
can be set to “tiddlers”, “shadows”, or “tiddlers+shadows” to further control which tiddlers the combined imagefilter
will include in the final results.
-e