emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master decd983 4/4: EUDC: Add more BBDB >= 3 support


From: Thomas Fitzsimmons
Subject: [Emacs-diffs] master decd983 4/4: EUDC: Add more BBDB >= 3 support
Date: Wed, 15 Aug 2018 22:15:04 -0400 (EDT)

branch: master
commit decd9839819277c34c13f1771ef73626208cbdd9
Author: Thomas Fitzsimmons <address@hidden>
Commit: Thomas Fitzsimmons <address@hidden>

    EUDC: Add more BBDB >= 3 support
    
    * lisp/net/eudcb-bbdb.el Declare BBDB >= 3 functions.
    (eudc-bbdb-field): Add translation from company to
    organization.
    (eudc-bbdb-extract-phones, eudc-bbdb-extract-addresses)
    (eudc-bbdb-format-record-as-result): Call BBDB >= 3 functions.
---
 lisp/net/eudcb-bbdb.el | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el
index fb618d1..ac4814a 100644
--- a/lisp/net/eudcb-bbdb.el
+++ b/lisp/net/eudcb-bbdb.el
@@ -47,10 +47,13 @@
 BBDB < 3 used `net'; BBDB >= 3 uses `mail'."
   ;; This just-in-time translation permits upgrading from BBDB 2 to
   ;; BBDB 3 without restarting Emacs.
-  (if (and (eq field-symbol 'net)
-          (eudc--using-bbdb-3-or-newer-p))
-      'mail
-    field-symbol))
+  (cond ((and (eq field-symbol 'net)
+             (eudc--using-bbdb-3-or-newer-p))
+         'mail)
+        ((and (eq field-symbol 'company)
+             (eudc--using-bbdb-3-or-newer-p))
+         'organization)
+        (t field-symbol)))
 
 (defvar eudc-bbdb-attributes-translation-alist
   '((name . lastname)
@@ -124,18 +127,31 @@ BBDB < 3 used `net'; BBDB >= 3 uses `mail'."
 (declare-function bbdb-record-addresses "ext:bbdb" t) ; via bbdb-defstruct
 (declare-function bbdb-records          "ext:bbdb"
                   (&optional dont-check-disk already-in-db-buffer))
+(declare-function bbdb-record-notes "ext:bbdb" t) ; via bbdb-defstruct
+
+;; External, BBDB >= 3.
+(declare-function bbdb-phone-label "ext:bbdb" t) ; via bbdb-defstruct
+(declare-function bbdb-record-phone "ext:bbdb" t) ; via bbdb-defstruct
+(declare-function bbdb-record-address "ext:bbdb" t) ; via bbdb-defstruct
+(declare-function bbdb-record-xfield "ext:bbdb" t) ; via bbdb-defstruct
 
 (defun eudc-bbdb-extract-phones (record)
   (require 'bbdb)
   (mapcar (function
           (lambda (phone)
             (if eudc-bbdb-use-locations-as-attribute-names
-                (cons (intern (bbdb-phone-location phone))
+                (cons (intern (if (eudc--using-bbdb-3-or-newer-p)
+                                   (bbdb-phone-label phone)
+                                 (bbdb-phone-location phone)))
                       (bbdb-phone-string phone))
               (cons 'phones (format "%s: %s"
-                                    (bbdb-phone-location phone)
+                                    (if (eudc--using-bbdb-3-or-newer-p)
+                                         (bbdb-phone-label phone)
+                                       (bbdb-phone-location phone))
                                     (bbdb-phone-string phone))))))
-         (bbdb-record-phones record)))
+         (if (eudc--using-bbdb-3-or-newer-p)
+              (bbdb-record-phone record)
+            (bbdb-record-phones record))))
 
 (defun eudc-bbdb-extract-addresses (record)
   (require 'bbdb)
@@ -157,7 +173,9 @@ BBDB < 3 used `net'; BBDB >= 3 uses `mail'."
                   (cons (intern (bbdb-address-location address)) val)
                 (cons 'addresses (concat (bbdb-address-location address)
                                          "\n" val))))
-            (bbdb-record-addresses record))))
+            (if (eudc--using-bbdb-3-or-newer-p)
+                (bbdb-record-address record)
+              (bbdb-record-addresses record)))))
 
 (defun eudc-bbdb-format-record-as-result (record)
   "Format the BBDB RECORD as a EUDC query result record.
@@ -176,7 +194,11 @@ The record is filtered according to 
`eudc-bbdb-current-return-attributes'"
        (setq val (eudc-bbdb-extract-phones record)))
        ((eq attr 'addresses)
        (setq val (eudc-bbdb-extract-addresses record)))
-       ((memq attr '(firstname lastname aka company net notes))
+       ((eq attr 'notes)
+        (if (eudc--using-bbdb-3-or-newer-p)
+            (setq val (bbdb-record-xfield record 'notes))
+          (setq val (bbdb-record-notes record))))
+       ((memq attr '(firstname lastname aka company net))
        (setq val (eval
                   (list (intern
                          (concat "bbdb-record-"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]