;; (setq bbdb-csv-import-mapping-table bbdb-csv-import-outlook-typed-email)
;;
;; The doc string for `bbdb-create-internal' may also be useful when creating a
-;; mapping table. Please send any new tables to the maintainer listed in this
-;; file. The maintainer should be able to help with any issues and may create a
-;; new mapping table given sample data.
+;; mapping table. If you create a table for a program not not already supported,
+;; please share it with the mailing list so it can be added to this program.
+;; The maintainer should be able to help with any issues and may create a new
+;; mapping table given sample data.
;;
;; Mapping table tips:
;; * The repeat keyword expands numbered field names, based on the first
-;; subsequent field, as many times as they exist in the csv data.
+;; field, as many times as they exist in the csv data.
;; * All mapping fields are optional. A simple mapping table could be
;; (setq bbdb-csv-import-mapping-table '((:mail "Primary Email")))
-;; * xfields uses the field name to create custom fields in bbdb. It downcases
-;; the field name, and replaces spaces with "-".
-;; * For example, if you had a csv data for bbdb's mail-alias, you could add to :xfields
-;; a csv field name would become "mail-alias", like "Mail Alias" or "Mail-alias"
+;; * :xfields uses the csv field name to create custom fields in bbdb. It downcases
+;; the field name, and replaces spaces with "-", and repeating dashes with a
+;; single one . For example, if you had a csv named "Mail Alias" or "Mail - alias",
+;; you could add it to :xfields in a mapping table and it would become "mail-alias"
+;; in bbdb.
;;; Misc tips/troubleshooting:
;;
;; do M-x bbdb then .* then C-u * d on the beginning of a record.
;; - After changing a mapping table variable, don't forget to re-execute
;; (setq bbdb-csv-import-mapping-table ...) so that it propagates.
+;; - :namelist is used instead of :name if 2 or more non-empty fields from :namelist are
+;; found in a record. If :name is empty, we try a single non-empty field from :namelist
+;; This sounds a bit strange, but it's to try and deal with Thunderbird idiosyncrasies.
;;; Bugs, patches, discussion, feedback
;;
;;
;; Questions, feedback, or anything is very welcome at to the bbdb-csv-import mailing list
;; https://lists.iankelling.org/listinfo/bbdb-csv-import, no subscription needed to post via
-;; bbdb-csv-import@lists.iankelling.org
+;; bbdb-csv-import@lists.iankelling.org. The maintainer would probably be happy
+;; to work on new features if something is missing.
(data (assoc-plus (if (consp e) (cadr e) e) csv-record)))
(if data (list data-name data)))))
;; set the arguments to bbdb-create-internal, then call it, the end.
- (let ((name (let ((name (rd-assoc :namelist)))
- ;; prioritize any combination of first middle last over :name
- (if (>= (length name) 2)
- (mapconcat 'identity name " ")
- (car (rd-assoc :name)))))
+ (let ((name (let ((namelist (rd-assoc :namelist))
+ (let-name (car (rd-assoc :name))))
+ ;; priority: 2 or more from :namelist, then non-empty :name, then
+ ;; any single element of :namelist
+ (cond ((>= (length namelist) 2)
+ (mapconcat 'identity namelist " "))
+ ((not (null let-name))
+ let-name)
+ (t
+ (mapconcat 'identity namelist " ")))))
(affix (rd-assoc :affix))
(aka (rd-assoc :aka))
(organization (rd-assoc :organization))
(let ((e (car list)))
(while (string-match " +" e)
(setq e (replace-match "-" nil nil e)))
+ (while (string-match "--+" e)
+ (setq e (replace-match "-" nil nil e)))
(setq e (make-symbol (downcase e)))
(cons e (cadr list)))) ;; change from (a b) to (a . b)
(rd #'assoc-expand (map-bbdb :xfields)))))