

Hacking your OSX Address Book with C, Racket and LaTeX  - plinkplonk
http://matt.might.net/articles/address-book-hacking/

======
js2
A very easy way to get to the address book (and anything that supports
Applescript/Apple events) from a higher level language is via
<http://appscript.sourceforge.net/>

I previously wrote something in Python to sync between LDAP and the OS X
address book using appscript. It was fairly straightforward. Edited to add:
<https://github.com/jaysoffian/absync/blob/master/absync>

~~~
riobard
Appscript is pretty cool! Is there anyway to produce a bundle and distribute
to other machines without Appscript installed?

------
sudont
Export via Applescript into CSV, for those without Xcode installed.

[http://hints.macworld.com/article.php?story=2004110421223917...](http://hints.macworld.com/article.php?story=20041104212239178)

Or, use this and Word: [http://www.techtalkpoint.com/articles/how-to-mail-
merge-appl...](http://www.techtalkpoint.com/articles/how-to-mail-merge-apple-
address-book-with-microsoft-word/)

I'm all about the geek credentials, and this is awesome. However, it's fairly
impractical, and a lot of dev's who use a mac don't know Cocoa.

~~~
Zev
To be slightly pedantic, neither CoreFoundation or AddressBook are part of the
Cocoa framework.

------
allenbrunson
okay, i see some problems here ...

why use the MacRoman character set? UTF8 is a much better default.

also, the code uses CFStringGetCStringPtr() as if it can't ever fail. from the
docs: "This function either returns the requested pointer immediately, with no
memory allocations and no copying, in constant time, or returns NULL. If the
latter is the result, call an alternative function such as the
CFStringGetCString() function to extract the characters"

~~~
mattmight
Thanks for the tip.

Fortunately, little Bobby Tables isn't one of my relatives.

I'll update it to use UTF8 when I get a free moment.

~~~
jessriedel
Context: <http://xkcd.com/327/>

------
julian37
Speaking of the Address Book and Lisp, here are two pages on how to access its
contents from Emacs:

<http://www.emacswiki.org/emacs/MacOSTweaks#toc3>

[http://slashusr.wordpress.com/2009/08/16/importing-
contacts-...](http://slashusr.wordpress.com/2009/08/16/importing-contacts-
from-osx-addressbook-to-emacs-bbdb/)

------
famoreira
Anyone care to explain why use S-Expression as opposed to plain CSV or json?

~~~
mattmight
Good question.

Why not CSV? S-Expressions are tree-structured, and that makes it easier to
handle things like whether or not someone has a spouse (or multiple spouses)
or a partner, or whether they have a title.

To parse S-Expressions, you just use (read) in Racket (or any Scheme for that
matter). CSV isn't hard to parse, but it's not a 6-character expression.

Why not JSON? JSON is tree-structured, so it accounts for the issues above.
But, most languages that slurp JSON don't have pattern-matching facilities as
powerful as Racket.

If you look at the patterns I wrote to chew up entries and spit out labels,
you'll see what I'm talking about.

Finally, the outputted S-Expressions are very human-readable.

/article author

~~~
famoreira
Thank you. I am trying to learn Lisp(Emacs Lisp and Clojure) and was curious
on your format choice. Great article btw.

------
drivebyacct2
Google Contacts -> Export -> Mail Merge

~~~
Tichy
What is Mail Merge?

~~~
callahad
Check out Duck Duck Go; it pulls snippets from Wikipedia and other data
sources right to the top of search results, which makes it easy to get the
gist of what something is, without much digging:
<http://duckduckgo.com/?q=mail+merge>

Plus, it's by our very own epi0Bauqu
(<http://news.ycombinator.com/user?id=epi0Bauqu>)

~~~
Tichy
Hm, somehow the first hits look like ads - perhaps a change of fonts would be
helpful? In any case, none provides the quick answer I was looking for (I
already guessed it is about mergin mails). But thanks!

