It is actually relatively easy to do. Start by creating the following macro definition (in a tiddler tagged with $:/tags/Macro):
\define filtersearch(filter)
<$button class="tc-btn-invisible">
<$text text="""$filter$""" />
<$action-navigate $to="$:/AdvancedSearch"/>
<$action-setfield $tiddler="$:/state/tab--1498284803" text="$:/core/ui/AdvancedSearch/Filter" />
<$action-setfield $tiddler="$:/temp/advancedsearch" text="""$filter$""" />
</$button>
\end
What it does:
* pass the desired filter syntax as a macro parameter
* create a button that displays the filter as normal text (no border/background)
* this button performs three actions:
1) open the $:/AdvancedSearch tiddler
2) select the "Filter" tab by setting the text of $:/state/tab--1498284803 to $:/core/ui/AdvancedSearch/Filter
3) set the text of $:/temp/advancedsearch to search for the desired filter syntax
To call the "filtersearch" macro from within your content, write something like:
This is some text to search for <<filtersearch "[tag[todo]]">> within this document
Note:
Step 2 references a specific "$:/state/tab" tiddler that includes a unique "magic number" which is generated by the <<qualify>> macro (see
https://tiddlywiki.com/#qualify%20Macro). I found the appropriate $:/state/tab tiddler by using the AdvancedSearch/Filter tab to search for "
[prefix[$:/state/tab]text[$:/core/ui/AdvancedSearch/Filter]]". This magic number should be the same for all TiddlyWiki documents that use the standard shadow definition for the $:/AdvancedSearch tiddler.
enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)