Ok, something to try:

\define removeme() [[$(item2)$]] 
\define empty()
<$vars appendme="[[$(item2)$]]">
  <$button class="tc-btn-invisible">
      <$action-listops $tiddler='$(tiddler)$' $field="$(field)$"
           $subfilter="+[append<appendme>]"/>
      {{$:/image/checkbox1}} <<label>> 
   </$button>
<$vars>
\end
\define toggle-in-field(tiddler, field, item, item2, label)
<$set name=item2 value='$item2$' emptyValue='$item$'>
<$set name=label value='$label$' emptyValue='[[$item$]]'>
<$vars tiddler="""$tiddler$""" field="""$field$""">
<div style="white-space:nowrap; display:inline-block; margin-right:3px;">
<$list filter="[enlist{$tiddler$!!$field$}regexp[^$item$$]limit[1]]" 
variable=n1 emptyMessage=<<empty>>>
   <$button class="tc-btn-invisible" >
      <$action-listops $tiddler='$tiddler$' $field="$field$"
         $subfilter="+[remove<removeme>]"/>
      {{$:/image/checkbox2}} <<label>> 
   </$button>
</$list>
</div>
</$vars>
</$set>
</$set>
\end

It seems to work with your Foo bar examples, but my testing was pretty 
brief. It does NOT use variable #2, because I don't understand yet what you 
want to do with that. Perhaps you could explain in more detail.

There was some TW-Logic errors (TW-Logic is not to be confused with the 
real thing). This line presents problems:

   <$set name=item2 value='$item2$' emptyValue='[[$item$]]'>

Because if there is a value then the rest of the code sees a simple text 
string, but if there is not a value than the rest of the code sees a title 
list string. The rest of the code needs it to be one or the other. I 
switched it off, but then switched on title list right before the list-ops. 
This might not be the best way, but it seems to work.

There's only one list widget now. There was a logic error with !regexp. 
!regexp returns a list of items that don't match the criteria, but that 
doesn't mean that aren't other criteria that DO match the criteria. So 
instead I used the "emptyMessage" for when there were no items that 
matched. This meant playing with variable names a bit.

HTH
-- Mark

On Thursday, August 9, 2018 at 1:14:27 PM UTC-7, Mat wrote:
>
> Thanks for reply, Mark!
>
> You seem to want to look at something like "[[Foo]] Bar Baz" as a whole 
>> string. I'm not sure how to even set that up experimentally, because TW 
>> constantly wants to turn it into a title list, with each item viewed as a 
>> title.
>>
>
> I'd think all the cases where you're forced to use the enlist filter 
> operator would mean that if you don't use it, then the arg is seen as one 
> string. No?
>  
> But, regardless, doesn't the regexp:field[] filter op always interpret 
> any field content as one string because regexp:tags[oo ba] would show 
> positive for the tags "foo bar". I.e AFAICT, the space character is just a 
> character to regexp, not a separator. 
>
>
>
> As far as a regular expression that just finds "Foo" (assuming a standard 
>> title list) then regexp[^Foo$] should work.
>>
>
> If there is anything more in the field, such as is common the tags field, 
> then that syntax would give a false negative.
>
> The actual use case for my question is the toggle-in-field 
> <http://toggle-in-field.tiddlyspot.com/> plugin. I have thus far used 
> regexp[\b$item$\b] like so 
>
> <$list filter="[[$tiddler$]has[$field$]regexp:$field$[\b$item$\b]]">
>
> This is actually pretty good but it gives a false positive in a TW 
> context(!) where a title Foo must not be confused with a title [[Foo bar]]. 
> There needs to be some condition that a prefixing [[ also requires a 
> suffixing ]] but I'm not sure how to deal with bracket characters in a 
> filter and if it is at all possible.
>
> Thanks for your input, Mark!
>
> <:-)
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/89e2d4f8-9a78-4bb6-ad73-75a11654e0be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to