Get all the places a macro was called

Hello good people

I want to list every tiddler where a macro was called with a specific variable (for ex every instance of <<printThis 1>>). what s the best way to do this? would searching for the macro call expression work or would it be replaced with macro content in search? i tested this with search and regexp but dont know if there is bug in my filter expression or if its a bigger problem

thanks

Searching for “<<macroname” or for that matter “\define macroname(” is trivial in a search field however if the search string contains special characters place it in a variable or field first if you want to reference it inside a filter with tge search operator. Also make sure you include system or shadow tiddlers if relevant.

[all[shadows+tiddlers]… Or other firls in nessasary.

2 Likes

thanks for the reply

my problem is when searching for <<macroName var>> when i hardcode var value everythings fine but when i need to get var value from a field for example, the search search::[macroName {{!!varField}}>>] doesn’t return anything

That is why I only search for what is dependable such as only <<macroname. Somtimes the last filter is our eyes.

However if you know regexp you can getvquite sohisticated.

1 Like

As tones points out, search only for “half” of the call, i.e <<macroname

BUT there is one more aspect: macros can be invoked with he macrocall widget, like so <$macrocall $name=macroname .... so you might also want to search for $name=macroname (maybe even $name="macroname" with quotes).

2 Likes

Maybe a language service can make this better, we can have “find reference” if there is a language service running.

1 Like

I seem to be explaining it wrong, i’m looking for wherever its called with that specific variable. for example only when its <<macroWave "hand">> not when its <<macroWave "food">> and im getting this from a field called macroWaveType
im sorry

There is no function in the TW core that will provide this function out of the box.

1 Like

@NewTiddler1 I understand exactly what you are asking but unless you can guarantee the spacing and parameter names are exact, you will find constructing a search to get what you want is complex.

Normally the number of occurrences of a macro call or macro definition is small enough that searching for <<macroname and name=macroname will be sufficient.

However let us say you made a custom macro that you use everywhere (thus is large in number) and as you suggest the parameter passed to it is critical for its operation and you want to search for based on the macro and the parameter value.

You could set your own standard to help youself, such as every time you use the parameter in your macro calls, use the following forms uniqueparamname:"value" or uniqueparamname="value"(in a $macrocall widget). These can always be found then because you ensured this was the case. Using the full named parameter/value pair, means it will not matter in which order it exists in the macrocall.

In fact you do not even search for the macroname only the uniqueparamname / value pair.

1 Like

I didn’t think of this at all! thank you this was very helpful :+1:

1 Like

i tested a bunch of things and I think the problem was that search:: was taking getting field value literally ( this thing → {{!!field}} ) by default, same for macros and variables (this stuff → <myFiltVar> <myFiltMacro>>). the thing that worked finally was just putting the list widget in its own macro and passing the field value through the macro call since its substituted it gets around the literal setting.
maybe it was stupid of me but i didn’t know