Global Macros

401 views
Skip to first unread message

Jan Johannpeter

unread,
Mar 17, 2017, 6:15:31 AM3/17/17
to TiddlyWiki
Hello,
I got a question regarding global macros:
I learned he way make a macro work throughout the hole wiki is tagging the containing Tiddler $:/tags/Macro, which means that all macros defined there will be global.
I most cases I just need one expression to work in other tiddlers but sometimes also quite a lot of steps (also defined as macros) to reach this goal.
Is there a way of preventing these form beiing global macros? The question is important because i would have to change my naming strategy to find unique names for the steps.

Yours Jan



Jed Carty

unread,
Mar 17, 2017, 7:18:02 AM3/17/17
to TiddlyWiki
I am not aware of a way to do this. 

It may not be appropriate for your situation, but my method of getting around this is to prefix the names for all of the macros that aren't mean to be globally available with the name of the global macro. So if I have a global macro CurrentInvoiceTitle that returns something like 'Robbie Roybut - OokTech - 17 March 2017' that has a macro to get the project name (Robbie Roybut), the company name (OokTech) and the current date (17 March 2017) I would name the helper macros CurrentInvoiceTitleGetProjectName, CurrentInvoiceTitleGetCompanyName and CurrentInvoiceTitleGetCurrentDate

This is much easier because I use an external text editor for most of my work.

FrD

unread,
Mar 17, 2017, 8:34:30 AM3/17/17
to TiddlyWiki
Hi Jan,

Have a look at http://tiddlywiki.com/#ImportVariablesWidget
I've done a test with a TW of mine :
- Put all the "steps" (macros you don't intend to share at the global level) in a tiddler named for instance "StepsMacros" (don't tag it with $:/tags/Macro)
- Put your global level macro, say "MyGlobalMacro", in another tiddler tagged with $:/tags/Macro)
- Modify this macro by inserting just after the \define :
<$importvariables filter="[prefix[StepsMacros]]">
- Don't forget to insert before \end :
</$importvariables>

It seems to work on my test file. I don't know if it's intended to work this way ...

Regards

FrD

Jan

unread,
Mar 19, 2017, 5:13:59 PM3/19/17
to TiddlyWiki
Hello Jed, Salut FrD
Thanks for your help, especially the ImportVariablesWidget seems to be the solution.
I had solved this more trivial by transcluding the function into the Tiddler. I guess I made the macros global macros that way...I got to checkt this.

Thanks Jan


--
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 post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f3bf4dd2-a526-4323-9b02-b3931e4afe00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages