currentTiddler as a macro parameter default

373 views
Skip to first unread message

Rustem

unread,
May 5, 2015, 4:10:45 AM5/5/15
to tiddl...@googlegroups.com
How can I pass `<currentTiddler>` or a field as a default value for a macro parameter?

Thanks.
--R

Måns

unread,
May 5, 2015, 4:41:53 AM5/5/15
to tiddl...@googlegroups.com
Hi Rustem

Example taken from : [[$:/core/ui/Buttons/clone]]

<$button message="tm-new-tiddler" param=<<currentTiddler>>  .....

Cheers Måns Mårtensson

R

unread,
May 5, 2015, 10:40:15 AM5/5/15
to tiddl...@googlegroups.com

Thank you. I'm getting thoroughly confused with all different kinds of bracketing in TW5.

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/l-Yx8WOJtxA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/dd120965-9281-4e41-9eeb-484333a43cbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

R

unread,
May 5, 2015, 10:44:28 AM5/5/15
to tiddl...@googlegroups.com

Sorry, I actually meant macro definition, not invocation. I'll try this, see if it works.
\define x(y:<<currentTiddler>>)

On May 5, 2015 1:41 AM, "Måns" <huma...@gmail.com> wrote:
--

Jeremy Ruston

unread,
May 5, 2015, 2:00:02 PM5/5/15
to TiddlyWiki
Hi Rustem

The default values for macro parameters can only be specified as literal strings, I'm afraid. Can you expand on the situation, perhaps I can advise on alternatives?

Best wishes

Jeremy.


--
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 http://groups.google.com/group/tiddlywiki.

For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Rustem

unread,
May 5, 2015, 2:32:28 PM5/5/15
to tiddl...@googlegroups.com, jeremy...@gmail.com

Gladly! I have a tree macro, I made it parameterized on purpose, so I could display any tree from any tiddler. Then I thought it wold be nice if I could invoke it without a parameter, when I want to display the tree originating from the current tiddler.

\define _ra_treeN(node) 

;[[$node$]] 
:<$macrocall $name=_ra_tree node="$node$"/> 
\end 

\define _ra_tree(node) 
<$tiddler tiddler="$node$"> 

<$list filter="[<currentTiddler>tagging[]!<currentTiddler>!tag[$:/_ra/tags/Bookmark]!tag[$:/_ra/tags/Archive]!nsort[score]]"> 

  <$macrocall $name=_ra_treeN node={{!!title}}/> 

</$list> 
\end

Eric Shulman

unread,
May 5, 2015, 2:40:13 PM5/5/15
to tiddl...@googlegroups.com, jeremy...@gmail.com
On Tuesday, May 5, 2015 at 11:00:02 AM UTC-7, Jeremy Ruston wrote:
The default values for macro parameters can only be specified as literal strings, I'm afraid. Can you expand on the situation, perhaps I can advise on alternatives?

I just tried this on TiddlyWiki.com:
\define x(y:<<currentTiddler>>)
$y$
\end
<<x>>
.. and it WORKS!

and just to be sure it wasn't some magic involving <<curerntTiddler>>, I also tried

\define z()
This is some text
\end
\define x(y:<<z>>)
$y$
\end
<<x>>
and it works also.

@Jeremy: It is possible your implementation is just so good that it handles a case you didn't expect?

-e



Rustem

unread,
May 5, 2015, 2:52:03 PM5/5/15
to tiddl...@googlegroups.com, jeremy...@gmail.com
@Eric: Yes, that works. But if I put the same default into my tree macro, there is still no tree unless I provide the parameter. So, must be something inside the macros that needs adjusting...

Jeremy Ruston

unread,
May 5, 2015, 3:14:25 PM5/5/15
to Eric Shulman, TiddlyWiki
Hi Eric

Your example of

\define x(y:<<currentTiddler>>)

is actually equivalent to:

\define x(y:"<<currentTiddler>>")

The technique you are using is to pass the attribute brackets as part of the parameter string. If the parameter isn't specified then it is given the literal string value "<<currentTiddler>>", and not the actual value of the variable "currentTiddler". So it only works if the parameter is eventually wikified, so that the macrocall syntax is processed.

Another problem is that macro calls currently cannot be nested, so you cannot do:

<<x y:"<<myVariable>>">>

There's also a trap that this won't work:

<<x y:"My Tiddler">>

Instead you have to do:

<<x y:"[[My Tiddler]]">>

Best wishes

Jeremy






RA

unread,
Dec 20, 2018, 4:40:34 AM12/20/18
to TiddlyWiki
Just wanted to check, since I'm not following the development closely anymore… Is it still not possible to use anything but a literal as a macro parameter default? (I trimmed the old thread below, please see this in Groups for background info.)


On Tuesday, May 5, 2015 at 11:00:02 AM UTC-7, Jeremy Ruston wrote:
The default values for macro parameters can only be specified as literal strings, I'm afraid.
Jeremy.

Jeremy Ruston

unread,
Dec 20, 2018, 6:43:43 AM12/20/18
to tiddl...@googlegroups.com
Hi RA


On 20 Dec 2018, at 09:40, RA <8pa...@gmail.com> wrote:

Just wanted to check, since I'm not following the development closely anymore… Is it still not possible to use anything but a literal as a macro parameter default? (I trimmed the old thread below, please see this in Groups for background info.)

I don’t think anything has changed in macro parameter default handling since that discussion.

Best wishes

Jeremy.

Reply all
Reply to author
Forward
0 new messages