Created
October 22, 2012 14:16
-
-
Save ttscoff/3931703 to your computer and use it in GitHub Desktop.
Ruby function to find the first TaskPaper project matching a title fragment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def first_matching_project(fragment) | |
%x{osascript <<'APPLESCRIPT' | |
tell application "TaskPaper" | |
tell front document | |
set projectlist to name of projects | |
set frag to "#{fragment}" | |
repeat with aproject in projectlist | |
if (offset of "#{fragment}" in aproject) > 0 then return (aproject as string) | |
end repeat | |
return "Inbox" | |
end tell | |
end tell | |
APPLESCRIPT}.strip | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment