[tw5] Re: Adding duplicate title in title list
Amazing response, Eric. Thank you! That worked *perfectly*! I need to spend some quality time with https://tiddlywiki.com/#Filter%20Expression. There is a lot of new stuff on there I hadn't seen before! > Note also that using `` in your filter is *slightly* more efficient than `all[current]` See, I *used* to use currentTiddler but saw so many examples with all[current] that I assumed that there was some optimization going on there. Noted and adjusted. Great tip! > enjoy I will, thank you! On Wednesday, February 16, 2022 at 10:43:56 PM UTC Eric Shulman wrote: > Answer to question #1: > > By default, titles resulting from a filter are only listed once, with the > last instance of a given title "dominantly appended" to the list (i.e., > duplicates are removed). Thus, in your example, adding `[[foo]]` to the > end of the list automatically removed the first instance of `foo` from the > front of the list. You've already discovered the use of the `:raw` suffix > for the `enlist-input` operator, which prevents duplicates from being > removed when you enlist an existing space-separated list. Another bit of > filter syntax that helps with preserving duplicates is the "=" prefix on a > filter run. To get the results you expected, you would write: `[[foo foo > foo bar]enlist-input:raw[]] =[[foo]]`. > > Answer to question #2: > > As you noted in your followup message, you have an existing list stored in > a tiddler field called `fieldName`. Let's assume this field contains 4 > items: `foo [[bar baz]] mumble [[frotz gronk snork]]` (where the 2nd and > 4th items contain spaces). To add an item to that list, you would write > something like this:: `[get[fieldName]enlist-input:raw[]] > =[]`. Note also that using `` in your filter > is *slightly* more efficient than `all[current]`, since the `all[]` > operator first needs to parse the operand (`current`) to determine that you > want to retrieve the current tiddler's title, while `` > directly retrieves the title without the added internal layer of parsing. > > enjoy, > -e > On Wednesday, February 16, 2022 at 2:17:51 PM UTC-8 andres@gmail.com > wrote: > >> Ok, so I have the following list: >> >> foo foo foo bar >> >> I then want to append 'foo' to the end of that list such that I wind up >> with: >> >> foo foo foo bar foo >> >> So I try the following filter: >> >> [[foo foo foo bar]enlist-input:raw[]] [[foo]] >> >> That results in: >> >> foo foo bar foo >> >> This is unexpected to me, which means that there is something I don't >> understand. >> >> So I have two questions: >> >> 1. Why is the title not appended as I expected? >> 2. How can I get the result I want? To add complexity (cause why not?), >> the list will be generated dynamically based on user input, titles will >> only sometimes be of existing tiddlers, and the titles can have spaces xD. >> > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b569a692-b2ee-4c23-93e1-dd8c1a051dd2n%40googlegroups.com.
[tw5] Re: Adding duplicate title in title list
Answer to question #1: By default, titles resulting from a filter are only listed once, with the last instance of a given title "dominantly appended" to the list (i.e., duplicates are removed). Thus, in your example, adding `[[foo]]` to the end of the list automatically removed the first instance of `foo` from the front of the list. You've already discovered the use of the `:raw` suffix for the `enlist-input` operator, which prevents duplicates from being removed when you enlist an existing space-separated list. Another bit of filter syntax that helps with preserving duplicates is the "=" prefix on a filter run. To get the results you expected, you would write: `[[foo foo foo bar]enlist-input:raw[]] =[[foo]]`. Answer to question #2: As you noted in your followup message, you have an existing list stored in a tiddler field called `fieldName`. Let's assume this field contains 4 items: `foo [[bar baz]] mumble [[frotz gronk snork]]` (where the 2nd and 4th items contain spaces). To add an item to that list, you would write something like this:: `[get[fieldName]enlist-input:raw[]] =[]`. Note also that using `` in your filter is *slightly* more efficient than `all[current]`, since the `all[]` operator first needs to parse the operand (`current`) to determine that you want to retrieve the current tiddler's title, while `` directly retrieves the title without the added internal layer of parsing. enjoy, -e On Wednesday, February 16, 2022 at 2:17:51 PM UTC-8 andres@gmail.com wrote: > Ok, so I have the following list: > > foo foo foo bar > > I then want to append 'foo' to the end of that list such that I wind up > with: > > foo foo foo bar foo > > So I try the following filter: > > [[foo foo foo bar]enlist-input:raw[]] [[foo]] > > That results in: > > foo foo bar foo > > This is unexpected to me, which means that there is something I don't > understand. > > So I have two questions: > > 1. Why is the title not appended as I expected? > 2. How can I get the result I want? To add complexity (cause why not?), > the list will be generated dynamically based on user input, titles will > only sometimes be of existing tiddlers, and the titles can have spaces xD. > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/dff8b409-b0bc-4f67-b436-582bb2265f1fn%40googlegroups.com.
[tw5] Re: Adding duplicate title in title list
I should add that the list is currently stored as a field, so my filter is more along the lines of [all[current]get[fieldName]enlist-input:raw[]] [] I couldn't use the listops action widget subfilters because they automatically dedup so I need to use the full filter which doesn't fully dedup my list but, at least with this filter, still makes me lose entries. On Wednesday, February 16, 2022 at 10:17:51 PM UTC andres@gmail.com wrote: > Ok, so I have the following list: > > foo foo foo bar > > I then want to append 'foo' to the end of that list such that I wind up > with: > > foo foo foo bar foo > > So I try the following filter: > > [[foo foo foo bar]enlist-input:raw[]] [[foo]] > > That results in: > > foo foo bar foo > > This is unexpected to me, which means that there is something I don't > understand. > > So I have two questions: > > 1. Why is the title not appended as I expected? > 2. How can I get the result I want? To add complexity (cause why not?), > the list will be generated dynamically based on user input, titles will > only sometimes be of existing tiddlers, and the titles can have spaces xD. > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/fe3bd9b3-8911-4505-8859-389d8485fd1cn%40googlegroups.com.