Global Shortcuts and action Macro defined in other tiddlers

106 views
Skip to first unread message

Mohammad

unread,
Jun 19, 2019, 12:29:23 AM6/19/19
to TiddlyWiki




Macros defined outside a global keyboard-shortcut (through a tiddler tagged $:/tags/Macro) need to be imported in order to be accessible. The import pragma can be used for that

\import $:/core/ui/PageMacros [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]

If the tiddler that contains the macro definition is known and - for example - titled my-macro-tiddler

\import my-macro-tiddler



But it does not work!
Furthermore if a macro definea in a tiddler tagged with $:/tags/Macro why they should again imported using \import pragma?
What will be happened if the $:/tags/Macro removed and only \Pragma used?

Is there any example to give a try on this?


--Mohammad

TonyM

unread,
Jun 19, 2019, 12:59:27 AM6/19/19
to TiddlyWiki
Mohammad,

As I read it this is what it should read to be clearer.

Macros defined outside a global keyboard-shortcut (ie NOT through a tiddler tagged $:/tags/Macro) need to be imported in order to be accessible.

Your hunch is correct.

Regards
Tony

PMario

unread,
Jun 19, 2019, 4:05:52 AM6/19/19
to TiddlyWiki
On Wednesday, June 19, 2019 at 6:29:23 AM UTC+2, Mohammad wrote:
...
But it does not work!

"it" is not specific enough. ... IMO we could help if the line ends with ?
 
Furthermore if a macro definea in a tiddler tagged with $:/tags/Macro why they should again imported using \import pragma?
What will be happened if the $:/tags/Macro removed and only \Pragma used?

TW uses a lot of conventions. System tags like $:/tags/Macro is one of them. It is used in the PageTemplate tiddler. Which contains:

\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]   in the 4th line.

While PageTemplate is very early in the TW widget tree, there are still several elements outside. eg: the root-widget and the html "document" element, which is No 1. Global shortcuts are activated at TW startup at a time, where PageTemplate doesn't exist yet. .. So they are bound to the "document" element.

So if you use macros, that are defined outside the "global keyboard shortcut" tiddler, you'll need to import them. ... BUT be aware, that the line above, is very heavy weight, because it reloads ALL existing macros. ... So

\import my-macro-tiddler

is the better option here.
 
Is there any example to give a try on this?

"this" again not specific enough. this ... the global shortcut or this the \import pragma (which does work btw)

have fun!
mario

PMario

unread,
Jun 19, 2019, 4:33:19 AM6/19/19
to TiddlyWiki
Hi,

You can create 2 tiddlers A and B

A contains:

\import B

<<b>>

B contains

\define b() bbbbbb



have fun!
mario

BurningTreeC

unread,
Jun 20, 2019, 10:29:43 AM6/20/19
to TiddlyWiki
Hi there,

the global shortcuts don't have access to macro-tiddlers tagged $:/tags/Macro ... they do not. that's why we need to import such a tiddler so that a macro can be used

\import my-macro-tiddler at the top of the shortcut tiddler should be sufficient.

maybe there's a different problem with the import syntax or the imported macro

best wishes,
btc

Mohammad

unread,
Jun 20, 2019, 4:58:24 PM6/20/19
to TiddlyWiki
@Mario
Many thanks for clarification! I understood Keyboard shortcuts is one of the case has not access to $:/tags/Macro

@BTC
I will give another try to see how it works. 

--Mohammad
Reply all
Reply to author
Forward
0 new messages