;;; 02110-1301 USA.
;;;
+(require 'cl)
+
(defconst eweouz-version "0.3")
(defconst eweouz-buffer-name "*EWEOUZ*")
(defvar eweouz-buffer nil)
(defvar eweouz-pop-up-target-lines 5)
-(defun eweouz-search-do (func string)
+(defun eweouz-search-do (func string &optional max-matches)
"Search for the simple string STRING in all fields"
- (block nil
+ (let ((i 0))
(with-temp-buffer
(call-process eweouz-dump-path nil (current-buffer) t string)
(set-text-properties (point-min) (point-max) nil nil)
(goto-char (point-min))
(message (format "%s" (point)))
- (while (looking-at "\n*BEGIN:VCARD")
+ (while (and (looking-at "\n*BEGIN:VCARD") (or (eq max-matches nil)
+ (< i max-matches)))
(let ((m-start (point)))
+ (incf i)
(message (format "%s" (point)))
(search-forward-regexp "^END:VCARD")
(funcall func (vcard-parse-string (buffer-substring m-start (point)))))))))
(let* ((from (mail-header-parse-address (gnus-fetch-field "From")))
(email (car from))
(name (cdr from))
- (record (or (eweouz-search-do '(lambda (x) (return x)) email)
- (eweouz-search-do '(lambda (x) (return x)) name))))
+ (record (or (eweouz-search-do identity email 1)
+ (eweouz-search-do identity name 1))))
(if record
(eweouz-do-update record name email)
(eweouz-do-add from)))))