\define remove-from-begining-tiltle-bulk(myfilter, n:"0")<$list filter="[<__n__>] -0" variable=null><$list filter=<<__myfilter__>> variable="item"><$list filter="""[<item>split[]rest[$n$]join[]]""" variable="newTitle"><$list filter="[<newTitle>] -[has[title]] -[[]]" variable="ignore"> <$action-setfield $tiddler=<<item>> title=<<newTitle>> /> <$action-deletetiddler $tiddler=<<item>> /></$list> </$list></$list></$list>\end
a1
b1
cd
<$button> Do it<<remove-from-begining-tiltle-bulk myfilter:"[tag[xx]]" n:1>></$button>
I've been experimenting to try to figure out why this isn't working, but have not yet succeeded.
It seems that on the second pass through the inner list the filter is not detecting that we've already created a tiddler with the "1" title, so it goes ahead and creates another one that overwrites the first.
Note that I tried an alternative to your "[<newTitle>] -[has[title]] -[[]]" filter, using "[<newTitle>!is[tiddler]]" instead, but it had the same problem.
Hopefully, someone with a better understanding of the inner workings of TiddlyWiki will be able to explain the problem.
Mal
\define remove-from-begining-tiltle-bulk(myfilter, n:"0")
<$list filter="[<__n__>] -0" variable=null>
<$list filter=<<__myfilter__>> variable="item">
<$list filter="""[<item>split[]rest[$n$]join[]]""" variable="newTitle">
<$list filter="[<newTitle>] -[has[title]] -[[]]" variable="ignore">
<<actions1>>
<<actions2>>
</$list></$list></$list></$list>
\end
\define actions1()
<$action-setfield $tiddler=$(item)$ title=$(newTitle)$ />
\end
\define actions2()
<$action-deletetiddler $tiddler=$(item)$ />
\end
<$button> Do it
<<remove-from-begining-tiltle-bulk myfilter:"[tag[xx]]" n:1>>
</$button>
\define suffix-actions()
<$list filter="[tag[xx]suffix<sfx>]" variable="item">
<$action-setfield $tiddler=<<item>> title=<<sfx>> />
<$action-deletetiddler $tiddler=<<item>> />
</$list>
\end
\define makelink() [[$(newTitle)$]]
\define makeregexp() ^.{$(n)$}$(sfx)$$
\define generate-suffixes(myfilter, n:"0")
<$list filter="[<__n__>] -0" variable=null>
<$list filter=<<__myfilter__>> variable="item">
<$list filter="""[<item>split[]rest[$n$]join[]]""" variable="newTitle">
<$text text=<<makelink>>/>
</$list>
</$list>
</$list>
\end
\define deprefix-title(myfilter,num)
<$button>
Delete $num$ chars
<$vars n="$num$" >
<$wikify text="""<<generate-suffixes myfilter:"$myfilter$" n:"$num$">>""" name="outputs" output="formattedtext" mode="block">
<$list filter="[subfilter<outputs>]" variable="sfx">
<$list filter="$myfilter$ +[suffix<sfx>limit[2]count[]regexp[2]]" emptyMessage=<<suffix-actions>> variable="cnt">
</$list>
</$list>
</$wikify>
</$vars>
</$button>
\end
<<deprefix-title "[tag[xx]]" "1">>
<$list filter="$myfilter$ +[suffix<sfx>limit[2]count[]regexp[2]]" emptyMessage=<<suffix-actions>> variable="cnt">
\define makeregexp() ^.{$(n)$}$(sfx)$$
\define makelink() [[$(newTitle)$]]
<$text text=<<makelink>>/>
Mark
- what does the below line mean?
<$list filter="$myfilter$ +[suffix<sfx>limit[2]count[]regexp[2]]" emptyMessage=<<suffix-actions>> variable="cnt">
I don't understand the filter,how does it work?
- Seems the below macro is not needed
\define makeregexp() ^.{$(n)$}$(sfx)$$
- Why we need to makelink in
\define makelink() [[$(newTitle)$]]
and use it here:
<$text text=<<makelink>>/>
<$list filter="""[<item>split[]rest[$n$]join[]]""" variable="newTitle">
<$list filter="""[<item>split[]rest[$n$]join[]trim[]]""" variable="newTitle">
<$list filter="[[a string with spaces]split[]join[]]"/>
<$list filter="[[a string with spaces ]split[]join[-]]"/>
[[1111]split[]sum[]]
"1 1 1 1" +[sum[]]
Thank you for your help.
Mohammad
You need to pass named existing values to the new tiddler or treat the source tiddler as the template, I will try and share the code. Alternativly you can itterate all fields[] and transfer each field or selectivly.
I never quite suceeded in replicating and modifying the clone button.
I am currently finalising a new tiddler from template macro I can share soon.
Regards
Tony