Hi Tones

Thank you for your solution! That solution in TW-Scripts actually belongs
to Eric and based on the question and answer I kept the
original one! Yes, we can improve or add another one with your name and
based on this thread!


Best wishes
Mohammad


On Sun, Jun 6, 2021 at 4:02 AM TW Tones <anthony.mus...@gmail.com> wrote:

> Mohammad,
>
> As a community we are so grateful for your publishing and documentation.
> Shiraz as an example is a substantial resource.
>
> I would like to help, extend your great content a little further and make
> it even more useful If I can so humbly suggest a few things
>
> For example I looked at
> https://kookma.github.io/TW-Scripts/#Add%20Remove%20Tags%20Using%20ActionListops
>
> Some issues
>
>    - To set the tiddler programaticaly including the currentTiddler the
>    $macrocall form may be necessary
>    - The current tiddler is not the default
>    - Since you have to provide the tags but you could default to the
>    current tiddler put the tags as parameter 1 and 2
>    - You always have to provide the tiddlername
>
> This is my refactored code
> \define add-remove-tags(oldTag, newTag, tiddler)
> <$set name=tiddler value="$tiddler$" emptyValue=<<currentTiddler>> >
> <$button tooltip="Add '$newTag$' tag and Remove '$oldTag$' tag.">
>   Change ''$newTag$'' to ''$oldTag$''
>   <$action-listops $tiddler=<<tiddler>> $field="tags"
> $subfilter="[[$newTag$]]" />
>   <$action-listops $tiddler=<<tiddler>> $field="tags"
> $subfilter="-[[$oldTag$]]" />
> </$button>
> </$set>
> \end
> <<add-remove-tags a b>>
> <<add-remove-tags b a>>
>
> SO this is the difference
>
>    - << add-remove-tags a b>> will operate on the current tiddler
>    - the tiddler can be provided optionally.
>
> It is my approach to always write macros for the current tiddler by
> default, this means they remain valid inside lists and edit/view templates
>

Yes, nice! If you search the TW-Script, you see such a solution which is
documented in your name!



>
>    - I just reused the name $tiddler$ to Create <<tiddler>> with
>    emptyValue <<currentTiddler>>
>    - When you have replaceable values you can make a* detailed tooltip*
>    and keep the* button name shorter.*
>    - The button is a user function description rather than detailing what
>    happens, the tooltip does that.
>
>
We can add more examples to have such options!




> Regards
> Tones
>
> On Sunday, 6 June 2021 at 02:23:08 UTC+10 Mohammad wrote:
>
>> It's a bit complicated! but it works!
>>
>> have a look at TW-Scripts for example
>>
>>
>> https://kookma.github.io/TW-Scripts/#Add%20Remove%20Tags%20Using%20ActionListops
>>
>>
>>
>> Best wishes
>> Mohammad
>>
>>
>> On Sat, Jun 5, 2021 at 7:56 PM Charlie Veniot <cj.v...@gmail.com> wrote:
>>
>>> Nah, I didn't consider that because the particular TiddlyWiki instance
>>> I'm working with I've setup with only single-word tags.
>>>
>>> So no, that particular code sample was not designed for a tag with words
>>> separated by spaces.
>>>
>>> To handle any multi-word tag with spaces between the words:
>>>
>>> \define doIt()
>>> <$vars ldb="[["
>>>               rdb="]]">
>>> <$list variable="thisTiddler" filter="[tag[A]]">
>>> <$action-setfield $tiddler=<<thisTiddler>> $field="tags" $value={{{
>>> [<thisTiddler>tags[]addprefix<ldb>addsuffix<rdb>join[ ]]
>>> [[mot]addprefix<ldb>addsuffix<rdb>] +[join[ ]] }}}/>
>>> </$list>
>>> </$vars>
>>> \end
>>>
>>> <$button actions=<<doIt>>>
>>> Tag Em
>>> </$button>
>>>
>>> I've also wrapped the new tag (hard-coded in my code sample as "mot")
>>> with double-brackets, so that if you replace "mot" with a
>>> multi-word-separated by spaces tag, the code still works otherwise as-is.
>>> (in the case of a single-word, or CamelCase word, TiddlyWiki will ignore
>>> the double-brackets.)
>>>
>>> If you want to make the actions macro more generalized, then you'll want
>>> to add a parameter (newTag?), and then replace "mot" with "$newTag$", I
>>> think without trying it.
>>>
>>>
>>> On Saturday, June 5, 2021 at 6:33:51 AM UTC-3 Mohammad wrote:
>>>
>>>> Does this work if you want to add [[newTag from code]]?
>>>> Or if the tiddlers already have a tag with space in the title?
>>>>
>>>>
>>>> Best wishes
>>>> Mohammad
>>>>
>>>>
>>>> On Sat, Jun 5, 2021 at 10:01 AM Charlie Veniot <cj.v...@gmail.com>
>>>> wrote:
>>>>
>>>>> G'day,
>>>>>
>>>>> I'm refactoring the design on a TiddlyWiki project, and wanted to
>>>>> apply tag changes to batches of tiddlers.
>>>>>
>>>>> In case of any interest, here's the related code pattern:
>>>>>
>>>>> \define doIt()
>>>>> <$list variable="thisTiddler" filter="[tag[A]]">
>>>>> <$action-setfield $tiddler=<<thisTiddler>> $field="tags" $value={{{
>>>>> [<thisTiddler>tags[]] [[mot]] +[join[ ]] }}}/>
>>>>> </$list>
>>>>> \end
>>>>>
>>>>> <$button actions=<<doIt>>>
>>>>> Tag Em
>>>>> </$button>
>>>>>
>>>>> Cheers !
>>>>>
>>>>> --
>>>>> 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 view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/tiddlywiki/9b84cbd5-ce87-4611-a180-4dccaf611061n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/tiddlywiki/9b84cbd5-ce87-4611-a180-4dccaf611061n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/tiddlywiki/832ea5f8-e467-4e28-8785-a58ccb02562en%40googlegroups.com
>>> <https://groups.google.com/d/msgid/tiddlywiki/832ea5f8-e467-4e28-8785-a58ccb02562en%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/c0c8ce7b-e367-4216-a507-764c1fdcccb4n%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/c0c8ce7b-e367-4216-a507-764c1fdcccb4n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMDdRfFepd_jeMxAeYGMeuHXnzksHb-eiwhDNLQ-gYFo-w%40mail.gmail.com.

Reply via email to