remove a tag from a list of tiddler

102 views
Skip to first unread message

vpl

unread,
Mar 6, 2020, 3:41:49 AM3/6/20
to TiddlyWiki
Hi,

I can't find on the group a way to remove a tag from a list of tiddlers that I would have filtered (based on another tag)

I have a list of tiddlers that are tagged with "tag-a" and "tag-b"
Some of them are tagged also with "tag-x"
I want to filter all tiddlers containing "tag-a" and remove, from these tiddlers their "tag-x", but keep the "tag-b" when present

Any idea how to do that ?

I had the idea to combine a list with a <$action-deletefield>
but this may delete all the tags of a given tiddler.
What I want is just remove the tag-x ..

Thanks a lot for your help

Regards

Luis Gonzalez

unread,
Mar 6, 2020, 5:16:25 AM3/6/20
to TiddlyWiki
The macro:

\define remove_tag(filter_tag remove_tag)

<$button>

<!-- We filter tiddlers with tag "filter_tag"-->
<$list filter="[tag<__filter_tag__>]" variable="deleteTiddler">

<!-- With each tiddler of this list (stored in "deleteTiddlers" variable) -->
<$fieldmangler tiddler=<<deleteTiddler>> >

<!-- We remove the tag "remove_tag" from each tiddler of the list -->
<$action-sendmessage $message="tm-remove-tag" $param=<<__remove_tag__>>/>
</$fieldmangler>
</$list>
remove ''<<__remove_tag__>>'' from ''<<__filter_tag__>>'' tagged tiddlers
</$button> 

\end

You call this macro this way:

<<remove_tag tag-a tag-x>>

With this code you remove tag-x from all tiddlers tagged with tag-a.

vpl

unread,
Mar 6, 2020, 5:56:29 AM3/6/20
to TiddlyWiki
Hi,

Thanks a lot for your quick reponse

I've tested and the button does not appear within the macro
So I externalized and left the macro alone as below, but this does not work
How may I trouble shoot or log what's happening during the execution of the macro  ? I'm blocked ..

Thanks for your help


\define remove_tag(filter_tag remove_tag)
<!-- We filter tiddlers with tag "filter_tag"-->
<$list filter="[tag<__filter_tag__>]" variable="deleteTiddler">

<!-- With each tiddler of this list (stored in "deleteTiddlers" variable) -->
<$fieldmangler tiddler=<<deleteTiddler>> >
<!-- We remove the tag "remove_tag" from each tiddler of the list -->
<$action-sendmessage $message="tm-remove-tag" $param=<<__remove_tag__>>/>
</$fieldmangler>

</$list>
\end

<$button actions=<<remove_tag tag-a tag-x>>>remove tag </$button>

Luis Gonzalez

unread,
Mar 6, 2020, 7:21:03 AM3/6/20
to TiddlyWiki
If you copy your macro to an independent tiddler remember tag it with "$:/tags/Macro".

Look at this little Tiddlywiki I add.
empty.html

vpl

unread,
Mar 6, 2020, 8:27:05 AM3/6/20
to TiddlyWiki
And this works !!! Fantastic !
Thanks so much

And here I have a clear documented example of macro ;;

Really appreciated

Thanks a lot
Vpl

TonyM

unread,
Mar 6, 2020, 7:03:53 PM3/6/20
to TiddlyWiki

Bulk actions with buttons (previously shared)


Very easy and exposes a valuable piece of tiddlywiki knowledge worth learning.


As you may know, on tiddlywiki.com the following produces a list of tiddlers;

<$list filter="[tag[Field Operators]]">

</$list>



you can use any filter to generate this list


Now we can look for an action that will open tiddlers eg; https://tiddlywiki.com/#ActionNavigateWidget We wrap it in a button so we can trigger this action We wrap the action in the list so we can execute that action for every tiddler generated by the list Since there is no variable= on the list widget the currentTiddler variable changes for each item in the list so the default of currentTiddler is used. Since we did not provide the $to= parameter in the action-navigate it defaulted to currentTiddler

<$button>
   <$list filter="[tag[Field Operators]]">
      <$action-navigate $to="ActionWidgets"/>
   </$list>
Click me!
</$button>

<$list filter="[tag[Field Operators]]">

</$list>


Why should you learn this deeply?,
it opens up any list to activate any action on every tiddler in the list.
  • delete a tag
  • remove a tag
  • delete a set of tiddlers
  • more more more

Warning

Always consider showing the list of tiddlers to be impacted by the button with a seperate list as I have done above

Regards

Reply all
Reply to author
Forward
0 new messages