Use this script to implement a version of Mark Forster’s Autofocus time management system.
tell application "FoldingText"
tell front document
evaluate script "function(editor, options) {
var tree = editor.tree(),
item = editor.selectedRange().startNode,
itemPage = item.parent;
while (itemPage && itemPage.text() !== 'Autofocus') {
itemPage = itemPage.parent;
}
if (itemPage) {
var pagesParent = itemPage.parent,
lastPage = pagesParent.lastChild,
reenterItem = tree.createNode(item.line());
tree.beginUpdates();
if (lastPage === itemPage || lastPage.children().length > 30) {
lastPage = tree.createNode('# Autofocus.todo');
pagesParent.appendChild(tree.createNode());
pagesParent.appendChild(lastPage);
lastPage.appendChild(tree.createNode());
}
lastPage.appendChild(reenterItem);
item.addTag('done', new Date().toISOString().substr(0, 10));
tree.endUpdates();
}
}" with options {}
end tell
end tell
Watch this (dated, but function still same) screencast to see how to use this script.
The autofocus system is paper based, but it can be implemented on the computer by using a new heading for each page. To try out the script first create a new document and paste in the following text:
# Autofocus.todo
- item 1
- item 3
# Autofocus.todo
- item 2
Then place your cursor on one of the todo items and run the script. The item will be marked “done” and then reentered on on the last page.
In this implementation an Autofocus.todo
heading is created for each page. Use unordered list syntax for items so that you can get a nice clickable checkbox to cross the items off the list. The process is the same as described on Mark’s page, except:
-
Instead of using physical pages add your items to “Autofocus.todo” headings.
-
Instead of physically crossing items of your lists, click the checkbox that’s added by .todo mode. That will add the
@done
tag to the item so that it gets visually crossed off. -
Instead of manually re-entering items that you are not finished with, place your text cursor on the items line, and run the linked to “Re-Enter” script. That will move a copy of the item to the end of your list. And it will automatically create “Autofocus.todo” headings as needed.
Update
- This script now adds date value along with “done” tag.
Update 2
- Fixed to work with latest FoldingText