[WIP PATCH] emacs: query: completion for from: in searches
Tomi Ollila
tomi.ollila at iki.fi
Sat Aug 13 02:52:33 PDT 2016
On Fri, Aug 12 2016, Mark Walters <markwalters1009 at gmail.com> wrote:
> This is a first attempt at tab completion for from: searches
> ---
Nice work! I did not test this, but tried to get a grasp of it by
testing tag: completion -- It took me a while to find out where to test
-- in interactive `notmuch-search` invocation, at least...
I'd be interested in 2 things here:
1) how to use this feature with external address completion -- how close
can this feature be made to work like address completion when sending
emails
2) the completion from minibuffer seems to work pretty well -- at least
when comparing how address completion works in
`notmuch-show-resend-message` -- I have to look into that part to see
whether I can improve this...
Tomi
>
> This sort of works (well it works but maybe in unexpected ways!)
>
> At the moment it completes to any word (as delimited by whitespace) in
> any address stored in the address hashmap. It does not trigger the
> address harvesting itself -- you either need to call
> notmuch-address-harvest-trigger manually, or use address completion
> when sending a mail first, and the harvest needs to finish before this
> will work.
>
> Since the hashmap does some address deduplication this will not give
> perfect completion (there may be names in your database it won't
> complete to). Also completion is case-sensitive.
>
> Getting a perfect solution may be more effort than its worth -- this
> will probably demonstrate whether something like this suffices.
>
> Best wishes
>
> Mark
>
> emacs/notmuch.el | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 8acdef3..532f7b3 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -888,10 +888,20 @@ PROMPT is the string to prompt with."
> ;; this ugly regexp is used to get the last word of the input
> ;; possibly preceded by a '('
> ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)
> - (mapcar (lambda (compl)
> - (concat (match-string-no-properties 1 string) compl))
> - (all-completions (match-string-no-properties 2 string)
> - completions)))
> + (let ((last-word (match-string-no-properties 2 string))
> + (start-string (match-string-no-properties 1 string)))
> + (if (and notmuch-address-full-harvest-finished
> + (string-match "^from:\\(.*\\)" last-word))
> + (let ((from-completions (notmuch-address-matching (match-string 1 last-word))))
> + (apply #'append
> + (mapcar (lambda (name-addr)
> + (mapcar (lambda (compl)
> + (concat start-string "from:" compl))
> + (split-string name-addr "[ <>]" t)))
> + from-completions)))
> + (mapcar (lambda (compl)
> + (concat start-string compl))
> + (all-completions last-word completions)))))
> (t (list string)))))))
> ;; this was simpler than convincing completing-read to accept spaces:
> (define-key keymap (kbd "TAB") 'minibuffer-complete)
> --
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list