list of tiddlers using a macro

101 views
Skip to first unread message

Matt4

unread,
May 3, 2018, 2:28:51 PM5/3/18
to TiddlyWiki
Is there a way to get a list of tiddlers that use a particular macro? Currently I'm searching for the first part of the macro (<<todo for example) in a tiddler and displaying the results that way but it seems in efficient. Ideally, I would like to list the parameters of each of those macros as well. 

So if I had a todo macro that looked like this <<todo "Ask question about TiddlyWiki">> I would want to get thetiddlers that used that macro and display the Ask question about TiddlyWiki portion of each of those uses. 

Matt

Thomas Elmiger

unread,
May 3, 2018, 5:33:12 PM5/3/18
to TiddlyWiki
Hi Matt,

Something like this could help (not really tested, make a backup first!) – this is from an older example I adapted for you:

Make a tiddler titled "todoMacroList" with this in it:

<$vars start="""<<todo""" end=""">>""">
<ul>
<$list filter="""[regexp:text<start>sort[]] -[[todoMacroList]] -[has[draft.of]]""">

<$link to=<<currentTiddler>>><<currentTiddler>></$link>

<$macrocall $name=extract start=<<start>> end=<<end>> limit="no" prefix="<li>" suffix="</li>">

</$list>
</ul>
</$vars>

===

You will need my extract macro for this:
https://tid.li/tw5/hacks.html#Extract%20Macro


Good luck!
Thomas

TonyM

unread,
May 4, 2018, 1:31:51 AM5/4/18
to TiddlyWiki
Mat,

Interesting you ask this. As a matter of practice writing macros I have started adding to tiddlers fields the following where a macro is defined

Field macro-macroname with the value containing the parameters in an example of using the macro.

We could also document the use of a macro with a field macrouse-macroname. The field value could document special use cases.

It is somewhat manual to do this however it could help while designing. You could also enhance a search to also create such fields when the macro is found.

I am tempted to document others macros this way. We can then use a field filter like has:field[macro-macroname] to locate there definition and parameters. Or use prefix[macrouse-macroname] to locate tiddlers using the macro.

Just some thoughts

Tony

Matt4

unread,
Jun 18, 2018, 6:51:06 PM6/18/18
to TiddlyWiki
I finally got around to trying your extract macro and after a few tries it worked out great! Thanks!

Matt
Reply all
Reply to author
Forward
0 new messages