Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • kfogel/mailaprop
1 result
Show changes
Commits on Source (2)
......@@ -337,12 +337,30 @@ but patches welcome of course."
;; * Truncates the candidate list (of a given string) at N.
;;
;; Yup. That's the ticket.
(let* ((alphabet (let ((tmp ()))
(dotimes (base 26)
(setq tmp (cons (make-string 1 (+ base ?a)) tmp)))
tmp))
(prefixes (mailaprop-strings-from-alphabet alphabet 3)))
prefixes))
(let ((max-prefix-len 3)
(num-candidates 20))
(when (< max-prefix-len mailaprop-minimum-initial-input-length)
(let* ((alphabet (let ((tmp ()))
(dotimes (base 26)
(setq tmp (cons (make-string 1 (+ base ?a)) tmp)))
tmp))
(prefixes (mailaprop-strings-from-alphabet alphabet max-prefix-len)))
(dolist (prefix prefixes)
;; TODO: Well, this was all very nice in theory, but in
;; practice, it is completely silly to loop over a zillion
;; prefixes, getting candidates for every one of them, when
;; most of them don't have candidates -- and it takes way
;; too long. The better way to do this would be to loop
;; over addresses and memoize all prefixes of length 1 to N
;; that correspond to actual existing addresses that have
;; that prefix in either the real name or the email address
;; portion.
;;
;; This is commented out because I reverted the calling
;; discipline, removing the last two args:
;;
;; (mailaprop-get-candidates prefix t num-candidates)
)))))
(defun mailaprop-load-addresses (&optional address-file)
"Load (or reload) the email address completion table.
......@@ -424,16 +442,8 @@ for trying out completions outside email headers."
(indent-for-tab-command)))
(defun mailaprop-get-candidates (substr &optional as-prefix limit)
"Return a list of candidate completions for SUBSTR.
If optional second argument AS-PREFIX is non-nil, then only include
candidates that match SUBSTR as a prefix of either the real name
portion or the address portion.
If optional third argument LIMIT is non-nil, it must be an integer
specifying the maximum length of the returned list.
"
(defun mailaprop-get-candidates (substr)
"Return a list of candidate completions for SUBSTR."
(or (gethash substr mailaprop-candidates-cache nil)
;; If it wasn't memoized, then build, memoize, and return it.
(let ((lst ())
......@@ -441,14 +451,8 @@ specifying the maximum length of the returned list.
(dolist (addr-entry mailaprop-addresses)
(let ((score (mailaprop-ae-get-score addr-entry)))
(let ((date (mailaprop-ae-get-date addr-entry)))
(when (let ((re (regexp-quote substr)))
(message "\"%s\" -> \"%s\""
(concat (if as-prefix "^" "") (regexp-quote substr))
(mailaprop-ae-get-addr addr-entry))
(sit-for 2)
(string-match-p
(concat (if as-prefix "^" "") (regexp-quote substr))
(mailaprop-ae-get-addr addr-entry)))
(when (string-match-p
(regexp-quote substr) (mailaprop-ae-get-addr addr-entry))
(setq lst (cons (list (mailaprop-ae-get-addr addr-entry)
date
score)
......@@ -538,7 +542,7 @@ If there is no score corresponding to ADDR, return zero."
;; but as a substring that can appear anywhere
;; in the address. TODO: we could make that a
;; choice, controllable by the user.
(mailaprop-get-candidates arg t)))
(mailaprop-get-candidates arg)))
(post-completion nil)
(annotation (let ((sent-count (mailaprop-find-sent-count arg))
(recv-count (mailaprop-find-recv-count arg))
......