Is there a way to set the search box in TaskPaper 3 through a script? I could do this in version 2 by using Applescript to tell TaskPaper 2 to:
set search field string to whateverText
This was handy because I could then use Alfred to trigger a search of my task list. I’m trying to figure out how to accomplish the same thing in TP3 preview. I appreciate any suggestions on how to go about this.
property pstrQuery : "//@done"
tell application "TaskPaper"
set strJS to "
function fnSetSearch(editor, options) {
return editor.itemPathFilter = options.query;
}
"
set lstDocs to documents
if lstDocs ≠ {} then
evaluate item 1 of lstDocs script strJS with options {query:pstrQuery}
end if
end tell
Thank you! I had been trying to figure out how to use the first script within Alfred, but your second post that demonstrated how to call the same function using Applescript worked perfectly. It runs well within Alfred (v1) as a tag search and gives me a starting point for adapting other scripts.
on alfred_script(q)
tell application "TaskPaper"
set strJS to "
function fnSetSearch(editor, options) {
return editor.setQuery(
options.query
);
}
"
set lstDocs to documents
if lstDocs ≠ {} then
evaluate item 1 of lstDocs script strJS with options {query:"//@" & q}
end if
end tell
end alfred_script
Thanks for catching that – there have been a few adjustments to the scripting interface in this last build of TaskPaper 3 – I will update it in the (EU) morning.
UPDATE done
(The earlier .setQuery() method is now replaced by the R/W .itemPathFilter property)