From ef9bcabbf878711852bbf313dc3a76b7e7ae9856 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Tue, 24 Feb 2015 09:12:24 +0200 Subject: [PATCH] Re: [PATCH 5/5] completion: complete addresses in from:/to: search terms --- d6/6506d170af8449689ce91272b8b982f5c76d1e | 134 ++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 d6/6506d170af8449689ce91272b8b982f5c76d1e diff --git a/d6/6506d170af8449689ce91272b8b982f5c76d1e b/d6/6506d170af8449689ce91272b8b982f5c76d1e new file mode 100644 index 000000000..d3f1ab75c --- /dev/null +++ b/d6/6506d170af8449689ce91272b8b982f5c76d1e @@ -0,0 +1,134 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id A3F72431FC2 + for ; Mon, 23 Feb 2015 23:20:40 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.438 +X-Spam-Level: ** +X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 5N5qeBWXL5Nz for ; + Mon, 23 Feb 2015 23:20:37 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 52C70431FC0 + for ; Mon, 23 Feb 2015 23:20:37 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 4F7D210019F + for ; Tue, 24 Feb 2015 09:12:24 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: Re: [PATCH 5/5] completion: complete addresses in from:/to: search + terms +In-Reply-To: <1422388098-16333-5-git-send-email-jani@nikula.org> +References: <1422388098-16333-1-git-send-email-jani@nikula.org> + <1422388098-16333-5-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.19+53~gb45d2f9 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 24 Feb 2015 07:20:40 -0000 + +On Tue, Jan 27 2015, Jani Nikula wrote: + +> Use the new notmuch address command to do completion for addresses in +> from: and to:. +> +> --- +> +> This patch is more of an RFC. The to: completion is sloooow because +> typically there are more matches to begin with, and then producing the +> results requires reading the messages. Maybe it would be better to use +> the same mechanism as from: for both, even if it's not accurate for +> to:? + +Shameless marketing puff: Imagine how fast would it would be to use +nottoomuch-addresses -- the completions are there before one +sees TAB KeyRelease event... ;) + +Tomi + + +> --- +> completion/notmuch-completion.bash | 30 +++++++++++++++++++++++++----- +> 1 file changed, 25 insertions(+), 5 deletions(-) +> +> diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash +> index e0498903f22f..db49294fc58c 100644 +> --- a/completion/notmuch-completion.bash +> +++ b/completion/notmuch-completion.bash +> @@ -27,10 +27,30 @@ +> # on completion. +> # +> +> -_notmuch_user_emails() +> +# $1: current input of the form prefix:partialinput, where prefix is +> +# to or from. +> +_notmuch_email() +> { +> - notmuch config get user.primary_email +> - notmuch config get user.other_email +> + local output prefix cur +> + +> + prefix="${1%%:*}" +> + cur="${1#*:}" +> + +> + # Cut the input to be completed at punctuation because +> + # (apparently) Xapian does not support the trailing wildcard '*' +> + # operator for input with punctuation. We let compgen handle the +> + # extra filtering required. +> + cur="${cur%%[^a-zA-Z0-9]*}" +> + +> + case "$prefix" in +> + to) output=recipients;; +> + from) output=sender;; +> + *) return;; +> + esac +> + +> + # Only emit plain, lower case, unique addresses. +> + notmuch address --output=$output $prefix:"${cur}*" | \ +> + sed 's/[^<]*<\([^>]*\)>/\1/' | tr "[:upper:]" "[:lower:]" | sort -u +> } +> +> _notmuch_search_terms() +> @@ -44,10 +64,10 @@ _notmuch_search_terms() +> COMPREPLY=( $(compgen -P "tag:" -W "`notmuch search --output=tags \*`" -- ${cur##tag:}) ) +> ;; +> to:*) +> - COMPREPLY=( $(compgen -P "to:" -W "`_notmuch_user_emails`" -- ${cur##to:}) ) +> + COMPREPLY=( $(compgen -P "to:" -W "`_notmuch_email ${cur}`" -- ${cur##to:}) ) +> ;; +> from:*) +> - COMPREPLY=( $(compgen -P "from:" -W "`_notmuch_user_emails`" -- ${cur##from:}) ) +> + COMPREPLY=( $(compgen -P "from:" -W "`_notmuch_email ${cur}`" -- ${cur##from:}) ) +> ;; +> path:*) +> local path=`notmuch config get database.path` +> -- +> 2.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2