How to call procedure in filter expression, with param?

https://tiddlywiki.com/#Procedure%20Calls say it is possible to do this

Using Procedure Calls in Filters

<$list filter="[<my-procedure>]">

but it didn’t say how to add param.

How to call the new lingo procedure as filter operator? When used in wikitext it is

\define lingo-base() $:/plugins/linonetwo/commandpalette/language/

<<lingo Readme>>

and

<<lingo Name $:/plugins/linonetwo/commandpalette/language/>>

how to do these in filter expression, and even more, use input as first param? Like [all[shadows]tag[$:/tags/Layout]get[description]<lingo>search[keyword]]

Oh, no, it says “The text is not wikified which again means that the parameters will be ignored.”

Everytime I meet these “not wikified” places I feel it is difficult to use. I hope there is a magic switch that can turn on wikify everything.

Its the same as calling it as a procedure <<my-procedure param>> or <<my-procedure paramname:paramvalue>> however there are some limitations within the filter.

You can set a variable to the output of the procedure + parameters, and just reference the result in the filter.

<$set name=result value=<<my-procedure param>> >

... filter [<result>] ...
  • There are some cases you may need to wikify rather than simply set.

If you can possibly change the way you generate the value into a filter, you can make it into a function. Functions are “evaluated” (my word, almost like wikified) and will this work in filters. Similarly you can use the filter parameter on the set widget.

This is not working

[all[shadows]tag[$:/tags/Layout]get[description]<lingo title:Name override-lingo-base:$:/plugins/linonetwo/commandpalette/language/>]

Function is also defined by filter, so it get back to the problem that can’t use procedure usefully in filter.

And lingo is at last few step ,so there is no place to define variable for it. I’m calling $tw.wiki.filterTiddlers([all[shadows]tag[$:/tags/Layout]search[${query}]]) to get result, not rendering wikitext.

Anyway, I will write JS to do the filtering instead…

I made mistack, what I really need is a wikify filter operator

[all[shadows]tag[$:/tags/Layout]get[description]wikify[]search[keyword]]

So it gets back to [IDEA] procedure wikify mode · Issue #8072 · Jermolene/TiddlyWiki5 · GitHub

Anyway, I can always use JS instead.

          return $tw.wiki.filterTiddlers(`[all[shadows]tag[$:/tags/Layout]]`)
            .map((title) => $tw.wiki.getTiddler(title)?.fields)
            .filter((tiddler): tiddler is ITiddlerFields => {
              if (tiddler === undefined) return false;
              return $tw.wiki.filterTiddlers(
                `[search[${query}]]`,
                undefined,
                $tw.wiki.makeTiddlerIterator([renderTextWithCache(tiddler.name, widget), renderTextWithCache(tiddler.description, widget)]),
              ).length > 0;
            });

and

import type { Widget } from 'tiddlywiki';

export function renderTextWithCache(text: unknown, widget: Widget | undefined) {
  if (text === undefined || typeof text !== 'string' || widget === undefined) return '';
  return $tw.wiki.getGlobalCache(`wikify-${text}`, () => $tw.wiki.renderText('text/plain', 'text/vnd.tiddlywiki', text, { parentWidget: widget }));
}

@linonetwo I think I answered your first question, but I see the reason you asked raises new questions.

  • But first is this all inside Javascript?

I am confident your conclusions are somewhat incorrect. You are a very competent javascript coder and not so with tiddlywiki script yet.

Function is also defined by filter, so it get back to the problem that can’t use procedure usefully in filter.

  • It is possible, as I illustrated above in my reply, but you have to ask why is this approach important to you, because pretty much the same thing can be done multiple ways.

I think it is important to ask for help by exploring the problem in plain language.

My guess

You are trying load different language content to that found in the description field, the new text is in your own plugin.

Let me try reading your example;

[all[shadows]tag[$:/tags/Layout]get[description]<lingo title:Name override-lingo-base:$:/plugins/linonetwo/commandpalette/language/>]

Reading your Filter;

  • All shadow tiddlers selecting only those with the tag $:/tags/Layout (titles)
  • From each of the resulting tiddlers get their description (description text)
    • If no description is found they will be ignored
  • For each of these “strings of descriptions” call the lingo macro, this is the end of the filter.
    • When calling the lingo macro (see core macros) the only parameter is a title.
    • title = name override-lingo-base:$:/plugins/linonetwo/commandpalette/language/>
      • There are things wrong here, the ending /> could cause problems, it would be safer in quotes because not only spaces in titles can interfere.
      • If this macro could get anything from the filter it would be description text not a title
      • The titles, and description text is lost above and not made use of in any way. The lingo macro is called once for each description with exactly the same parameters each time.

What do you want this filter to do, in plain language?

I’m creating a new command palette plugin that might solve your Is there a Search within tool anyone has created? , you can search under a filter.

You know after feat: t macro and docs by linonetwo · Pull Request #7821 · Jermolene/TiddlyWiki5 · GitHub , many tiddlers will have caption: <<lingo xxx>>, and if you want to search tiddlers with their lingo, you have to wikify its caption field first!