[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Proposal] New EUDC backend for macOS address book
From: |
Thomas Fitzsimmons |
Subject: |
Re: [Proposal] New EUDC backend for macOS address book |
Date: |
Sat, 02 May 2020 12:20:28 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi,
Jean-Christophe Helary <address@hidden>
writes:
>> On Apr 28, 2020, at 1:10, Thomas Fitzsimmons <address@hidden> wrote:
>>
>> Hi Alexander,
>>
>> Alexander Adolf <address@hidden> 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)
- Re: [Proposal] New EUDC backend for macOS address book,
Thomas Fitzsimmons <=