Hi,
is it possible to access the overwritten macro from inside an overwriting macro?
Thanks,
Mirko
Hi,
is it possible to access the overwritten macro from inside an overwriting macro?
Thanks,
Mirko
What do you mean by “access”. What do you want to access?
Its possible… but it’s ugly.
Let’s say you have a tiddler “MacroADefinition”, tagged with $:/tags/Global (so it’s available to other tiddlers), in which you write:
\define macroA(x,y) <<__x__>> is <<__y__>>
<$let originalMacroA=<<macroA>>/>
Basically, you have to “save” the original macroA definition in a variable with a different name so you can invoke it later on using that variable name. Then, in some other tiddler, “AnotherMacroADefinition”, you can write:
\define macroA(x,y)
something else here<br>
<<originalMacroA $x$ $y$>>
\end
<<macroA foo bar>>
The resuting output will be:
something else here
foo is bar
Like I said… it’s UGLY.
-e
I can’t think of an easy way. Perhaps one of the core team can.
Presumably something like this (untested) plain JS override:
((original) => {
window.console = {
...original,
log: (msg, ...msgs) => original.log(Object(msg) === msg ? JSON.stringify(msg, null, 4) : msg, ...msgs)
}
})(console)
Here our overridden console.log maintains a reference to the original console.log method and uses it, even while providing an altered interface.
Right, that is ugly. And I would expect that the desire would be to use this to override core macros… without altering those core macro tiddlers directly. This doesn’t allow for that. I’m wondering (and don’t have the time to test now) if that second definition could be in still a different tiddler, imported into our overriding one, so that we don’t have to override the core tiddler. I’m pretty sure it can’t be in the macro overriding tiddler, as we can’t wrap pragmas inside something like <$let> widgets. I hope I have time to investigate this evening.