Skip to content

Instantly share code, notes, and snippets.

@DrLulz
Created January 27, 2015 19:15
Show Gist options
  • Select an option

  • Save DrLulz/7395489d6fbec9147841 to your computer and use it in GitHub Desktop.

Select an option

Save DrLulz/7395489d6fbec9147841 to your computer and use it in GitHub Desktop.
Search OmniOutliner front document. Select all rows which match the query and collapse all rows which don't.
set query to the text returned of (display dialog "Enter Your Search Term" default answer "QUERY" with title "Search OmniOutliner Front Document" with icon path to resource "OmniOutliner.icns" in bundle (path to application "OmniOutliner"))
tell application id "OOut"
try
set doc_name to name of front document
on error
activate
display dialog "No Document Open"
end try
set the_result to {}
set every_row to every row of front document
repeat with r in every_row
set row_text to text of topic cell of r
if query is in row_text then
set end of the_result to r
collapseAll rows of front document
end if
end repeat
repeat with i in the_result
set the_ancestors to the ancestors of i
repeat with j in the_ancestors
set expanded of j to true
end repeat
end repeat
set index of window 1 where name contains doc_name to 1
activate window 1
if the_result is {} then
activate
display dialog "The word " & query & " was not found." with icon path to resource "OmniOutliner.icns" in bundle (path to application "OmniOutliner")
else
tell front document to select items of the_result
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment