Skip to content

Instantly share code, notes, and snippets.

@alexwlchan
Created February 28, 2017 09:47
Show Gist options
  • Save alexwlchan/163ab04bda82627091d63d717c14b67a to your computer and use it in GitHub Desktop.
Save alexwlchan/163ab04bda82627091d63d717c14b67a to your computer and use it in GitHub Desktop.
// auto_collapse_deferred_items.js
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// This script collapses any projects with the @defer tag in the frontmost
// window. Useful for tidying up the window, so I don't have to see the
// detail associated with those projects.
'use strict'
function TaskPaperCollapseDeferredItems(editor, options) {
var projects = editor.outline.evaluateItemPath('//@type=project');
for (idx in projects) {
var project = projects[idx];
if (project.hasAttribute("data-defer")) {
editor.setCollapsed(project);
}
}
return 0;
}
Application("TaskPaper").documents[0].evaluate({
script: TaskPaperCollapseDeferredItems.toString()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment