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: Sat, 02 May 2020 12:20:28 -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="102469"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Alexander Adolf , emacs-devel@gnu.org To: Jean-Christophe Helary Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 02 18:21:34 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 1jUutR-000QXc-9b for ged-emacs-devel@m.gmane-mx.org; Sat, 02 May 2020 18:21:33 +0200 Original-Received: from localhost ([::1]:56892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUutQ-0004Y1-AT for ged-emacs-devel@m.gmane-mx.org; Sat, 02 May 2020 12:21:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUusS-0003fi-KE for emacs-devel@gnu.org; Sat, 02 May 2020 12:20:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUusR-0004WO-An for emacs-devel@gnu.org; Sat, 02 May 2020 12:20:32 -0400 Original-Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:40004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jUusQ-0004Vg-OR for emacs-devel@gnu.org; Sat, 02 May 2020 12:20:30 -0400 Original-Received: by mail-qv1-xf2f.google.com with SMTP id fb4so6229457qvb.7 for ; Sat, 02 May 2020 09:20:30 -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=HH6akvp/leDMDgg/gG4FO4NRk6qXA+ly3AbwrzBCcXA=; b=umk9edkhfVVyNkPGQRd0Yek1T1YgQty5jC1wT9KrZr6wh+Zi7WJv0Djj0IjLU4WLGm k5fcX3rWR9DuaZIGYGsvMDMJ59XWZeW1+ejf6cOVTP0mFpuFJwbDOQUnnawzMiJ2446f xtkVnmFHzYQv/qXp9c7MK5v4r879Z0UIPcbibvt8vwlBHIx2EEo81KFXZK0/T88802hv LmqBBvkAhOYvRtnoTEm69IZ/2P8JSQc24rvmmhyjZx0iH9phJIpvvBZQr2T0DU09eiwg qGaMtFKY4bFJf0ZCLaj8Cpy6a2yRjQS+BBLirFYwOqsSUZeAlgCIYbqhwZs7GeKXX7O3 QhCA== 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=HH6akvp/leDMDgg/gG4FO4NRk6qXA+ly3AbwrzBCcXA=; b=HeYzptfg5SzzUlIDfCIb3nRvqyPIvc+kbrYK1QH/+s7ds24PYq9xrk7B2K7mHZy0BE spvXfmF8GyYhFtBJSB9GstD/o+0Mm1p1csJ9WK6XGJcdUojvlJPn9gFnltwxu6qe8uUm p48BSklyhbMAxoVI3rca4sW6bg6+U7TxAe7duH88GEA+3/ff8eq4xXbefonbe1SiXS9M O/hx+4hy464nqndi/7SqLF9pOBmNxjsdzypBwakoERMEbCof833V7oahBoL8jifux7i0 un81SD31bjRUMTBwABDZP6e6qDUmWyT0zhV0B38h2W5msAd64/7eSMISouOPA1V7BbSy 3NjQ== X-Gm-Message-State: AGi0PuYTm+6ndxYOEiiCe7j6f22l33f4PAZ/S1wCbiN941Pk0BZSfZbh r7aO2p9tr9FPXtiMYSwX6ZjKJA== X-Google-Smtp-Source: APiQypLHPoG/yncVlupGMCHdj/qQdcv1nENLkAUUppf0tS7XqWdM4mW71n3w3BUqm2wGGK8tTzXfIA== X-Received: by 2002:ad4:446a:: with SMTP id s10mr9073064qvt.31.1588436429554; Sat, 02 May 2020 09:20:29 -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 d17sm5973644qtb.74.2020.05.02.09.20.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 May 2020 09:20:28 -0700 (PDT) In-Reply-To: (Jean-Christophe Helary's message of "Tue, 28 Apr 2020 01:41:30 +0900") Received-SPF: none client-ip=2607:f8b0:4864:20::f2f; envelope-from=fitzsim@fitzsim.org; helo=mail-qv1-xf2f.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::f2f 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:248487 Archived-At: Hi, Jean-Christophe Helary writes: >> On Apr 28, 2020, at 1:10, Thomas Fitzsimmons wrote: >> >> Hi Alexander, >> >> Alexander Adolf writes: >> >>> 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? > > The application that is called in the applescript is called "Contacts". > > Before July 2012, when macos 10.8 was released, it was called "Address Book". > > So if the script wants to support machines with an OS older that 10.8 > there will be a need to check the OS version and change the name of > the application that is called. OK, thanks. Alexander, I see you report an error if osascript is not present. Can you add a separate check via AppleScript for whether "Contacts" (or failing that, "Address Book") is running and accessible? Then the user would get a clear error if osascript can't access the application for whatever reason. Can you also use the AppleScript line continuation character (U+00AC, from what I can tell from some online searches) to wrap the longest line to under 80 columns? > I don't remember and can't find on the web whether there was an > Address Book on systems before OSX, but even if there was, I don't > think emacs supports such old proprietary systems. > > Regarding the code itself, it looks simple enough that it would work > on systems with old versions of Address Book but that would require > some testing. OK, thanks for reviewing. > One could ask people on the AppleScript User list for their support, > or some other place (MacScripters ?) > > As far as I can tell, the Applescript itself (I've not tested the > inclusion in the emacslisp code) works fine on the latest macos > version. OK, thanks. Alexander, given Jean-Christophe's research, and once the above AppleScript-related comments are sorted out, I think this is fine to go in, code-wise. Would you be able to write a section in the EUDC manual describing the backend and how it relates to eudcb-mab.el? I don't think it hurts to offer both backends, provided they're documented and contrasted in the EUDC manual. Back in 2015, there was a proposal to have the eudcb-mab.el backend query the SQLite database directly: https://lists.gnu.org/archive/html/emacs-devel/2015-02/msg01033.html The code was good, but the author never completed the copyright assignment procedure. I tried following up but never heard back. It's unfortunate because I think that approach could be useful, as an alternative to eudcb-macos-contacts. It would allow, for example, using the contacts database in reference-only mode on systems that do not provide "contacts" or "osascript" binaries. I'd like to keep the eudcb-mab.el backend around in case that effort is ever revived. Thomas diff --git a/lisp/net/eudcb-macos-contacts.el b/lisp/net/eudcb-macos-contacts.el index 49c878b054..67808b3677 100644 --- a/lisp/net/eudcb-macos-contacts.el +++ b/lisp/net/eudcb-macos-contacts.el @@ -1,4 +1,4 @@ -;;; eudcb-macos-contacts.el --- Emacs Unified Directory Client - macOS Contacts backend +;;; eudcb-macos-contacts.el --- EUDC - macOS Contacts backend ;; Copyright (C) 2020 condition-alpha.com @@ -17,7 +17,7 @@ ;;; Commentary: ;; This library provides an interface to the macOS Contacts app as -;; an EUDC data source. It uses AppleScript to interface with the +;; an EUDC data source. It uses AppleScript to interface with the ;; Contacts app on localhost, so no 3rd party tools are needed. ;;; Usage: @@ -50,7 +50,7 @@ eudc-macos-contacts-conversion-alist (defun eudc-macos-contacts-search-helper (str) "Helper function to query the Contacts app via AppleScript. Searches for all persons with a case-insensitive substring match -of STR in any of their name fileds (first, middle, or last)." +of STR in any of their name fields (first, middle, or last)." (if (executable-find "osascript") (call-process "osascript" nil t nil "-e" @@ -65,7 +65,8 @@ eudc-macos-contacts-search-helper end repeat get results as text end tell" str)) - (message "[eudc] Error in macOS Contacts: `osascript' executable not found"))) + (message + "[eudc] Error in macOS Contacts: `osascript' executable not found"))) (defun eudc-macos-contacts-query-internal (query &optional return-attrs)