From 501ec1e414a1e75ad0cb91e2fc7b39aa5ea81f83 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 17 May 2016 13:53:04 +0200 Subject: [PATCH] Re: [PATCH v3] emacs: address completion, allow sender/recipient and filters --- 40/e9299bfe58ff278e61d7a590bdf0cfd1695d7d | 159 ++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 40/e9299bfe58ff278e61d7a590bdf0cfd1695d7d diff --git a/40/e9299bfe58ff278e61d7a590bdf0cfd1695d7d b/40/e9299bfe58ff278e61d7a590bdf0cfd1695d7d new file mode 100644 index 000000000..a3c4dd984 --- /dev/null +++ b/40/e9299bfe58ff278e61d7a590bdf0cfd1695d7d @@ -0,0 +1,159 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 95C386DE00BF + for ; Tue, 17 May 2016 04:53:20 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -1.649 +X-Spam-Level: +X-Spam-Status: No, score=-1.649 tagged_above=-999 required=5 tests=[AWL=0.661, + RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id O4W7FJ7xVdHP for ; + Tue, 17 May 2016 04:53:12 -0700 (PDT) +Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) + by arlo.cworth.org (Postfix) with ESMTP id EC2866DE00D3 + for ; Tue, 17 May 2016 04:53:11 -0700 (PDT) +Received: from localhost (unknown [192.168.200.7]) + by max.feld.cvut.cz (Postfix) with ESMTP id 266215CCEE0; + Tue, 17 May 2016 13:53:08 +0200 (CEST) +X-Virus-Scanned: IMAP STYX AMAVIS +Received: from max.feld.cvut.cz ([192.168.200.1]) + by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new, port 10044) + with ESMTP id b4fRIg0PHohi; Tue, 17 May 2016 13:53:06 +0200 (CEST) +Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) + by max.feld.cvut.cz (Postfix) with ESMTP id 2FB265CCF41; + Tue, 17 May 2016 13:53:06 +0200 (CEST) +Received: from wsh by steelpick.2x.cz with local (Exim 4.87) + (envelope-from ) + id 1b2dYf-0005M0-2x; Tue, 17 May 2016 13:53:05 +0200 +From: Michal Sojka +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v3] emacs: address completion, + allow sender/recipient and filters +In-Reply-To: <1463384211-13086-1-git-send-email-markwalters1009@gmail.com> +References: <87h9e11vq1.fsf@steelpick.2x.cz> + <1463384211-13086-1-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.22+17~ga5b8c02 (http://notmuchmail.org) Emacs/24.5.1 + (x86_64-pc-linux-gnu) +Date: Tue, 17 May 2016 13:53:04 +0200 +Message-ID: <8737pg99zz.fsf@steelpick.2x.cz> +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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, 17 May 2016 11:53:20 -0000 + +Hi Mark, + +few minor comments bellow. + +On Mon, May 16 2016, Mark Walters wrote: +> This commit lets the user customize the address completion. + +Add "It makes two changes." + +> The first change controls whether to build the address completion list +> based on messages you have sent or you have received (the latter is +> much faster). +> +> The second change add a possible filter query to limit the messages +> used -- for example, setting this to date:1y.. would limit the +> address completions to addresses used in the last year. This speeds up +> the address harvest and may also make the search less cluttered as old +> addresses may well no longer be valid. +> --- +> +> This version uses the docstrings suggested my Michal (which are much +> better than mine), and renames some variables, as he suggested, to +> make the code clearer. +> +> I wondered about allowing the user to specify completion based on +> message "sent or received", rather than either sent, or received, but +> think that is adding too much mess. We could also allow completion +> based on any messages in the database, which would the include +> completion based on messages received via mailing lists or +> distribution lists. +> +> I also note that if the user enters a bad query into the filter query +> box (eg 6M.. rather than date:6M..) they may get an obscure error as +> notmuch/xapian fails. I don't see a goo way round that so have left +> that as a "don't do that" case. + +Agreed. + +> emacs/notmuch-address.el | 119 ++++++++++++++++++++++++++++++++--------------- +> emacs/notmuch-company.el | 2 +- +> 2 files changed, 82 insertions(+), 39 deletions(-) +> +> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el +> index aafbe5f..3dc5da9 100644 +> --- a/emacs/notmuch-address.el +> +++ b/emacs/notmuch-address.el +> @@ -28,15 +28,51 @@ +> ;; +> (declare-function company-manual-begin "company") +> +> -(defcustom notmuch-address-command 'internal +> - "The command which generates possible addresses. It must take a +> -single argument and output a list of possible matches, one per +> -line. The default value of `internal' uses built-in address +> -completion." +> +(defvar notmuch-address-last-harvest 0 +> + "Time of last address harvest") +> + +> +(defvar notmuch-address-completions (make-hash-table :test 'equal) +> + "Hash of email addresses for completion during email composition. +> + This variable is set by calling `notmuch-address-harvest'.") +> + +> +(defvar notmuch-address-full-harvest-finished nil +> + "t indicates that full completion address harvesting has been +> +finished") +> + +> +(defcustom notmuch-address-command '(sent nil) +> + "Determines how to generate address completion candidates. +> + +> +If it is a string then that string should be an external program +> +which must take a single argument (searched string) and output a +> +list of completion candidates, one per line. +> + +> +Alternatively, it can be a (non-nil) list, in which case internal +> +completion is used; in this case the list should have form +> +'(DIRECTION FILTER), where DIRECTION is either sent or received +> +and specifies whether the candidates are searched in messages +> +sent by the user or received by the user (note received by is +> +much faster), and FILTER is either nil or a filter-string, such +> +as \"date:1y..\" to append to the query. +> + +> +If this variable is nil then address completion is disabled." +> :type '(radio +> - (const :tag "Use internal address completion" internal) +> + (list :tag "Use internal address completion" +> + (radio +> + :tag "Base completion on messages you have" +> + :value sent +> + (const :tag "sent" sent) +> + (const :tag "received" received)) + +I think, users will be more happy if they understand the difference +without reading the full doc string. + + (const :tag "sent (more accurate)" sent) + (const :tag "received (faster)" received)) + + +Thanks. +-Michal -- 2.26.2