It would be nice to have a reverse function of enlist that would take a list of titles and output a single title for enlist to act upon it ad returns the original list.
It would allow to pass a list of titles as a single arguments. If there is no space in the titles, one could use join[ ] as a substitute but in many a case there will be spaces!
I have been able to have this functionality with a function. See below and after that, my comments.
\function .prepareTitle()
=[charcode[91],[91]]
[all[]]
=[charcode[93],[93]]
+[join[]]
\end
\function .tolist()
[all[]]
:map[search:title:literal[ ]then<.prepareTitle>else<currentTiddler>]
+[join[ ]]
\end
\define importTitles()
<$let those={{{
[tag{!!tagged}]
+[dump[ball tagged]]
+[.tolist[]]
}}}
>
<$action-setfield got=<<those>>/>
</$let>
\end
<label>tag to be looked for <$edit-text field=tagged/></label>
<$button actions=<<importTitles>>>import titles with that tag</$button>
into field "got": <$view field=got/>
This function works nicely BUT it needs an auxiliary function. If I tag $:/tags/Macro the above tiddler, it will also export that one. I can setup an other tiddler to just import that auxiliary function but it’s a bit tedious. If anyone is able to make it without an auxiliary function, let they show it!
BTW it’s a bit awkward to export function by tagging $:/tags/Macro . Sure, it does the job. But it would have been a perfect fit to tag $:/tags/Function instead (both macros could be used at the same time.
I have found this issue using the new functions which I love. Sometimes I want them to return a list but the rules only return the first item. So if you want to return a single string use +[join[ ]] which is a great way to concatenate various values into a readable string such as tooltip.
However as requested and suggested by @saqimtiaz it you want to retain a list of titles in the variable and or function use format:titlelist[]join[ ]]. You will have to use an enlist it to get the titles back out, but you could even pass the whole list as a parameter or a variable.
I think you will find any of the global tags, SystemTag: $:/tags/Global
SystemTag: $:/tags/Global/View SystemTag: $:/tags/Global/View/Body $:/tags/Macros all do “effectively” the same thing, for defines, functions procedure even custom widgets.
The “enlist” documentation should point to that functionality to help out fellow coders. This could indeed be a documentation pattern: for any help, point out related items. the reverse of a function in particular.
I’ve come to a decision on that. \define isn’t going anywhere. I have probably a few thousand \defines to wade through – frankly, too many to take that approach. My decision, for what it’s worth, if I don’t need nesting, if I’m making significant use of substitution, they’re staying just as they are.
New code, that’s different. \procedure is my new BFF.
I can’t really see in the doc what it does better than \define. Except using the \parameters pragma. But the loc don’t really show why it would be such a great feature. If I understand your intent correctly, the combination of the two works better if I use functions (defined by \function) in my filter? And again, how’s that?
Also’ in the " Macro Definition Syntax" there is no mention of \procedure.
I thnk, however, that it would probably better to have a new topic for that. So if you want to contribute, join me on the “\procedure vs \define” please.