Programmatic generation of macros

119 views
Skip to first unread message

TonyM

unread,
Oct 11, 2018, 9:44:22 PM10/11/18
to TiddlyWikiDev
Folks,

In a related endeavour to my post also today is there any method by which I can Programmatically generate of macros?

For example if a had a set of tiddlers prefixed $:/macrotranscludes/

eg {{$:/macrotranscludes/action-no}} containing something to do when "action-no" etc..

could I in some way "Dynamically" list and define the tiddlers such that the following macro's were generated and active?

\define action-no() {{$:/macrotranscludes/action-no}}
\define tiddler2() {{$:/macrotranscludes/tiddler2}}
\define tiddler3() {{$:/macrotranscludes/tiddler3}}

Thanks in advance
Tony

TonyM

unread,
Nov 19, 2018, 11:53:52 PM11/19/18
to TiddlyWikiDev
Bump,

No answer, so just started some further experimentation.

Its quite easy to build the text that would form a set of macro definitions. A single button could write this to a tiddler with the tag $:/tags/Macro

\define append-text(tiddlername totiddlername)
<$list filter="[[$tiddlername$]get[text]]" variable=line>
 
\define :<<line>>() {{<<line>>}}<br>
</$list>
\end
<<append-text Fromtid totid>>


Notice how I am considering creating macros with a leading: semi-colon.

Any other ideas?

Regards
Tony

bimlas

unread,
Nov 20, 2018, 10:17:26 AM11/20/18
to TiddlyWikiDev
It's not an answer, but maybe helps: https://tobibeer.github.io/tb5/#Ad-Hoc%20Macro

bimlas

unread,
Nov 20, 2018, 12:23:50 PM11/20/18
to TiddlyWikiDev
Another description, which may also be useful: https://tiddlywiki.com/#ImportVariablesWidget

By the way I tried to implement your idea, but I did not quite succeed: https://bimlas.gitlab.io/demo/tw5/generate-macros-by-tags.html

It seems that it's transcluding the tiddler at the definition, parsing it as HTML instead of "wiki-code".

bimlas

unread,
Nov 20, 2018, 2:26:00 PM11/20/18
to TiddlyWikiDev
Just played with nested macro definitions: https://bimlas.gitlab.io/demo/tw5/nested-macro-definition.html

If I could use variables in transclusion, I could modify https://bimlas.gitlab.io/demo/tw5/generate-macros-by-tags.html to let it work, but the macro is exists only "inside" wikify widget, you cannot acces it from outside.

TonyM

unread,
Nov 22, 2018, 7:15:52 AM11/22/18
to TiddlyWikiDev
Bimlas,

Thanks for the suggestions.

It seems to me the process to generate some macros may be an active process but the result needs to be a static tiddler, tagged for macros. Though I will keep looking for a hack. 

I interested in perhaps using the discovery of fields to generate macros by the same name, perhaps even build such a macro as the result of a wizard, eg define qualities of the field and capture it in macros for the fields later use.

Just experimenting

Tony
Reply all
Reply to author
Forward
0 new messages