From: Alexander Adolf <alexander.adolf@condition-alpha.com>
To: emacs-devel@gnu.org
Subject: [Proposal] New EUDC backend for macOS address book
Date: Mon, 27 Apr 2020 17:09:07 +0200 [thread overview]
Message-ID: <f1bd89cf6c17dc777f5596c0e2e69172@condition-alpha.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]
Dear Emacs Developers,
I am in the process of migrating my email workflow to `notmuch-mode'
within Emacs. While `notmuch-mode' provides a completion backend for
`company-mode' to get auto-completion for email addresses from your
notmuch email archive, I was looking for a way to give me
auto-completion for email addresses from my macOS address book, too.
My research lead me to EUDC [1], and its `eudcb-mab.el', but which
didn't work out of the box for me. Looking at the code, it turns out
that `eudcb-mab.el' accesses the SQLite file used by macOS address book
to store a local copy of the contacts, and reverse-engineers its
contents. This is however not documented by Apple as an "official" way
of accessing that data, and in fact Apple had recently changed the file
name of the SQLite. This broke `eudcb-mab.el' for me, as it was still
looking for the old file name. Also, since it is an undocumented file,
Apple may choose to not only change the file name, but also its inner
structure at any point.
[1] https://www.gnu.org/software/emacs/manual/html_mono/eudc.html
On the other hand, there is an Apple officially documented, and endorsed
way of accessing the macOS address book contacts, and this is via
AppleScript [2]. Being a published and documented API, it can probably
be expected to remain stable, and invariant towards any redesigns of the
macOS address book app that Apple may choose to undertake in the
foreseeable future.
[2] https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html
I hence set out to write a new backend for EUDC to get access to macOS
address book contacts via AppleScript. The result is
`eudcb-macos-contacts.el', which is enclosed with this message, and
which I would kindly like to propose for inclusion as part of EUDC (and
replacing the existing `eudcb-mab.el').
Yes, I have duly signed the copyright assignment (rt.gnu.org #1503473).
In my implementation, I found that - interestingly - there is an elisp
function in Emacs core, cunningly called `do_applescript()', and which
is intended to execute AppleScript on the macOS platform from within
Emacs. Unfortunately, I did find some oddities with it (see debbugs
#39890 [3]), but couldn't discern whether the cause was in
`do_applescript()' itself (so a fix could have been proposed), or in the
Apple library code it builds upon. I hence decided to instead use
`call-process()' to invoke the osascript [4] command line utility, which
ships as part of every macOS. This does work reliably for me, and yields
a more graceful overall behaviour of Emacs during large queries (again
see debbugs #39890 [3]).
[3] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39890
[4] https://ss64.com/osx/osascript.html
Many thanks in advance for your considerations, and looking forward to
your thoughts,
--alexander
[-- Attachment #2: eudcb-macos-contacts.el --]
[-- Type: application/emacs-lisp, Size: 4027 bytes --]
next reply other threads:[~2020-04-27 15:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 15:09 Alexander Adolf [this message]
2020-04-27 16:10 ` [Proposal] New EUDC backend for macOS address book Thomas Fitzsimmons
2020-04-27 16:41 ` Jean-Christophe Helary
2020-05-02 16:20 ` Thomas Fitzsimmons
2020-05-06 15:14 ` Alexander Adolf
2020-05-06 17:41 ` Thomas Fitzsimmons
2020-05-07 16:03 ` Alexander Adolf
2020-05-07 18:29 ` Thomas Fitzsimmons
2020-05-08 12:17 ` Alexander Adolf
2020-05-08 13:44 ` Thomas Fitzsimmons
2020-06-08 20:41 ` Alexander Adolf
2020-06-10 5:03 ` Thomas Fitzsimmons
2020-06-29 13:38 ` Alexander Adolf
2020-07-09 15:12 ` Alexander Adolf
2020-07-09 20:29 ` Thomas Fitzsimmons
2020-07-10 13:36 ` Alexander Adolf
2020-07-10 3:53 ` Richard Stallman
2020-07-14 14:46 ` Thomas Fitzsimmons
2020-07-15 3:49 ` Jean-Christophe Helary
2020-07-17 0:56 ` Richard Stallman
2020-08-09 1:57 ` Richard Stallman
2020-09-06 3:00 ` Thomas Fitzsimmons
2020-05-05 14:47 ` Alexander Adolf
2020-04-27 20:00 ` chad
2020-05-05 13:30 ` Alexander Adolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f1bd89cf6c17dc777f5596c0e2e69172@condition-alpha.com \
--to=alexander.adolf@condition-alpha.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.