Function: eudc-bbdb-format-record-as-result

eudc-bbdb-format-record-as-result is a byte-compiled function defined in eudcb-bbdb.el.gz.

Signature

(eudc-bbdb-format-record-as-result RECORD)

Documentation

Format the BBDB RECORD as a EUDC query result record.

The record is filtered according to eudc-bbdb-current-return-attributes.

Source Code

;; Defined in /usr/src/emacs/lisp/net/eudcb-bbdb.el.gz
(defun eudc-bbdb-format-record-as-result (record)
  "Format the BBDB RECORD as a EUDC query result record.
The record is filtered according to `eudc-bbdb-current-return-attributes'."
  (require 'bbdb)
  (let ((attrs (or eudc-bbdb-current-return-attributes
		   '(firstname lastname aka company phones addresses net notes)))
	eudc-rec)
    (dolist (attr attrs)
      (let ((val
             (pcase attr
              ('phones    (eudc-bbdb-extract-phones record))
	      ('addresses (eudc-bbdb-extract-addresses record))
	      ('notes
               (if (eudc--using-bbdb-3-or-newer-p)
                   (bbdb-record-xfield record 'notes)
                 (bbdb-record-notes record)))
              ((or 'firstname 'lastname 'aka 'company 'net)
               (funcall (intern
			 (concat "bbdb-record-"
				 (symbol-name (eudc-bbdb-field attr))))
			record))
	      (_
	       (error "Unknown BBDB attribute")))))
	(cond
	 ((or (not val) (equal val ""))) ; do nothing
	 ((memq attr '(phones addresses))
	  (setq eudc-rec (append val eudc-rec)))
	 ((and (listp val)
	       (= 1 (length val)))
	  (push (cons attr (car val)) eudc-rec))
	 ((> (length val) 0)
	  (push (cons attr val) eudc-rec))
	 (t
	  (error "Unexpected attribute value")))))
    (nreverse eudc-rec)))