From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Thomas Fitzsimmons Newsgroups: gmane.emacs.devel Subject: Re: [Proposal] New EUDC backend for macOS address book Date: Mon, 27 Apr 2020 12:10:01 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="76547"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Alexander Adolf Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 27 18:11:03 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jT6LX-000Jo2-Iv for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Apr 2020 18:11:03 +0200 Original-Received: from localhost ([::1]:54104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jT6LW-0005SX-Jp for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Apr 2020 12:11:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45146) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jT6Kd-0004k5-2k for emacs-devel@gnu.org; Mon, 27 Apr 2020 12:10:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jT6Kc-0007Zg-2R for emacs-devel@gnu.org; Mon, 27 Apr 2020 12:10:06 -0400 Original-Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:45786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jT6Kb-0007ZZ-Gw for emacs-devel@gnu.org; Mon, 27 Apr 2020 12:10:05 -0400 Original-Received: by mail-qk1-x735.google.com with SMTP id m67so18472593qke.12 for ; Mon, 27 Apr 2020 09:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fitzsim-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=dcCQZPE+F5Nq1NhPr31+OFdE4UL+SlVhgoBSiPfV3Z4=; b=mvANkwBvFPx2+aJ+8HyardEaTbmFQbvNYzw3Ka2imaYc5AmWDJhph4+REVrISsYq6a Regmk6k72Zq++4243qF0vLsNZM+/UCjam5zqk+cObGldTqsK/t6317ZXkuMbWa3duWdP YUF/gTO6nhjcemcVHnl6LNEl4w6cdkBWAjbrYUyXHhc9gjmQTQUMsf5eoBSiA/sZiNGQ fXKCMdXi9qD09wPPY1qT++hwqBqI9zs0fe7kmfAhWY3jMS2pkqn2U9n7Yqzs5N+mWosA CzPtKrdmVJDNOqAkexN+YnB+l9Dwln3Jakys6gOttAp4Lyw2pwJpbMDgvNZhlYfmlLcp RKgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=dcCQZPE+F5Nq1NhPr31+OFdE4UL+SlVhgoBSiPfV3Z4=; b=MTZt7Of1MBkxcgucxsa+SMeg9sx/ysTHHqpvEuhSiJncawEuIjz/zg9HAx6S0SqXay KizVQafcc8OUD1DkyL5WXiKgQDVIVPur4T90z5ybo/TiYnVm67JeU0jGshKeebfJXhqJ jBKMRz6ihwM4B1c9nUZLeS2ZU1UWmM3j/NtsTWDjP8wzGVdavIdT9QObF3J4lbuhXeDk nM48gjV1iEp6G9MeskfeG6E4s42Ik9owvs1YP0hgaLyrG5yskj2bWT5Gwut7bNdLR3fv nf9J4GtJKvINK674p2p7/EgCtdP25M7C4owcPqtCYJPqwxaKsPhOKurmerlGvBvkGMQK MlwQ== X-Gm-Message-State: AGi0PuZ4Anof7N3zfsvzoPYOejxCQo7GFr7F/UEsmD+qhwWY9qzjV7C7 h50WoUjD8yDXiZ8sETfwgSrPFWbot2o= X-Google-Smtp-Source: APiQypIjPbBq9RhMw/dxbwPdD5N0ezvQPAbVUSlZ1hFaE9boMMSGT/Pm/zRLen3PqOSIVQDbMJYIMw== X-Received: by 2002:a05:620a:cd7:: with SMTP id b23mr22787560qkj.22.1588003803475; Mon, 27 Apr 2020 09:10:03 -0700 (PDT) Original-Received: from localhost.localdomain (69-165-165-189.dsl.teksavvy.com. [69.165.165.189]) by smtp.gmail.com with ESMTPSA id h25sm10939512qto.87.2020.04.27.09.10.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Apr 2020 09:10:02 -0700 (PDT) In-Reply-To: (Alexander Adolf's message of "Mon, 27 Apr 2020 17:09:07 +0200") Received-SPF: none client-ip=2607:f8b0:4864:20::735; envelope-from=fitzsim@fitzsim.org; helo=mail-qk1-x735.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::735 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:247943 Archived-At: Hi Alexander, Alexander Adolf writes: > 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. Thanks for working on this, and for the background information. It sounds like the AppleScript-based approach is superior and the way forward. However, I'd still like to know more about how eudcb-mab.el failed, so that we can discuss backward compatibility. Was the incorrect file path the only issue preventing eudcb-mab.el from working for you? > 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. OK. > 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'). Do you have a sense for how far back the AppleScript method will work? i.e., would it work on all systems on which eudcb-mab.el currently works? Do you think we should maintain eudcb-mab and eudcb-macos-contacts in parallel, at least for a few releases, and recommend eudcb-macos-contacts to existing eudcb-mab users? > Yes, I have duly signed the copyright assignment (rt.gnu.org #1503473). Great! > 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 Thanks for the detailed bug report. I hope someone with access to a system to test AppleScript and/or the required expertise will comment there. Thomas