TiddlyWiki5 icon indicating copy to clipboard operation
TiddlyWiki5 copied to clipboard

New in-tagtree-of filter operator to check if title is under a root tag

Open linonetwo opened this issue 3 weeks ago • 6 comments

Related:

  • kin filter https://github.com/TiddlyWiki/TiddlyWiki5/pull/3511
  • tagging tree https://talk.tiddlywiki.org/t/recursive-filter-operators-to-show-all-tiddlers-beneath-a-tag-and-all-tags-above-a-tiddler/3814

Just port it from https://github.com/tiddly-gittly/in-tagtree-of as I think it is useful when building cascade or fileSystemPath, to show panel under todo tree or move private todo to another folder.

Its performance is quite good on my large wiki.

Just make a PR in case you need it.

We should discard the core changes -- assuming you can make the plugin without them?

Or leave it to plugin and TidGi (which supports sub-wiki).

linonetwo avatar Dec 10 '25 15:12 linonetwo

Deploy Preview for tiddlywiki-previews ready!

Name Link
Latest commit 14d9a15d290fcb87a906ad114c503aa33e848a29
Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/693998f388a8110009ee0392
Deploy Preview https://deploy-preview-9485--tiddlywiki-previews.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Dec 10 '25 15:12 netlify[bot]

Confirmed: linonetwo has already signed the Contributor License Agreement (see contributing.md)

github-actions[bot] avatar Dec 10 '25 15:12 github-actions[bot]

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2447.2 KB
PR 2451.1 KB

Diff: ⬆️ Increase: +3.9 KB


✅ Change Note Status

All change notes are properly formatted and validated!

📝 $:/changenotes/5.4.0/#9485

Type: feature | Category: filters Release: 5.4.0

Add new in-tagtree-of filter operator

🔗 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9485

👥 Contributors: linonetwo


📖 Change Note Guidelines

Change notes help track and communicate changes effectively. See the full documentation for details.

github-actions[bot] avatar Dec 10 '25 15:12 github-actions[bot]

You did describe the usecase with:

... as I think it is useful when building cascade or fileSystemPath, to show panel under todo tree or move private todo to another folder.

  • How exactly does it make cascade filters easier?
  • Are there other usecases?

The first thing that came into my mind was: "Can it help me to auto-expand the TOC to find a focused tiddler?"

pmario avatar Dec 10 '25 17:12 pmario

auto-expand the TOC to find a focused tiddler?

Of course (with JS), on focusedTiddler change, loop check each in-tagtree-of[visible folder], I don't know how to do it with wikitext in a minute.

Well, I think it used mostly in sub-wiki feature. Which might also work in MWS to decide which bag should a tiddler belongs to.

Thanks for review, while I think we might not accept this, because there are too few tiddlywiki's heavy user, so MWS user will be even smaller, so the need to separate public and private data is a even niche feature.

linonetwo avatar Dec 11 '25 06:12 linonetwo

I think there is a bug: [[build]in-tagtree-of[Commands]] should return build, but it returns an empty list. So there may be something wrong with the recursion mechanism.

pmario avatar Dec 11 '25 09:12 pmario

截屏2025-12-13 12 46 20 @pmario build is its caption, not title.

And I think name in-tagtree-of might be too long.

linonetwo avatar Dec 13 '25 04:12 linonetwo

Thanks @linonetwo, this is an interesting idea. Fundamentally, I'd prefer to see this functionality in wikitext, but recognise that there are many algorithms where JS can be significantly more performant. I also see several important use cases for the proposed operation, and so think that this is worth discussing.

A middle path we could pursue might be to explore whether there are even more fundamental wikitext enhancements that would improve performance for this use case, and for other related use cases. A fairly obvious example would be exploring means to improve the performance of iterating over the tiddlers within a TOC. It would probably be useful to have a way to short circuit evaluation of particular subtrees.

Perhaps it may even be possible to draw out an even lower level primitive: a general means to iterate through a data structure by specifying the functions for processing each node, and for navigating to the next node. That would then make a good basis for exploring ways to optimise function invocation, which would be beneficial across the system.

Jermolene avatar Dec 13 '25 10:12 Jermolene

And I think name in-tagtree-of might be too long.

I think it's OK. IMO [[BuildCommand]in-tagtree-of[Commands]] is a very clear filter. We do not have many filters, which really make it clear what it does.

I think in-tree-of could be an option, if a future suffix with in-tree-of:field-name[??] -- Where the field would need to be tag-like, which my rewritten TOC procedures would allow.

pmario avatar Dec 13 '25 16:12 pmario

I'd prefer to see this functionality in wikitext, but recognise that there are many algorithms where JS can be significantly more performant.

The main problem at tw-com is, that there are several tiddlers which have the same tag. So there are physically multiple tag-trees active at the same time.

With wikitext we need "recursion protections" using the excluded-variable. The code is relatively complex. In JS it's relatively easy to "follow" 2 or more tag-trees if needed.

pmario avatar Dec 13 '25 16:12 pmario

iterating over the tiddlers within a TOC

I thought we don't have existing feature like this.

auto-expand the TOC to find a focused tiddler?

I will take time to implement this as another PR to show use case of this filter, so folder could expand like VSCode does. I will convert current PR to draft as it is not urgent, we have plugin version of it.

linonetwo avatar Dec 13 '25 16:12 linonetwo