Is it possible to edit a macro def but keep the same content?

I want to add several actions into the save-tiddler-actions macro found inside $:/core/ui/EditTemplate.

I know that I could clone the whole tiddler and edit the macro, and override the default tiddler with my version, but if the core get an update I will need to do it again. I tried to import the macro defs with an import pragma and override the save-tiddler-actions, then transclude the content of the $:/core/ui/EditTemplate minus the macro defs with a pragma (to keep my override), but it didnt work. Is that possible ?

Here’s my (failed) attempt :

\import [[$:/core/ui/EditTemplate]]
\define save-tiddler-actions()
<!-- reuse the default actions -->
<<save-tiddler-actions>>
<!-- new actions -->
<$action-sendmessage $message="tm-add-tag" $param="test"/>
\end

$$text/vnd.tiddlywiki
\rules except macrodef
{{$:/core/ui/EditTemplate}}
$$

Use this pattern:

\define save-edit-node-actions()
\import [[$:/plugins/sq/streams/action-macros]]
<!--  extra actions here-->
<<save-edit-node-actions>>
\end
1 Like

Ok so I did this :

Thanks to your help I managed to update the content of the macro macro-tiddler-A, but do you know if it is possible to also update the macro inside the transclusion in tiddlerB ? I’m trying to get this result :

EDIT: Another way to put it : with the import pragma, we can import all the macro / variable from a tiddler, without the text content of this tiddler. To achieve what I’m trying to do I think I need the reverse : import the text content of a tiddler, without the macro / variable def. That way it would be easy to reuse the content of any tiddler !

If it’s not currently possible, maybe the upcoming parametric transclusion could do that ?

Perhaps you could wikify the “target tiddler” and display that in the display tiddler. However it will use the macros defined in the “target tiddler”.

  • You could clone it and remove the definitions.

The import pragma is very powerful, its features have not been revealed. I used this approach for overriding a macro! Sometimes ago I tried to see how can I implement OOP using Tiddlywiki and this is very powerful.


@Mohammad The import variables widget prevent the override the same way transcluding a tiddler does, that’s the issue :confused: The problem is that a lot of system tiddlers are defining variables and macro with \define pragma, then in the same tiddler there is wikitext that uses these variables and macro.

Overriding one of these macro/variables and re-using the wikitext from one of these tiddlers doesnt seem to be possible … but it would allow an user to customize a system tiddler and keep it up to date automatically (unless the variables name are modified of course).

@TW_Tones using wikify might work, it’s not the best for performance but I will try this !


EDIT: it worked !

Here’s the solution, using wikify :

\import [[One]]
\define A()
\import [[One]]
<<A>> + new content
\end

<$wikify name="content" text={{{ [{One}] +[split[\end]last[]] }}} type="text/vnd.tiddlywiki" mode="block" output="html">

<<content>>

</$wikify>

OverrideSpecificMacro.json (586 Bytes)

Several caveats : Macro def needs to end with “\end”, the wikify widget could slow down the wiki. But at least this is possible … Hopefully someone could provide a better solution without wikify.

Thanks @TW_Tones ! If there is no other way to do this without wikify I’ll mark your comment as Solution :slight_smile: