Solved. In fact, the solution was so simple I'm worried it's a trap! I have 
created a new filter operator -- enlistallowduplicates -- which differs 
from enlist by a single parameter.

Here is the non-comment part of enlist.js:

(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Export our filter function
*/
exports.enlist = function(source,operator,options) {
        var list = $tw.utils.parseStringArray(operator.operand);
        if(operator.prefix === "!") {
                var results = [];
                source(function(tiddler,title) {
                        if(list.indexOf(title) === -1) {
                                results.push(title);
                        }
                });
                return results;
        } else {
                return list;
        }
};

})();


Here is the non-comment part of enlistallowduplicates.js with the added 
parameter bolded/italicised/underlined:

(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Export our filter function
*/
exports.enlistallowduplicates = function(source,operator,options) {
    var list = $tw.utils.parseStringArray(operator.operand,*true*);
    if(operator.prefix === "!") {
        var results = [];
        source(function(tiddler,title) {
            if(list.indexOf(title) === -1) {
                results.push(title);
            }
        });
        return results;
    } else {
        return list;
    }
};

})();


This works because $tw.utils.parseStringArray is already defined with a 
second boolean parameter called AllowDuplicates which, unsurprisingly, 
causes the return value (a list) to include duplicates. The new operator -- 
enlistallowduplicates -- also respects the double-square-brackets 
convention. So, this meets all my criteria for a drop-in replacement for 
enlist that allows duplicates.

I checked the definition of $tw.utils.parseStringArray in version 
5.1.20-prerelease (it's in boot/boot.js) and it remains unchanged, so this 
solution should survive the next upgrade (unless these parts change between 
now and then).

My thanks to everyone who responded to my question, and especially to Mark 
S. who nudged me toward a replacement filter operator.

Regards,
David.

On Friday, 26 April 2019 05:35:54 UTC+9:30, Mark S. wrote:
>
>
> It turns out that I wrote an "enlist2" filter in 2017 that can split on 
> spaces without duplication. Unfortunately, this means your tiddler titles 
> can't have spaces. I can imagine an enhanced version that could split on [[ 
> ]] as well.
>
> https://groups.google.com/d/msg/tiddlywiki/KzDgSIrPOXI/IWsqXamwBQAJ
>

-- 
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/f9b7a710-5587-4f70-8f45-3ca071ba99fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to