The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus 1 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
omnifocus: links Thread Tools Search this Thread Display Modes
Quote:
Originally Posted by gshenaut View Post
But that takes me back to "inherent ambiguity": Is there some way to not include projects with names like "Foobar" for input "Foo" using "complete"? As I understand it, invoking «*complete "Foo"*» will return all projects whose name contains "Foo" as a substring, including "Foobar", but it would *not* be erroneous to have two different projects named like that.
You should be able to just use the first match: if there's an exact match, it should always be listed first. (If not, please let us know as that's a bug!)
 
Quote:
Originally Posted by Ken Case View Post
You should be able to just use the first match: if there's an exact match, it should always be listed first. (If not, please let us know as that's a bug!)
Complete does work as advertised - multiple matches are sorted by their match score, with the best matches first.

(Of course, the best match is not necessarily an exact match, and even when the first match is an exact one, one can not exclude the possibility that the 2nd and 3rd up to Nth matches may also be exact ... Nothing constrains top level project names to be unique)

It is not too difficult to iterate through the match list, gathering any exact matches from the start of it.

(Though it might be helpful to add an ExactMatchesOnly option to Complete ...)

--

Last edited by RobTrew; 2010-05-07 at 11:13 PM..
 
I really appreciate all the help.

Here's another glitch that I don't know how to handle. In OmniFocus, I have my projects in folders. For example, there's a folder "Writing". So suppose I have a writing project called "Foobar". Well, the "complete" command appears to return "Writing : Foobar" as the name of the project, in a structure of this form:
Code:
{name:"Writing : Foobar", xml:"Writing : <span class=\"match\">Foobar</span>", id:"jexW10LHv6C", score:195}
Therefore, I never get any exact matches for project names. What's odd about this is that in the XML version of the database, there is a "<name>Foobar</name>" tag in the project record, with just a "<folder idref=XXX /> back to the enclosing folder. So in a sense, it "should" be easier for "complete" to just work on the project name in isolation.

On the other hand, this may be related to the "inherent ambiguity" issue: now for there to be two projects that "complete" returns the same name for, they will also have to be in identical folder hierarchies, which I suppose is theoretically possible, but probably shouldn't be permitted.

Anyway, is there a modifier or some other way to make "complete ... as project" not prepend projects' folder hierarchies, or to do something like
Code:
s/..*: //
on the values that it does return?

Greg
 
Quote:
Originally Posted by gshenaut View Post
is there a modifier or some other way to make "complete ... as project" not prepend projects' folder hierarchies,
No. Probably better to assemble the whole path, in the " : " delimited format, and apply complete to that. Less risk of multiple matches, for a start.
 
But what I'm doing is going from the name of a filesystem folder to the name of an OmniFocus project, so "I" won't know where a given filesystem project folder is in the OmniFocus folder hierarchy.

I decided to use Applescript only to provide a list of "possible matches" and their IDs, and to do the rest in a trivial ksh script (which I'm far more used to):
Code:
#!/bin/ksh

# Open all OmniFocus project IDs named arg1
getProj(){
	projName="$1"
	Possibles="$( osascript <<FIN
tell application "OmniFocus"
	set oDoc to default document
	using terms from application "OmniFocus"
		tell oDoc
			set lstNameID to ""
			set lstComplete to complete "$projName" as project
			if (count of lstComplete) > 0 then
				repeat with recProject in lstComplete
					set lstNameID to lstNameID & (id of recProject) & " " & (name of recProject) & "\n"
				end repeat
			end if
		end tell
	end using terms from
	lstNameID
end tell
FIN
 )"

activate=false
print -- "$Possibles" | while read id proj ; do
	if [[ ${proj#*: } == $projName ]] ; then
		open "omnifocus:///task/$id"
		activate=true
	fi
done
if [[ $activate == true ]] ; then
	osascript -e "tell app \"Omnifocus\" to activate"
fi
}

getProj "$1"
This appears to work well for my purposes and is far less kludgy than plowing through the XML file directly. It could be made more elegant, perhaps, but this is probably close enough.

The one remaining issue: is there some way to tell OmniFocus not to open any windows on startup? Or alternatively, to use Applescript to close all currently open OmniFocus windows?

Greg
 
Quote:
Originally Posted by gshenaut View Post
is there some way ... to use Applescript to close all currently open OmniFocus windows?
Code:
tell application id "com.omnigroup.OmniFocus"
	tell front document to close document windows
end tell
or perhaps

Code:
tell application id "com.omnigroup.OmniFocus"
	tell front document to set visible of document windows to false
end tell
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open OmniFocus links in the same window? JustinLuey OmniFocus 1 for Mac 0 2012-06-25 05:20 PM
Links to OmniFocus from another app plopp OmniFocus for iPhone 1 2009-10-15 04:35 PM
Ad hoc links OmniFocus <--> Devonthink RobTrew OmniFocus 1 for Mac 4 2009-06-23 02:22 PM
'Clickable' URLs or web-links in OmniFocus Bruce L OmniFocus 1 for Mac 5 2007-12-16 06:56 PM
OmniFocus-Mail Links curt.clifton OmniFocus 1 for Mac 60 2007-06-20 04:32 PM


All times are GMT -8. The time now is 08:50 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.