Function: eudc-macos-contacts-query-internal

eudc-macos-contacts-query-internal is a byte-compiled function defined in eudcb-macos-contacts.el.gz.

Signature

(eudc-macos-contacts-query-internal QUERY &optional RETURN-ATTRS)

Documentation

Query macOS Contacts with QUERY.

QUERY is a list of cons cells (ATTR . VALUE) where ATTRs should be valid macOS Contacts 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-macos-contacts.el.gz
(defun eudc-macos-contacts-query-internal (query &optional _return-attrs)
  "Query macOS Contacts with QUERY.
QUERY is a list of cons cells (ATTR . VALUE) where ATTRs should be valid
macOS Contacts attribute names.
RETURN-ATTRS is a list of attributes to return, defaulting to
`eudc-default-return-attributes'."
  (let ((macos-contacts-buffer (get-buffer-create " *macOS Contacts*"))
        result)
    (with-current-buffer macos-contacts-buffer
      (erase-buffer)
      (eudc-macos-contacts-search-helper query)
      (delete-duplicate-lines (point-min) (point-max))
      (goto-char (point-min))
      (while (not (eobp))
        (if (not (equal (line-beginning-position) (line-end-position)))
            (let ((keys '(first_name last_name job_title department
                          organization email phone))
                  record)
              (dolist (field (split-string (buffer-substring
                                            (point) (line-end-position))
                                           ":"))
                (let ((key (pop keys)))
                  (unless (string= "" field)
                    (pcase key
                      ((or 'email 'phone) (dolist (x (split-string field ","))
                                            (push (cons key x) record)))
                      (_ (push (cons key field) record))))))
              (unless (length= record 0)
                (push (nreverse record) result))))
        (forward-line))
      result)))