diff options
| author | Thomas Fitzsimmons | 2018-08-15 14:32:00 -0400 |
|---|---|---|
| committer | Thomas Fitzsimmons | 2018-08-15 21:43:03 -0400 |
| commit | decd9839819277c34c13f1771ef73626208cbdd9 (patch) | |
| tree | ebab96e39e0c36f8dd08eb58379ad45dedcc209e | |
| parent | af991f15e6d6479e3b4c5a545df4fb09458d100a (diff) | |
| download | emacs-decd9839819277c34c13f1771ef73626208cbdd9.tar.gz emacs-decd9839819277c34c13f1771ef73626208cbdd9.zip | |
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.
| -rw-r--r-- | lisp/net/eudcb-bbdb.el | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el index fb618d12098..ac4814a25cb 100644 --- a/lisp/net/eudcb-bbdb.el +++ b/lisp/net/eudcb-bbdb.el | |||
| @@ -47,10 +47,13 @@ | |||
| 47 | BBDB < 3 used `net'; BBDB >= 3 uses `mail'." | 47 | BBDB < 3 used `net'; BBDB >= 3 uses `mail'." |
| 48 | ;; This just-in-time translation permits upgrading from BBDB 2 to | 48 | ;; This just-in-time translation permits upgrading from BBDB 2 to |
| 49 | ;; BBDB 3 without restarting Emacs. | 49 | ;; BBDB 3 without restarting Emacs. |
| 50 | (if (and (eq field-symbol 'net) | 50 | (cond ((and (eq field-symbol 'net) |
| 51 | (eudc--using-bbdb-3-or-newer-p)) | 51 | (eudc--using-bbdb-3-or-newer-p)) |
| 52 | 52 | 'mail) | |
| 53 | field-symbol)) | 53 | ((and (eq field-symbol 'company) |
| 54 | (eudc--using-bbdb-3-or-newer-p)) | ||
| 55 | 'organization) | ||
| 56 | (t field-symbol))) | ||
| 54 | 57 | ||
| 55 | (defvar eudc-bbdb-attributes-translation-alist | 58 | (defvar eudc-bbdb-attributes-translation-alist |
| 56 | '((name . lastname) | 59 | '((name . lastname) |
| @@ -124,18 +127,31 @@ BBDB < 3 used `net'; BBDB >= 3 uses `mail'." | |||
| 124 | (declare-function bbdb-record-addresses "ext:bbdb" t) ; via bbdb-defstruct | 127 | (declare-function bbdb-record-addresses "ext:bbdb" t) ; via bbdb-defstruct |
| 125 | (declare-function bbdb-records "ext:bbdb" | 128 | (declare-function bbdb-records "ext:bbdb" |
| 126 | (&optional dont-check-disk already-in-db-buffer)) | 129 | (&optional dont-check-disk already-in-db-buffer)) |
| 130 | (declare-function bbdb-record-notes "ext:bbdb" t) ; via bbdb-defstruct | ||
| 131 | |||
| 132 | ;; External, BBDB >= 3. | ||
| 133 | (declare-function bbdb-phone-label "ext:bbdb" t) ; via bbdb-defstruct | ||
| 134 | (declare-function bbdb-record-phone "ext:bbdb" t) ; via bbdb-defstruct | ||
| 135 | (declare-function bbdb-record-address "ext:bbdb" t) ; via bbdb-defstruct | ||
| 136 | (declare-function bbdb-record-xfield "ext:bbdb" t) ; via bbdb-defstruct | ||
| 127 | 137 | ||
| 128 | (defun eudc-bbdb-extract-phones (record) | 138 | (defun eudc-bbdb-extract-phones (record) |
| 129 | (require 'bbdb) | 139 | (require 'bbdb) |
| 130 | (mapcar (function | 140 | (mapcar (function |
| 131 | (lambda (phone) | 141 | (lambda (phone) |
| 132 | (if eudc-bbdb-use-locations-as-attribute-names | 142 | (if eudc-bbdb-use-locations-as-attribute-names |
| 133 | (cons (intern (bbdb-phone-location phone)) | 143 | (cons (intern (if (eudc--using-bbdb-3-or-newer-p) |
| 144 | (bbdb-phone-label phone) | ||
| 145 | (bbdb-phone-location phone))) | ||
| 134 | (bbdb-phone-string phone)) | 146 | (bbdb-phone-string phone)) |
| 135 | (cons 'phones (format "%s: %s" | 147 | (cons 'phones (format "%s: %s" |
| 136 | (bbdb-phone-location phone) | 148 | (if (eudc--using-bbdb-3-or-newer-p) |
| 149 | (bbdb-phone-label phone) | ||
| 150 | (bbdb-phone-location phone)) | ||
| 137 | (bbdb-phone-string phone)))))) | 151 | (bbdb-phone-string phone)))))) |
| 138 | (bbdb-record-phones record))) | 152 | (if (eudc--using-bbdb-3-or-newer-p) |
| 153 | (bbdb-record-phone record) | ||
| 154 | (bbdb-record-phones record)))) | ||
| 139 | 155 | ||
| 140 | (defun eudc-bbdb-extract-addresses (record) | 156 | (defun eudc-bbdb-extract-addresses (record) |
| 141 | (require 'bbdb) | 157 | (require 'bbdb) |
| @@ -157,7 +173,9 @@ BBDB < 3 used `net'; BBDB >= 3 uses `mail'." | |||
| 157 | (cons (intern (bbdb-address-location address)) val) | 173 | (cons (intern (bbdb-address-location address)) val) |
| 158 | (cons 'addresses (concat (bbdb-address-location address) | 174 | (cons 'addresses (concat (bbdb-address-location address) |
| 159 | "\n" val)))) | 175 | "\n" val)))) |
| 160 | (bbdb-record-addresses record)))) | 176 | (if (eudc--using-bbdb-3-or-newer-p) |
| 177 | (bbdb-record-address record) | ||
| 178 | (bbdb-record-addresses record))))) | ||
| 161 | 179 | ||
| 162 | (defun eudc-bbdb-format-record-as-result (record) | 180 | (defun eudc-bbdb-format-record-as-result (record) |
| 163 | "Format the BBDB RECORD as a EUDC query result record. | 181 | "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'" | |||
| 176 | (setq val (eudc-bbdb-extract-phones record))) | 194 | (setq val (eudc-bbdb-extract-phones record))) |
| 177 | ((eq attr 'addresses) | 195 | ((eq attr 'addresses) |
| 178 | (setq val (eudc-bbdb-extract-addresses record))) | 196 | (setq val (eudc-bbdb-extract-addresses record))) |
| 179 | ((memq attr '(firstname lastname aka company net notes)) | 197 | ((eq attr 'notes) |
| 198 | (if (eudc--using-bbdb-3-or-newer-p) | ||
| 199 | (setq val (bbdb-record-xfield record 'notes)) | ||
| 200 | (setq val (bbdb-record-notes record)))) | ||
| 201 | ((memq attr '(firstname lastname aka company net)) | ||
| 180 | (setq val (eval | 202 | (setq val (eval |
| 181 | (list (intern | 203 | (list (intern |
| 182 | (concat "bbdb-record-" | 204 | (concat "bbdb-record-" |