Automatic task list creation

150 views
Skip to first unread message

JWHoneycutt

unread,
Jun 30, 2018, 9:29:56 AM6/30/18
to TiddlyWiki

I have a Task list, consisting of all tiddlers tagged "Task".

As I create or modify a lengthy tiddler, I would like to extract new tasks automatically.


This is how I imagine it working


I have been consistently typing carriage return ;Task: Blah blah carriage return

I would like the new (tiddler tagged with "Task") to be titled with the following contents extracted from the lengthy tiddler:

Wherever <cr>;Task: "text to become a new task" <cr> is encountered


How would you do that? Should I use "splitbefore"? (but that is for titles...)


JWHoneycutt

BurningTreeC

unread,
Jun 30, 2018, 10:38:16 AM6/30/18
to TiddlyWiki
Hi @JWHoneycutt

this is a modified get[] filter that returns a field of any tiddler line by line:

/*\
title: $:/core/modules/filters/get.js
type: application/javascript
module-type: filteroperator

Filter operator for replacing tiddler titles by the value of the field specified in the operand.

\*/
(function(){

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

/*
Export our filter function
*/
exports.get = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
if(tiddler) {
var value = tiddler.getFieldString(operator.operand);
if(value && operator.suffix !== "lines") {
results.push(value);
} else if(value && operator.suffix === "lines") {
                                var lines = value.split('\n');
                                for(var i = 0; i < lines.length; i++) {
                                        results.push(lines[i]);
                                }
                        }
}
});
return results;
};

})();


it doesn't change the behaviour of get[] if you use it the normal way like [[mytiddler]get[text]] or [[mytiddler]get[myfield]]

but it returns the field line by line (if there are more lines) when you use it this way:

[[mytiddler]get:lines[text]]

this filter needs some testing... if you want to try it, I recommend trying it in an empty wiki to see if it works for you


I think it can be used to identify lines beginning with ";Task:" and to extract what follows to ";Task:" like this:

[[mytiddler]get:lines[text]removeprefix[;Task:]]

BTC

BurningTreeC

unread,
Jun 30, 2018, 11:08:50 AM6/30/18
to TiddlyWiki
the save-tiddler button ($:/core/ui/Buttons/save) could be modified to this:

<$fieldmangler><$button tooltip={{$:/language/Buttons/Save/Hint}} aria-label={{$:/language/Buttons/Save/Caption}} class=<<tv-config-toolbar-class>>>
<<extract-tasks-from-tiddler>>
<$action-sendmessage $message="tm-add-tag" $param={{$:/temp/NewTagName}}/>
<$action-deletetiddler $tiddler="$:/temp/NewTagName"/>
<$action-sendmessage $message="tm-add-field" $name={{$:/temp/newfieldname}} $value={{$:/temp/newfieldvalue}}/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<$action-sendmessage $message="tm-save-tiddler"/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/done-button}}
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/language/Buttons/Save/Caption}}/></span>
</$list>
</$button></$fieldmangler>


the actions for saving a tiddler with "ctrl-Enter" need the same modification. for that, you change the tiddler $:/core/ui/EditTemplate ... there's only one new line at the top:

\define actions()
<<extract-tasks-from-tiddler>>
<$action-sendmessage $message="tm-add-tag" $param={{$:/temp/NewTagName}}/>
<$action-deletetiddler $tiddler="$:/temp/NewTagName"/>
<$action-sendmessage $message="tm-add-field" $name={{$:/temp/newfieldname}} $value={{$:/temp/newfieldvalue}}/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<$action-sendmessage $message="tm-save-tiddler"/>
\end
\define frame-classes()
tc-tiddler-frame tc-tiddler-edit-frame $(missingTiddlerClass)$ $(shadowTiddlerClass)$ $(systemTiddlerClass)$
\end
<div class=<<frame-classes>> data-tiddler-title=<<currentTiddler>>>
<$fieldmangler>
<$set name="storyTiddler" value=<<currentTiddler>>>
<$keyboard key="((cancel-edit-tiddler))" message="tm-cancel-tiddler">
<$keyboard key="((save-tiddler))" actions=<<actions>>>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/EditTemplate]!has[draft.of]]" variable="listItem">
<$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]">
<$transclude tiddler=<<listItem>>/>
</$set>
</$list>
</$keyboard>
</$keyboard>
</$set>
</$fieldmangler>
</div>




and you create another tiddler tagged with $:/tags/Macro with this content:

\define extract-tasks-from-tiddler()
<$list filter="[[$(storyTiddler)$]get:lines[text]removeprefix[;Task:]!prefix[ ]] [[$(storyTiddler)$]get:lines[text]removeprefix[;Task:]prefix[ ]removeprefix[ ]]" variable="taskLine">
<$list filter="[<taskLine>is[missing]]">
<$action-createtiddler $basetitle=<<taskLine>>/>
<$fieldmangler tiddler=<<taskLine>>>
<$action-sendmessage $message="tm-add-tag" $param="Task"/>
</$fieldmangler>
</$list>
</$list>
\end

this is working pretty good for me, I really like your idea!

all the best,
BTC



Mark S.

unread,
Jun 30, 2018, 12:36:59 PM6/30/18
to TiddlyWiki
This thing could have been done with the regexps filter. https://github.com/Jermolene/TiddlyWiki5/pull/2963

Something like this would be useful in the core.

-- Mark

BurningTreeC

unread,
Jun 30, 2018, 12:39:01 PM6/30/18
to TiddlyWiki
I've found a bug and changed the macro a bit:

\define extract-tasks-from-tiddler()
<$list filter="[[$(storyTiddler)$]get:lines[text]removeprefix[;Task:]!prefix[ ]] [[$(storyTiddler)$]get:lines[text]removeprefix[;Task:]prefix[ ]removeprefix[ ]]" variable="taskLine">
<$list filter="[<taskLine>is[missing]]">
<$action-createtiddler $basetitle=<<taskLine>>/>
<$action-setfield $tiddler=<<taskLine>> tags="Task"/>
</$list>
</$list>
\end


BurningTreeC

unread,
Jun 30, 2018, 12:49:54 PM6/30/18
to TiddlyWiki
@Mark S.

This thing could have been done with the regexps filter. https://github.com/Jermolene/TiddlyWiki5/pull/2963

Something like this would be useful in the core.

-- Mark

Is there a regexps plugin somewhere?
I think if there are good pull requests that are lingering around for a long time, we should start making plugins out of them so people can test and report and maybe the original PR benefits in some way or another from that.

Maybe we can gather a list of useful PR's that are waiting for a merge-success ... and anyone able to create plugins and having some love and time at hand can port them to a tiddlyspot page
I was totally unaware of that regexps filter for example...

BTC

JWHoneycutt

unread,
Jun 30, 2018, 1:44:55 PM6/30/18
to TiddlyWiki
@BTC

Thank you !

Follow-up question:

The "modified get[] filter" you provide at the beginning of your explanation - is that the content of a tiddler I should add or replace within my wiki?  Or is it already part of the core?  Does it need a special $:/tags... tag?

JWHoneycutt


BurningTreeC

unread,
Jun 30, 2018, 2:01:52 PM6/30/18
to tiddl...@googlegroups.com
@JWHoneycutt
It should replace the text content of the tiddler $:/core/modules/filters/get.js
You find it by typing "$:/core/modules/filters/get.js" in the search field, then clicking the advanced search button and selecting the "shadow" tab

I will also test it the coming days for performance and reliability and post updates here if I change something, so you'll know

The syntax for a task in a tiddler is this:

in a new line:

;Task: my new task

followed by another new line

then, when you save the tiddler, a new tiddler with the title "my new task" gets created if it doesn't already exist and will be tagged with "Task"


hope it works for you,
BTC

BurningTreeC

unread,
Jun 30, 2018, 2:02:48 PM6/30/18
to TiddlyWiki
edit: the "shadow" tab

Mark S.

unread,
Jun 30, 2018, 5:09:52 PM6/30/18
to TiddlyWiki
@ BTC

Here it is packaged as a plugin. http://mashive.tiddlyspot.com/

-- Mark
regexps.json
Reply all
Reply to author
Forward
0 new messages