searching address book (was Re: [TxMt] create email from document)

Grant Hollingworth grant at antiflux.org
Tue Nov 7 20:02:52 UTC 2006


* Oliver Taylor <oliver at ollieman.net> [2006-11-07 01:04]:
>Something really interesting would be a way to lookup email addresses  
>in the users' address book, though I have no idea if this is even  
>possible.

That's a good idea.  I made a simple version using contacts[1], which doesn't require Address Book to be open.  I put it in the Text bundle because it seems applicable everywhere.  Typing ctrl-shift-cmd-a (what's the easiest way of typing those key glyphs?) will replace the current selection or word with a name and email address returned by contacts.

TODO:

* pop up a list for multiple matches, instead of just using the first one
* use osascript as a backup
* wrap name in quotation marks if necessary
* don't return error message on failure

[1] http://gnufoo.org/contacts/
-------------- next part --------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>beforeRunningCommand</key>
	<string>nop</string>
	<key>bundleUUID</key>
	<string>B7BC3FFD-6E4B-11D9-91AF-000D93589AF6</string>
	<key>command</key>
	<string>NAME=${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}
echo -n $(contacts -HS -f "%n <%e>" "$NAME" | head -1)</string>
	<key>fallbackInput</key>
	<string>word</string>
	<key>input</key>
	<string>selection</string>
	<key>keyEquivalent</key>
	<string>^@A</string>
	<key>name</key>
	<string>Find Email Address in Address Book</string>
	<key>output</key>
	<string>replaceSelectedText</string>
	<key>uuid</key>
	<string>224ED9D6-BA12-473C-A589-F3EB8902E31D</string>
</dict>
</plist>


More information about the textmate mailing list