Function: eudc-bbdb-query-internal
eudc-bbdb-query-internal is a byte-compiled function defined in
eudcb-bbdb.el.gz.
Signature
(eudc-bbdb-query-internal QUERY &optional RETURN-ATTRS)
Documentation
Query BBDB with QUERY.
QUERY is a list of cons cells (ATTR . VALUE) where ATTRs should be valid
BBDB attribute names.
RETURN-ATTRS is a list of attributes to return, defaulting to
eudc-default-return-attributes.
Source Code
;; Defined in /usr/src/emacs/lisp/net/eudcb-bbdb.el.gz
(defun eudc-bbdb-query-internal (query &optional return-attrs)
"Query BBDB with QUERY.
QUERY is a list of cons cells (ATTR . VALUE) where ATTRs should be valid
BBDB attribute names.
RETURN-ATTRS is a list of attributes to return, defaulting to
`eudc-default-return-attributes'."
(require 'bbdb)
(let ((eudc-bbdb-current-query query)
(eudc-bbdb-current-return-attributes return-attrs)
(query-attrs (eudc-bbdb-format-query query))
bbdb-attrs
(records (bbdb-records))
result
filtered)
;; BBDB ORs its query attributes while EUDC ANDs them, hence we need to
;; call bbdb-search iteratively on the returned records for each of the
;; requested attributes
(while (and records (> (length query-attrs) 0))
(setq bbdb-attrs (append bbdb-attrs (list (car query-attrs))))
(if (car query-attrs)
;; BEWARE: `bbdb-search' is a macro!
(setq records (eval `(bbdb-search (quote ,records) ,@bbdb-attrs) t)))
(setq query-attrs (cdr query-attrs)))
(mapc (lambda (record)
(setq filtered (eudc-filter-duplicate-attributes record))
;; If there were duplicate attributes reverse the order of the
;; record so the unique attributes appear first
(if (> (length filtered) 1)
(setq filtered (mapcar #'reverse filtered)))
(setq result (append result filtered)))
(delq nil
(mapcar #'eudc-bbdb-format-record-as-result
(delq nil
(mapcar #'eudc-bbdb-filter-non-matching-record
records)))))
result))