Applying tags to a list of tiddlers?

103 views
Skip to first unread message

stefano franchi

unread,
Feb 17, 2019, 2:56:49 PM2/17/19
to tiddl...@googlegroups.com
How can I select a list of tiddler with a filter and then set their tags to some array of my choice?

I thought I could use the ActionSetFiled widget like:
<$ActionSetField $filter="MY_FILTER"  tags="NewTag1 [[Another New Tag]]" />

but I discovered the $ActionSetField does not have an $filter option. How do I loop over the results of a filter?


Cheers,

S.
--
__________________________________________________
Stefano Franchi

stefano...@gmail.com
http://stefano.cleinias.org

Mat

unread,
Feb 17, 2019, 3:18:41 PM2/17/19
to TiddlyWiki
Hi Stefano. BatchManipulator was created for batch ops like this. 

<:-)

stefano franchi

unread,
Feb 17, 2019, 3:26:58 PM2/17/19
to tiddl...@googlegroups.com
On Sun, Feb 17, 2019 at 2:18 PM Mat <matia...@gmail.com> wrote:
Hi Stefano. BatchManipulator was created for batch ops like this. 


Thanks Mat, that looks like a great tool. I am already playing with it. I would also like to understand how to do it in TW code, though, as I am trying to learn the ropes of TW. Perhaps you'd be kind enough to show me how it's done?

Cheers,

S.

bimlas

unread,
Feb 17, 2019, 4:22:48 PM2/17/19
to TiddlyWiki
Stefano,

TW-Commander worth a try as well: https://github.com/kookma/TW-Commander

stefano franchi

unread,
Feb 17, 2019, 4:40:28 PM2/17/19
to tiddl...@googlegroups.com
Hi Lazlo,

I was indeed looking at the Commander code, but I am still such a newbie with TW that I don't know how to use it. In particular, this bit seems to be all I need:

\define add-new-tag-bulk(newTag)
<$list filter={{$:/temp/commander}}>
<$fieldmangler>
<$action-sendmessage $message="tm-add-tag" $param=<<__newTag__>> />
</$fieldmangler>
</$list>
\end

Not completely sure how it works yet, but working on it...


Cheers,

S.

On Sun, Feb 17, 2019 at 3:22 PM bimlas <bimba....@gmail.com> wrote:
Stefano,

TW-Commander worth a try as well: https://github.com/kookma/TW-Commander

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/360fac05-f3c4-4151-8af8-077841eb77a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad

unread,
Feb 17, 2019, 5:02:04 PM2/17/19
to TiddlyWiki
Hi Stefano,
 This is Mohammad the Commander author!

Here is for you, a macro to add many tags you like to a list of tiddlers as batch operation. 




\define add-new-tag-bulk(filter, newTags)
<$list filter="$filter$" >
<$list filter="[enlist<__newTags__>]" variable="itemTag">
<$fieldmangler>
<$action-sendmessage $message="tm-add-tag" $param=<<itemTag>> />
</$fieldmangler>
</$list></$list>
\end




To test, create a tiddler in Tiddlywiki.com
name it as you like and tagged it as $:/tags/Macro

In another tiddler test it as below

<$button> do
<$macrocall $name="add-new-tag-bulk"
filter="[tag[About]]"
newTags="bb cc dd [[mytag with space]]"

/>
</$button>

This changes the tags of all tiddlers tagged with About to 
bb, cc, dd and "tag with space".

Hopefully these features will be available in Commander.


Cheers
Mohammad

Brian Theado

unread,
Feb 17, 2019, 5:05:35 PM2/17/19
to tiddl...@googlegroups.com
Stefano,

I think the action-listops widget (https://tiddlywiki.com/#ActionListopsWidget) will help you. It can be used to manipulate any tiddler field which is used as a list. The tags field is used as a list so it should be able to help.

For performing the operation on multiple tiddlers, you would need to put the action-listops inside a list widget (since it only operates on a single tiddler).

I found the documentation a little confusing. Maybe this will help you:
  • Use the $filter attribute to replace the field contents with the result of $filter
  • Use the $subfilter attribute to transform the current field contents
  • Use the $tags attribute as shorthand for $subfilter + $field=tags

I've seen some responses recommending the use of tm-add-tag widget message. I'm not really sure in what cases tm-add-tag is better than action-listops or vice versa.

Brian

Jed Carty

unread,
Feb 17, 2019, 5:07:11 PM2/17/19
to TiddlyWiki
As an explanation of what is going on (node the added button, this doesn't do anything with the button):

<$button>
Add tags
<$list filter=<<SomeFilterHere>>>
<$fieldmangler>
<$action-sendmessage $message="tm-add-tag" $param=<<__newTag__>> />
</$fieldmangler>
</$list>
</$button>

The list widget makes a list, one way to think about it is as iterating over a loop, but if you are familiar with some programming it is more accurately list comprehension similar to python (I think also erlang and haskell, it has been a while. Many other languages probably use the same concept).

So a possibly way too detailed description of the list widget:

The filter creates a list of titles
The template between the opening and closing tags for the $list widget is applied to each title returned by the filter
The results are output in the same order as the titles in the list

The $fieldmangler widget is magic, it is mostly left over from a previous version of how we thought tiddlywiki was going to work. Mostly it lets you add tags without overwriting the tags field. This is the only time when it is required or that there isn't a simpler way to do it. The magic is that it lets you edit fields, but that was before the action widgets became the main tool for changing tiddlers so it is less useful now.

The $action-sendmessage widget is a way that the older message-based changes to the wiki are used with the newer action widgets. It was a more conceptually complex system, I suggest that you just accept the magic for now and come back to that part later. Just treat the combination of $fieldmangler and $action-setfield widgets in this context like an action widget that lets you add a tag to a tiddler.

Then, if you wrap that whole thing in a button, the result is a button that activates a list of action widgets, each action widget adds a tag to one tiddler.

Hopefully that is understandable and not too rambling.

stefano franchi

unread,
Feb 19, 2019, 9:56:38 AM2/19/19
to tiddl...@googlegroups.com
Thanks to everyone for the help.
The analogous of list comprehension is exactly what I I was looking for and I had missed the  $fieldmangler  widget plays.
Things are slowly starting to become clearer...

Cheers,

S.


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages