Refactor address lines to use first found instead of leaving blanks
authorIan Kelling <ian@iankelling.org>
Fri, 18 Apr 2014 02:20:19 +0000 (19:20 -0700)
committerIan Kelling <ian@iankelling.org>
Fri, 18 Apr 2014 02:20:19 +0000 (19:20 -0700)
bbdb3-csv-import.el

index 8b66c73668ded8d729569ae0bb1d991921485307..ab72bacb1f4d2430f49c98f471200b3e2de825bf 100644 (file)
@@ -214,7 +214,7 @@ Adds email labels as custom fields.")
 Based on 'Export for outlook.com and other services',
 not the export for Outlook 2010 and 2013.")
 
-;;(defconst bbdb3-csv-import-combined)
+;(defconst bbdb3-csv-import-combined)
 
 
 (defvar bbdb3-csv-import-mapping-table nil
@@ -328,12 +328,13 @@ Defaults to current buffer."
                                (cons e (cadr list)))) ;; change from (a b) to (a . b)
                            (rd #'assoc-expand (map-bbdb3 "xfields"))))
               (address (rd (lambda (mapping-elem)
-                             (let ((address-lines (mapcar-assoc (caadr mapping-elem)))
+                             (let ((address-lines (rd (lambda (elem)
+                                                        (assoc-plus elem csv-record))
+                                                      (caadr mapping-elem)))
                                    (address-data (mapcar-assoc (cdadr mapping-elem)))
                                    (elem-name (car mapping-elem)))
-                               ;; outlook-web has 1 address line, bbdb requires 2
                                (if (= (length address-lines) 1)
-                                   (setq address-lines (append address-lines '(""))))
+                                   (setq address-lines (-snoc address-lines "")))
                                (when (consp elem-name)
                                  (setq elem-name (cdr (assoc (car elem-name) csv-record))))
                                
@@ -352,7 +353,6 @@ Defaults to current buffer."
           (bbdb-create-internal name affix aka organization mail phone address xfields t))))
     (setq bbdb-allow-duplicates initial-duplicate-value)))
 
-
 (defun bbdb3-csv-import-flatten1 (list)
   "flatten LIST by 1 level."
   (--reduce-from (if (consp it)