[TW5] How to navigate to list of tiddlers defined by a filter?

217 views
Skip to first unread message

Linus Johnsson

unread,
May 31, 2015, 7:48:53 AM5/31/15
to tiddl...@googlegroups.com
Dear all,

I'm having some trouble (again!) with macro parameters. What I would like to do is to create a macro that displays a button that opens several tiddlers at once, defined by a filter. It works as expected when the filter is defined in the macro, so

\define openTiddlersTest()
<$button>
<$list filter="Test1 Test2">
<$action-navigate $to={{!!title}}/>
</$list>
Open tiddlers
</$button>
\end

opens the tiddlers "Test1" and "Test2" as expected. However, when the filter is parameterized as follows:

\define openTiddlers(tf)
<$button>
<$list filter=$tf$>
<$action-navigate $to={{!!title}}/>
</$list>
Open tiddlers
</$button>
\end

<<openTiddlers "Test1 Test2">>

only "Test1" is opened. Variations such as <<openTiddlers "[[Test1]] [[Test2]]">> and <<openTiddlers """Test1 Test2""">> don't work either.

I tried to add parentheses around the parameter:

\define openTiddlers(tf)
<$button>
<$list filter=$(tf)$>
<$action-navigate $to={{!!title}}/>
</$list>
Open tiddlers
</$button>
\end

which strangely enough opens the tiddler "true". (Why would "$(tf)$" evaluate to "true"?) Even worse, when I try to use instead angle brackets:

\define openTiddlers(tf)
<$button>
<$list filter=<<tf>> >
<$action-navigate $to={{!!title}}/>
</$list>
Open tiddlers
</$button>
\end

seemingly every single tiddler in the Wiki is opened, and eventually it crashes completely.

Could anyone give me a hint as to what I'm doing wrong? I would also greatly appreciate an explanation of what is going on here, since I evidently don't grasp the WikiText semantics yet.


Best regards,
Linus

Jeremy Ruston

unread,
May 31, 2015, 8:48:56 AM5/31/15
to TiddlyWiki
Hi Linus

opens the tiddlers "Test1" and "Test2" as expected. However, when the filter is parameterized as follows:

\define openTiddlers(tf)
<$button>
<$list filter=$tf$>
<$action-navigate $to={{!!title}}/>
</$list>
Open tiddlers
</$button>
\end

The $param$ and $(var)$ syntax results in a textual substitution that is performed on the macro contents before it is parsed.

The problem here is that the textual substitution occurs literally, so if you pass a value that contains spaces you'll get something like this:

<$list filter=one two three>

So, the solution is to include quotes:

<$list filter="""$tf$""">

By using triple double quotes we ensure that filters that contain single or double double quotes will work correctly.

Best wishes

Jeremy.


 

<<openTiddlers "Test1 Test2">>

only "Test1" is opened. Variations such as <<openTiddlers "[[Test1]] [[Test2]]">> and <<openTiddlers """Test1 Test2""">> don't work either.

I tried to add parentheses around the parameter:

\define openTiddlers(tf)
<$button>
<$list filter=$(tf)$>
<$action-navigate $to={{!!title}}/>
</$list>
Open tiddlers
</$button>
\end

which strangely enough opens the tiddler "true". (Why would "$(tf)$" evaluate to "true"?) Even worse, when I try to use instead angle brackets:

\define openTiddlers(tf)
<$button>
<$list filter=<<tf>> >
<$action-navigate $to={{!!title}}/>
</$list>
Open tiddlers
</$button>
\end

seemingly every single tiddler in the Wiki is opened, and eventually it crashes completely.

Could anyone give me a hint as to what I'm doing wrong? I would also greatly appreciate an explanation of what is going on here, since I evidently don't grasp the WikiText semantics yet.


Best regards,
Linus

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/28276197-2738-4e21-9300-f658364993ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



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

Linus Johnsson

unread,
May 31, 2015, 10:55:46 AM5/31/15
to tiddl...@googlegroups.com
Ah, that explains it! It works as expected now. Many thanks!

I read about those triple quotes in "Macro Calls in WikiText", but I didn't realise that formal parameters (is that the correct term for the $parameter$ construct?) in the macro definition could be enclosed as well, not just parameter values (arguments?) on the "calling" side. Perhaps adding an example of is to "Macro Definitions in WikiText" would be helpful?

Best regards,
Linus

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/ShOTV6i1j8Y/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.

stevesuny

unread,
Jul 1, 2015, 3:05:10 PM7/1/15
to tiddl...@googlegroups.com
Hi all,

I want to do something similar, but instead of opening tiddlers, I want to navigate to a selected one from among the filtered alternatives.

 I have:

<$select tiddler='$:/generated-list-demo-state'>
<$list filter="[match{!!match}]">
<option><$view field='title'/></option>
</$list>
</$select>

Which generates the select with the names of filtered tiddlers,

but how to I get the selected option to become the current tiddler?

Thanks!

//steve.
Message has been deleted

Jed Carty

unread,
Jul 1, 2015, 7:52:56 PM7/1/15
to tiddl...@googlegroups.com
To make the select widget perform an action like that requires a change to the widget. I have some non-button widgets modified so they can trigger action widgets. The demo is here http://ooktech.com/jed/ExampleWikis/InvokingActions/ and on github https://github.com/inmysocks/WidgetsInvokeActions They aren't perfect. Hopefully something like this will make it into the core at some point.

Eric Shulman

unread,
Jul 2, 2015, 2:35:21 AM7/2/15
to tiddl...@googlegroups.com
On Wednesday, July 1, 2015 at 12:05:10 PM UTC-7, stevesuny wrote:
I want to do something similar, but instead of opening tiddlers, I want to navigate to a selected one from among the filtered alternatives.
<$select tiddler='$:/generated-list-demo-state'>
<$list filter="[match{!!match}]">
<option><$view field='title'/></option>
</$list>
</$select>
but how to I get the selected option to become the current tiddler?

The <$select> widget just sets the target tiddler's text to the selected value.  It doesn't have the ability to send a "tm-navigate" message or trigger an action widget by itself.

However, if you don't mind having to perform a second click, you could add this:

<$link to={{$:/generated-list-demo-state}}>GO!</$link>

enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
Reply all
Reply to author
Forward
0 new messages