TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.03k stars 1.19k forks source link

[IDEA] Use of Modern Filter with $:/Advanced Search Through Predefined Filters #7196

Open kookma opened 1 year ago

kookma commented 1 year ago

Is your feature request related to a problem? Please describe. I wish to retrieve all tiddler titles in a TOC tree through $:/AdvancedSearch -> Filter

Describe the solution you'd like From TW 5.1.23 we have some modern filter operators and filter run prefixes can perform complex operations. To use the full power of these features in predefined filters (tagged with $:/tags/Filter) you may need to use variables.

There is a solution for rederiving all tiddler titles in a TOC tree in https://talk.tiddlywiki.org/t/filter-question-return-all-toc-tiddler-titles-as-a-plain-list/5752/10 proposed by @yaisog. This solution needs variables in filter.

A problem Is it possible to have the variables in tiddler defines this filter and is tagged with $:/tags/Filter? One may define all variables in a tiddler tagged $:/tags/Macro

Code and demo

  1. download list-all-toc-tree.zip
  2. drag and drop https://tiddlywiki.com
  3. Open $:/AdvancedSearch -> Filter -> Dropdown and select List TOC tree tiddlers

Here I used both tags $:/tags/Macro and $:/tags/Filter on the same tiddler, but this makes the variables global (not good)

Jermolene commented 1 year ago

Hi @kookma it would indeed be useful to have something like the kin operator in the core. My preferred route is not just to provide a special operator for treewalking, but to extend the filter syntax so that it is straightforward and safe to write recursive functions. Thus, I think the first step is actually the implementation of user defined functions in #6666. That gives us named functions with named parameters, which are the building blocks of recursion in functional languages.

I appreciate that in the meantime you are asking for an extension to the advanced search canned filter system to permit named variables to be specified for the filter. There may be a useful feature along those lines, but I think the development needs to be driven by more diverse use cases than this. The implementation in the thread is breathtakingly clever, but it is not clear that it is representative of the filters that users would ordinarily encounter.

kookma commented 1 year ago

Thank you for clarification @Jermolene It seems having a core recursive filter and merging #6666 will bring us many flexibilities. In addition to kin I saw in the forum a recursive filter has been developed by @yaisog (see https://talk.tiddlywiki.org/t/recursive-filter-operators-to-show-all-tiddlers-beneath-a-tag-and-all-tags-above-a-tiddler/3814).