Function: eudc-create-bbdb-record

eudc-create-bbdb-record is a byte-compiled function defined in eudc-export.el.gz.

Signature

(eudc-create-bbdb-record RECORD &optional SILENT)

Documentation

Create a BBDB record using the RECORD alist.

RECORD is an alist of (KEY . VALUE) where KEY is a directory attribute name symbol and VALUE is the corresponding value for the record. If SILENT is non-nil then the created BBDB record is not displayed.

Source Code

;; Defined in /usr/src/emacs/lisp/net/eudc-export.el.gz
(defun eudc-create-bbdb-record (record &optional silent)
  "Create a BBDB record using the RECORD alist.
RECORD is an alist of (KEY . VALUE) where KEY is a directory attribute name
symbol and VALUE is the corresponding value for the record.
If SILENT is non-nil then the created BBDB record is not displayed."
  (require 'bbdb)
  (declare-function bbdb-create-internal "bbdb-com" (&rest spec))
  (declare-function bbdb-display-records "bbdb"
                    (records &optional layout append))
  ;; This function runs in a special context where lisp symbols corresponding
  ;; to field names in record are bound to the corresponding values
  (cl-progv (mapcar #'car record) (mapcar #'cdr record)
    (let* (bbdb-name
	   bbdb-company
	   bbdb-net
	   bbdb-address
	   bbdb-phones
	   bbdb-notes
	   spec
	   bbdb-record
	   value
	   (conversion-alist (symbol-value eudc-bbdb-conversion-alist)))

      ;; BBDB standard fields
      (setq bbdb-name (eudc-parse-spec (cdr (assq 'name conversion-alist)) record nil)
	    bbdb-company (eudc-parse-spec (cdr (assq 'company conversion-alist)) record nil)
	    bbdb-net (eudc-parse-spec (cdr (assq 'net conversion-alist)) record nil)
	    bbdb-notes (eudc-parse-spec (cdr (assq 'notes conversion-alist)) record nil))
      (setq spec (cdr (assq 'address conversion-alist)))
      (setq bbdb-address (delq nil (eudc-parse-spec (if (listp (car spec))
                                                        spec
						      (list spec))
						    record t)))
      (setq spec (cdr (assq 'phone conversion-alist)))
      (setq bbdb-phones (delq nil (eudc-parse-spec (if (listp (car spec))
						       spec
						     (list spec))
						   record t)))
      ;; BBDB custom fields
      (setq bbdb-notes (append (list (and bbdb-notes (cons 'notes bbdb-notes)))
                               (mapcar (lambda (mapping)
                                         (if (and (not (memq (car mapping)
                                                             '(name company net address phone notes)))
                                                  (setq value (eudc-parse-spec (cdr mapping) record nil)))
                                             (cons (car mapping) value)))
				       conversion-alist)))
      (setq bbdb-notes (delq nil bbdb-notes))
      (setq bbdb-record
	    (apply #'bbdb-create-internal
                   `(,bbdb-name
                     ,@(when (eudc--using-bbdb-3-or-newer-p)
                         '(nil
                           nil))
		     ,bbdb-company
		     ,bbdb-net
		     ,@(if (eudc--using-bbdb-3-or-newer-p)
                           (list bbdb-phones
                                 bbdb-address)
                         (list bbdb-address
                               bbdb-phones))
		     ,bbdb-notes)))
      (or silent
	  (bbdb-display-records (list bbdb-record))))))