unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Thomas Fitzsimmons <fitzsim@fitzsim.org>
To: George McNinch <gmcninch@gmail.com>
Cc: 21971@debbugs.gnu.org
Subject: bug#21971: 25.1.50; EUDC conversion to BBDB 3 incompatibility
Date: Sun, 22 Nov 2015 11:36:37 -0500	[thread overview]
Message-ID: <m3twoe56ui.fsf@fitzsim.org> (raw)
In-Reply-To: <82610ucc5p.fsf@jobim-via-gmail.com> (George McNinch's message of "Sun, 22 Nov 2015 10:00:02 -0500")

[-- Attachment #1: Type: text/plain, Size: 3212 bytes --]

George McNinch <gmcninch@gmail.com> writes:

> Hi Thomas,
>
>     TF> With your eudc-ldap-bbdb-conversion-alist workaround still
>     TF> enabled, can you try the attached patch to see if it fixes
>     TF> exporting for you?
>
> Indeed, this works fine for me; thanks!
>
>     >> Note also that the setting of eudc-ldap-bbdb-conversion-alist I
>     >> made above isn't quite the original value. If I instead use the
>     >> original value, e.g. by instead using the original value
>     >> 
>     >> [which amounts to:
>     >> 
>     >> (setq eudc-ldap-bbdb-conversion-alist `((name . cn) (net . mail)
>     >> (address eudc-bbdbify-address postaladdress "Address") (phone
>     >> (eudc-bbdbify-phone telephonenumber "Phone")))
>     >> 
>     >> 
>     >> in the initialization of EUDC],
>     >> 
>     >> then when I press "b" on a record in the *Directory Query
>     >> Results* buffer, I get the error
>     >> 
>     >> eudc-bbdbify-phone: Symbol’s function definition is void:
>     >> bbdb-parse-phone-number
>
>     TF> OK, this seems like a separate issue.  I haven't investigated it
>     TF> yet.
>
> Right; should I have made a separate report, or is this OK?  

It's fine, we can work on it here.

> --------------------------------------------
> By the way:
>
> I wonder: if bbdb really now uses "mail" instead of "net", I'd think
> that (?) that eudc-ldap-bbdb-conversion-alist should instead read:
>
>   (setq eudc-ldap-bbdb-conversion-alist
>    `((name . cn)
>      (mail . mail)
>      (address eudc-bbdbify-address postaladdress "Address")))
>
> But that doesn't seem to work (I tried... I get then BBDB record with
> *no* mail field at all).
>
> In general, I find it difficult to work out what can be used in that
> alist. E.g. it seems that there is a key symbol ou for the record
> passed to eudc-create-bbdb-record.
>
> So I tried adding the pair
>
>  (Organizations . ou)
>
> to that alist, but it doens't seem to populate the "right part of the
> BBDB record" - in fact, the BBDB record gets a new line with an
> Organizations field, but it makes the BBDB unhappy (it eventually
> complains of an "illegal field" or something). I'd hoped to populate the
> bit that shows up to the right of the name when displaying the BBDB
> record, which I thought was called "Organizations".
>
> I also tried (organization . ou) and (company . ou) and maybe a few
> others, but nothing seemed to work and guessing doesn't seem so healthy,
> and looking at the code in eudc-export.el doesn't seem like
>
> Well, this is a distraction, and only tangentially related to the patch,
> but it does point out that it'd be nice to have a clearer definition of
> the fields on both sides of this conversion...!

Can you remove your eudc-ldap-bbdb-conversion-alist customization and
try the attached patch?  I think it will fix both the phone parsing and
organization missing issues.

I wouldn't worry about 'net unless you're customizing it directly.  It's
a change and I left the old 'net as the customization entry point, but
it will get converted to 'mail depending on which version of BBDB is in
use.

Thomas


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Improve-EUDC-to-BBDB-3-export.patch --]
[-- Type: text/x-patch, Size: 2255 bytes --]

From 25b742df574fc9ae8340a37409fc72ec2f40574b Mon Sep 17 00:00:00 2001
From: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Date: Sun, 22 Nov 2015 11:29:13 -0500
Subject: [PATCH] Improve EUDC to BBDB 3 export

* eudc-vars.el (eudc-ldap-bbdb-conversion-alist): Change phone
entry to single item.  Add company conversion.
* eudc-export.el (eudc-bbdbify-company): New function.
(eudc-bbdbify-phone): Add BBDB 3 support.
(bug#21971)
---
 lisp/net/eudc-export.el | 8 +++++++-
 lisp/net/eudc-vars.el   | 3 ++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/net/eudc-export.el b/lisp/net/eudc-export.el
index a65f555..f91f4ae 100644
--- a/lisp/net/eudc-export.el
+++ b/lisp/net/eudc-export.el
@@ -169,6 +169,10 @@ eudc-bbdbify-address
                   (string &optional number-type))
 (declare-function bbdb-string-trim "ext:bbdb" (string))
 
+(defun eudc-bbdbify-company (&rest organizations)
+  "Return ORGANIZATIONS as a list compatible with BBDB."
+  organizations)
+
 (defun eudc-bbdbify-phone (phone location)
   "Parse PHONE into a vector compatible with BBDB.
 PHONE is either a string supposedly containing a phone number or
@@ -179,7 +183,9 @@ eudc-bbdbify-phone
    ((stringp phone)
     (let (phone-list)
       (condition-case err
-	  (setq phone-list (bbdb-parse-phone-number phone))
+	  (setq phone-list (if (eudc--using-bbdb-3-or-newer-p)
+			       (bbdb-parse-phone phone)
+			     (bbdb-parse-phone-number phone)))
 	(error
 	 (if (string= "phone number unparsable." (cadr err))
 	     (if (not (y-or-n-p (format "BBDB claims %S to be unparsable--insert anyway? " phone)))
diff --git a/lisp/net/eudc-vars.el b/lisp/net/eudc-vars.el
index 8cffa8e..a08d175 100644
--- a/lisp/net/eudc-vars.el
+++ b/lisp/net/eudc-vars.el
@@ -369,7 +369,8 @@ eudc-ldap-bbdb-conversion-alist
   '((name . cn)
     (net . mail)
     (address . (eudc-bbdbify-address postaladdress "Address"))
-    (phone . ((eudc-bbdbify-phone telephonenumber "Phone"))))
+    (phone . (eudc-bbdbify-phone telephonenumber "Phone"))
+    (company . (eudc-bbdbify-company o)))
   "A mapping from BBDB to LDAP attributes.
 This is a list of cons cells (BBDB-FIELD . SPEC-OR-LIST) where
 BBDB-FIELD is the name of a field that must be defined in your BBDB
-- 
1.8.3.1


  reply	other threads:[~2015-11-22 16:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-21 14:30 bug#21971: 25.1.50; EUDC conversion to BBDB 3 incompatibility George McNinch
2015-11-22  2:44 ` Thomas Fitzsimmons
2015-11-22 15:00   ` George McNinch
2015-11-22 16:36     ` Thomas Fitzsimmons [this message]
2015-11-22 17:01       ` George McNinch
2015-11-23  2:46         ` Thomas Fitzsimmons

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3twoe56ui.fsf@fitzsim.org \
    --to=fitzsim@fitzsim.org \
    --cc=21971@debbugs.gnu.org \
    --cc=gmcninch@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).