emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/eudc-bbdb-3 c80692b 05/15: EUDC: Keep phone and ad


From: Thomas Fitzsimmons
Subject: [Emacs-diffs] scratch/eudc-bbdb-3 c80692b 05/15: EUDC: Keep phone and address lists in BBDB-order
Date: Tue, 21 Nov 2017 23:47:51 -0500 (EST)

branch: scratch/eudc-bbdb-3
commit c80692bc69cda63a869d0402c4080aec9d7d2abb
Author: Thomas Fitzsimmons <address@hidden>
Commit: Thomas Fitzsimmons <address@hidden>

    EUDC: Keep phone and address lists in BBDB-order
    
    * lisp/net/eudcb-bbdb.el (eudc-bbdb-extract-phones): Return
    phone numbers in the same order in which they are stored in
    BBDB.
    (eudc-bbdb-extract-addresses): Likewise.
---
 lisp/net/eudcb-bbdb.el | 57 ++++++++++++++++++++++++++------------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el
index 1bb0daa..7370225 100644
--- a/lisp/net/eudcb-bbdb.el
+++ b/lisp/net/eudcb-bbdb.el
@@ -127,37 +127,40 @@ BBDB < 3 used `net'; BBDB >= 3 uses `mail'."
 
 (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))
-                      (bbdb-phone-string phone))
-              (cons 'phones (format "%s: %s"
-                                    (bbdb-phone-location phone)
-                                    (bbdb-phone-string phone))))))
-         (bbdb-record-phones record)))
+  ;; Keep same order as in BBDB record.
+  (nreverse
+   (mapcar (function
+           (lambda (phone)
+             (if eudc-bbdb-use-locations-as-attribute-names
+                 (cons (intern (bbdb-phone-location phone))
+                       (bbdb-phone-string phone))
+               (cons 'phones (format "%s: %s"
+                                     (bbdb-phone-location phone)
+                                     (bbdb-phone-string phone))))))
+          (bbdb-record-phones record))))
 
 (defun eudc-bbdb-extract-addresses (record)
   (require 'bbdb)
   (let (s c val)
-    (mapcar (lambda (address)
-             (setq c (bbdb-address-streets address))
-             (dotimes (n 3)
-               (unless (zerop (length (setq s (nth n c))))
-                 (setq val (concat val s "\n"))))
-             (setq c (bbdb-address-city address)
-                   s (bbdb-address-state address))
-             (setq val (concat val
-                               (if (and (> (length c) 0) (> (length s) 0))
-                                   (concat c ", " s)
-                                 c)
-                               " "
-                               (bbdb-address-zip address)))
-             (if eudc-bbdb-use-locations-as-attribute-names
-                 (cons (intern (bbdb-address-location address)) val)
-               (cons 'addresses (concat (bbdb-address-location address)
-                                        "\n" val))))
-           (bbdb-record-addresses record))))
+    (nreverse
+     (mapcar (lambda (address)
+              (setq c (bbdb-address-streets address))
+              (dotimes (n 3)
+                (unless (zerop (length (setq s (nth n c))))
+                  (setq val (concat val s "\n"))))
+              (setq c (bbdb-address-city address)
+                    s (bbdb-address-state address))
+              (setq val (concat val
+                                (if (and (> (length c) 0) (> (length s) 0))
+                                    (concat c ", " s)
+                                  c)
+                                " "
+                                (bbdb-address-zip address)))
+              (if eudc-bbdb-use-locations-as-attribute-names
+                  (cons (intern (bbdb-address-location address)) val)
+                (cons 'addresses (concat (bbdb-address-location address)
+                                         "\n" val))))
+            (bbdb-record-addresses record)))))
 
 (defun eudc-bbdb-format-record-as-result (record)
   "Format the BBDB RECORD as a EUDC query result record.



reply via email to

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