[TW5] What's special about the list field?

583 views
Skip to first unread message

Matabele

unread,
Jun 19, 2014, 3:04:28 PM6/19/14
to tiddl...@googlegroups.com
Hi

I have been playing around with lists, but am a little confused about the behaviour of the list (and tags) field when compared with standard fields.

Say a standard field 'myfield' contains a comma separated list. If I then set the value of the 'list' field to this value, the comma separated list will be transformed into a space separated list.

The converse is not true. If I then set the value of 'myfield' to the value of the 'list' field, the value in 'myfield' will now be space separated.

Does this effect the behaviour of filter operators for lists? (can comma separated and space separated lists be used in the same way?)

regards  

BJ

unread,
Jun 20, 2014, 1:59:22 AM6/20/14
to tiddl...@googlegroups.com
Hi Matabele,
the list field is used to re-order to a list of tiddlers, you can see how I have used it here:
http://bjhacks.tiddlyspot.com/#TagList

cheers
BJ

Matabele

unread,
Jun 20, 2014, 2:05:36 AM6/20/14
to tiddl...@googlegroups.com
Hi BJ

Thanks -- I was trying to do something like this, but wanted to use a field other than the list field -- then I ran across the problem that the 'list' field uses a space separated list and other fields use a comma separated list. This necessitated creating the list in a 'list' field, then storing the space separated list into another standard field.

Wondered whether it was possible to use a standard field in exactly the same way as the 'list' field?

regards

Danielo Rodríguez

unread,
Jun 20, 2014, 2:42:53 AM6/20/14
to tiddl...@googlegroups.com
Not exactly the same way but very close. Try the split operator. Look for it on Stephan's wikir

BJ

unread,
Jun 20, 2014, 2:47:04 AM6/20/14
to tiddl...@googlegroups.com
In what sense do you mean 'use'?
in boot you can see:
$tw.modules.define("$:/boot/tiddlerfields/list","tiddlerfield",{
    name: "list",
    parse: $tw.utils.parseStringArray,
    stringify: $tw.utils.stringifyList
});
which means that the 'list' field will be converted from space separated list of tag-strings (including [[tag forn]] of tags) to an array of strings (and converted back) whenb reading and writing via javascript. (eg addTiddler() function)

Matabele

unread,
Jun 20, 2014, 3:24:16 AM6/20/14
to tiddl...@googlegroups.com
Hi BJ

I had a need to resort a current list -- consequently I wrote a widget to store the output of a filter expression to a text reference. I then noticed that when stored to a standard field, the list was comma separated, but when stored to a the list field it became space separated. 

It would appear, therefore, that filter expressions for lists require the list to be space separated?

regards

Matabele

unread,
Jun 20, 2014, 3:41:09 AM6/20/14
to tiddl...@googlegroups.com
Hi BJ

Perhaps an easier way of asking my question:

Why is the list field space separated whereas standard fields are not?

regards

On Friday, June 20, 2014 8:47:04 AM UTC+2, BJ wrote:

Stephan Hradek

unread,
Jun 20, 2014, 4:27:07 AM6/20/14
to tiddl...@googlegroups.com
Because Jeremy did it that way.

;)

Jeremy just had ONE special field in mind, which he named "list" and which is treated special all over the place.

All the other fields are simple "scalars", meaning that they just can hold one string value.

It is simply that way, but if I remember correctly, Jeremy wants to do something about it.

Matabele

unread,
Jun 20, 2014, 4:39:25 AM6/20/14
to tiddl...@googlegroups.com
Hi Stephan

I have written a widget that sets the value of a text reference to the output of a filter expression. Currently, this will output a comma separated list (which will be transformed into a space separated list only if the text-reference points to the special 'list' field.) 

Would it make more sense for this widget to output a space separated list?

I wasn't around for any of the discussions with respect the use of lists of tiddlers, however there's a 'list' filter operator that allows the use of any field to be used in place of the special 'list' field and this makes no sense if the other field contains a comma separated list when a space separated list is expected.

The list filter operator replaces the current list with the list contained in the TextReference specified in the operand. The default field for the text reference is list.

regards 

BJ

unread,
Jun 20, 2014, 4:42:14 AM6/20/14
to tiddl...@googlegroups.com
I do this -
        listofTiddlerTitles = this.getTiddlerList();
        //listofTiddlerTitles is now a javascript array of strings (tiddler titles)
        updateFields["list"] = listofTiddlerTitles;
        //tiddlywiki defines in boot.js that the field called 'list' is to be converted to a space seperated string containing tiddler titles as 'tiddler title words' - eg "mytid [[this tid]]"
        self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getCreationFields(),tiddler,updateFields,
        self.wiki.getModificationFields()));

if instead I did this:
        listofTiddlerTitles = this.getTiddlerList();
        //listofTiddlerTitles is now a javascript array of strings (tiddler titles)
        updateFields["mylist"] = listofTiddlerTitles;
        //tiddlywiki will not know how to convert "mylist" to a string - anything could happen?????
        self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getCreationFields(),tiddler,updateFields,
        self.wiki.getModificationFields()));

BJ

unread,
Jun 20, 2014, 4:54:17 AM6/20/14
to tiddl...@googlegroups.com

you need to call $tw.utils.stringifyList(listofTiddlerTitles) inorder to convert it to a space seperated list

Matabele

unread,
Jun 20, 2014, 4:58:25 AM6/20/14
to tiddl...@googlegroups.com
Hi BJ

Thanks for getting down to the particulars. My problem is that my widget is general purpose -- to set the value of any text-reference to the output of a filter expression. Currently, this will output a comma separated list, however I imagine that the widget will generally be used to set the value of a text-reference to a list of tiddler titles.

Lists of tiddler titles are, however, perhaps more useful in space separated form. For example, an array of lists of tiddler titles, each the output of a filter expression at some point in time, could be stored in a data tiddler, then retrieved later (another recent thread points to a possible use to open and close a list of tiddlers with a particular tag.)

This can be done by the user in two steps by setting the value of a special 'list' field to the output of the filter expression (with my widget), then setting the value of a text-reference elsewhere to this space separated list.

However, I wondered whether my widget should not be modified to output a space separated list in the first instance. Is there any downside to this behaviour?

regards

regards

Stephan Hradek

unread,
Jun 20, 2014, 4:58:43 AM6/20/14
to tiddl...@googlegroups.com
To be honest: I have no idea.

I understood from what Jeremy said on (or before) the last hangout, that he thinks the list filter is broken. I also mentioned that I think it's inconsistent https://groups.google.com/d/msg/tiddlywiki/915nysD7h1c/G8jUVPEn-gkJ

I suggest to no longer use that filter. We talked in the hangout about making it deprecated.


Matabele

unread,
Jun 20, 2014, 5:05:16 AM6/20/14
to tiddl...@googlegroups.com
Hi Stephan

It makes sense for any text-reference to be used as a list. For example, lists can be stored to entries in a data tiddler, then at a later point in time the list can be retrieved and sorted before use. I think the issue might come down to the use of space separated lists by default in the special 'list' and 'tags' fields, and a different behaviour for all other text-references. 

regards

Matabele

unread,
Jun 20, 2014, 5:21:00 AM6/20/14
to tiddl...@googlegroups.com
Hi Stephan

What we need, therefore, is something like a 'setlist' filter operator, which understands indirect operands?

regards

Danielo Rodríguez

unread,
Jun 20, 2014, 5:21:44 AM6/20/14
to tiddl...@googlegroups.com
Hi Matabele,

I only understand partially what are you doing.
I recently coded a simple javascript macro that returns a comma separated list as a result of evaluating a filter. I use it as input for a new plugin that I'm developing. What is your use case? Why a widget for such a simple task? And, why do you need to use the list field?

Matabele

unread,
Jun 20, 2014, 5:27:22 AM6/20/14
to tiddl...@googlegroups.com
Hi

I think that for now I will follow BJ's suggestion and call $tw.utils.stringifyList(listofTiddlerTitles) to convert the output of the filter expression to a space separated list. This suits my application of the widget and I expect will fit most use cases for the widget.

Thanks for the help.

regards


On Thursday, June 19, 2014 9:04:28 PM UTC+2, Matabele wrote:

Matabele

unread,
Jun 20, 2014, 5:37:45 AM6/20/14
to tiddl...@googlegroups.com
Hi Rodriguez

What impresses me most about TW5 compared with TWC is what can be done with a vanilla TW5 'out-of-the-box'. However, I came upon a few limitations when developing applications and began writing simple widgets that can be stacked around a multi purpose button. This enables a user to build a button for the purpose without having to use javascript.

Of necessity the stackable widgets must be simple to use and must also be able to be used stacked in succession using widget messages -- this places constraints upon the complexity of any individual widget.

But most of all -- these are my first attempts with javascript :-)

regards


On Friday, June 20, 2014 11:21:44 AM UTC+2, Danielo Rodríguez wrote:
Hi Matabele,

Danielo Rodríguez

unread,
Jun 20, 2014, 6:04:28 AM6/20/14
to tiddl...@googlegroups.com
You can continue calling me Danielo, as before. 

I'm familiar to your widgets. I'm just asking for this particular one ;)

Matabele

unread,
Jun 20, 2014, 6:34:56 AM6/20/14
to tiddl...@googlegroups.com
Hi Danielo

Oops :-) 

I needed to resort and edit a list of tiddlers -- something like the BJ's 'taglist' plugin, however in this case the list was a current list of tiddlers generated from a field rather than a tag. In this case editing by hand with an <$edit-text> widget was sufficient (no drag and drop needed), but first I needed to put the current list of tiddlers with a specific value for the field into a list, in order that it could be edited. 

I have been assuming that whatever I might need to do, others might need to do also -- so wrote a widget to set the value of a text-reference to the result of a filter expression. After writing the widget, I explored some other use cases. One possible use was to set the 'list' field of the '$:/Storylist' tiddler to the output of a filter expression -- this enables a user to overwrite the storylist with the output of any filter expression. From there, I thought it might be useful to store snapshots of the storylist or results generated from filter expressions to an entry in a data tiddler -- these snapshots of the storylist can then be retrieved at some later point in time.

However, here I came upon the issue that the special 'list' field uses space separated lists of tiddler titles, whereas the output of a filter expression is a comma separated list of titles, and wondered which format would be most useful.

regards   

Matabele

unread,
Jun 20, 2014, 6:43:27 AM6/20/14
to tiddl...@googlegroups.com
Hi

I think this ticket explains best the general use case (this should not be restricted to lists of tiddlers with a particular tag, but to lists of tiddlers generated with any filter expression):


regards

On Thursday, June 19, 2014 9:04:28 PM UTC+2, Matabele wrote:

Danielo Rodríguez

unread,
Jun 20, 2014, 3:32:13 PM6/20/14
to tiddl...@googlegroups.com
Hello Matabelle,

Thank you for the detailed explanation. Now it is Cristal clear.

Jeremy Ruston

unread,
Jun 21, 2014, 4:59:38 AM6/21/14
to TiddlyWiki
Sorry I've been out of this thread as I've been tied up for a day or two.

> Would it make more sense for this widget to output a space separated list?

At the moment, the only fields that fully support lists of values are the "tags" field and the "list" field. As BJ pointed out, these fields are configured by the core with a serializer and deserializer that knows how to translate the string value to and from a space separated list.

If you store an array as the value of another field then it will not be properly serialised on when the tiddler is saved; instead the default JS behaviour kicks in and the array is converted to a comma delimited list (Try executing [0,1,2] + "" in the browser console to see what I mean).

All of the behaviour I've described is inherited from TW Classic. The plan going forward is expressed in the roadmap with these words:

"Tiddler object format (to provide true polymorphism of field values)"

The idea is to move responsibility to the caller for serialising field values into strings. This will mean providing some new APIs on the Tiddler object.

In the meantime, as BJ suggests, the fix is for you to explicitly serialise your lists when you store them in a tiddler.

Best wishes

Jeremy



On Fri, Jun 20, 2014 at 8:32 PM, Danielo Rodríguez <rdan...@gmail.com> wrote:
Hello Matabelle,

Thank you for the detailed explanation. Now it is Cristal clear.

--
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

Matabele

unread,
Jun 21, 2014, 7:15:28 AM6/21/14
to tiddl...@googlegroups.com, jeremy...@gmail.com
Hi

Thanks for the guidance -- on BJ's advice I had already decided to explicitly serialise the list in the widget. Glad to hear this fits with plans for the future course of TW5.

regards

Kalmir

unread,
Jan 12, 2019, 7:15:55 AM1/12/19
to TiddlyWiki
Hi, I am wondering if these days (early 2019) TW5 supports populating one field with multiple values? I mean a newly created field, i.e. not a standard one (like list or tag). If yes, the question is how to separate the values.

However, from reading field notation documentation, searching GGroups and doing own experiments, it seems to me TW5 doesn't allow that. Am I right?

I am asking because if I understood Jeremy's old reply in this tread correctly, enabling "polymorphism of field values" has been in consideration.

Thanks,
Mira

Jed Carty

unread,
Jan 12, 2019, 7:42:12 AM1/12/19
to TiddlyWiki
If you want multiple values like in the field list or tags you can use a space separated list in the same way as list or tags and use the filter operator enlist to read it like a list.


An example that may fit your case better that what is on that page is make a tiddler with a list called my_list and put this in the text of that tiddler:

<$list filter='[enlist{!!my_list}]'>
<
<currentTiddler>><br>
</$list>

The content of the field is, like the tags and list field, a space separated list. If there is an element in the list that has spaces in the title you need to put it inside [[ and ]] like this:

item1 item2 [[item3 has spaces]] item4

Hopefully that covers your use.

To manipulate fields like this the listops operator can be very helpful: https://tiddlywiki.com/#ActionListopsWidget

I made a plugin that lets you use any field like a tag field called GenTags.if that a fits your use you can see more about it here: https://ooktech.com/jed/ExampleWikis/GenericTagFields/

Kalmir

unread,
Jan 12, 2019, 8:12:22 AM1/12/19
to TiddlyWiki
Thanks, Jed, I need to look into it but I think your suggestions will help me.
Reply all
Reply to author
Forward
0 new messages