From 3b13d7284fb46353c041e458c4468b9a9e49edc5 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sat, 2 Aug 2014 03:53:17 -0700 Subject: [PATCH] make :name/:namelist more flexible and document it --- bbdb-csv-import.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bbdb-csv-import.el b/bbdb-csv-import.el index 62dd12b..757032a 100644 --- a/bbdb-csv-import.el +++ b/bbdb-csv-import.el @@ -112,6 +112,9 @@ ;; 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 ;; @@ -427,11 +430,16 @@ BUFFER-OR-NAME is a buffer or name of a buffer, or the current buffer if nil." (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)) -- 2.30.2