Filter/subfilter syntax and variables

109 views
Skip to first unread message

AdamS

unread,
Jan 17, 2019, 4:50:25 AM1/17/19
to TiddlyWiki
Hello all,

I've got this action that is supposed to remove a tiddler from a list of tiddler titles:

\define startactions()
<$action-listops $tiddler="List 1" $subfilter="-[<actionTiddler>]"/>
\end

However, it doesn't seem to work if the tiddler title appears in the list in this format [[Two Words]]. It works fine with [[OneWord]] and with OneWord, though. Anyone have any idea what I'm doing wrong here?

Best wishes,
Adam

Mark S.

unread,
Jan 17, 2019, 10:28:18 AM1/17/19
to TiddlyWiki
I think we need to know more about your setup. Are you using the macro in draggable, or in droppable? When I use it in droppable, it works right out of the box, no matter how many spaces are in the title.

Good luck!
-- Mark

AdamS

unread,
Jan 17, 2019, 12:46:56 PM1/17/19
to TiddlyWiki
Hi Mark,

I've tried to get the simplest setup that still features the weird behavior. It is using the draggable widget.

\define startactions()
<$action-listops $tiddler="List 1" $subfilter="-[<actionTiddler>]"/>
\end

<$list filter="[list[List 1]]">
<$draggable tiddler=<<currentTiddler>> startactions=<<startactions>>>
<$text text=<<currentTiddler>>/>
</
$draggable>
</$list>


And List 1 consists of "[[Link Tiddler]] [[Missing Link]] FakeTid [[FakeTiddler]]".
FakeTid and [[FakeTiddler]] get removed. The others do not.
Any ideas?

Best wishes,
Adam

Mark S.

unread,
Jan 17, 2019, 2:12:36 PM1/17/19
to TiddlyWiki
I'm thinking it may be an actual bug. The actionTiddler works as expected inside of droppable, as mentioned before.

By changing your case to use filter instead of subfilter, you can see what the macro sees. When I run it this way, I get

[[[[Missing Link]]]]

I think it's seeing the entire passed text as the literal string "[[[[Missing Link]]]]" If you add "[[[[Missing Link]]]]" to your list, then dragging [[Missing List]] will cause [[[[Missing Link]]]] to disappear.

If that's not a bug, I'd like to know the incantation that would make it work ;-)

-- Mark

AdamS

unread,
Jan 17, 2019, 4:13:36 PM1/17/19
to TiddlyWiki
Hi Mark,

I created an issue on github. I've tried wikifying the list items in various ways but I'm not having any luck making a workaround.

Best wishes,
Adam

admls

unread,
Jan 17, 2019, 5:50:26 PM1/17/19
to tiddl...@googlegroups.com

I think I may have spotted where the issue may be arising.


This is how the actions are invoked by the droppable widget:

this.invokeActionString(this.droppableActions,this,event,{actionTiddler: title, modifier: modifierKey})

In contrast, the draggable widget calls $:/core/modules/utils/dom/dragndrop.js which invokes startActions like this:
options.widget.invokeActionString(startActions,options.widget,event,{actionTiddler: titleString});
The titleString variable is:
var titleString = $tw.utils.stringifyList(titles);
So the droppable widget is passing one title and the draggable widget is passing a list of titles.

In the course of making that list, $tw.utils.stringifyList (in $:/boot/boot.js), does this:

if(entry.indexOf(" ") !== -1) { result.push("[[" + entry + "]]"); } else { result.push(entry); }

So if there is whitespace, as in the case of [[Missing Tiddler]], it gets an extra set of brackets in the draggable widget versus the droppable widget.
I guess a workaround would require being able to remove brackets? But at what point in the process?

admls

unread,
Jan 17, 2019, 6:03:34 PM1/17/19
to TiddlyWiki
I've got a workaround:

\define startactions()
<$wikify name="actionT" text=<<actionTiddler>>>
<$action-listops $tiddler="List 1" $subfilter="-[<actionT>]"/>
</$wikify>

\end

<$list filter="[list[List 1]]">
<$draggable tiddler=<<currentTiddler>> startactions=<<startactions>>>
<<currentTiddler>>
</
$draggable>
</$list>

$draggable adds a set of brackets and $action-listops also adds a set of brackets. So you have to wikify the actionTiddler after it has come out of $draggable and before it goes into $action-listops. That way it has at most one set of brackets on the other side of whatever $action-listops does to it. Phew!

Matthew Lauber

unread,
Jan 17, 2019, 7:04:30 PM1/17/19
to TiddlyWiki
Try $subfilter="-[enlist<actionTiddler>]"

admls

unread,
Jan 17, 2019, 7:48:45 PM1/17/19
to TiddlyWiki
That seems to do the opposite. It works for [[Some Tiddler]], but not for SomeTiddler.
Reply all
Reply to author
Forward
0 new messages