Re: [WIP PATCH] emacs: query: completion for from: in searches
authorTomi Ollila <tomi.ollila@iki.fi>
Sat, 13 Aug 2016 09:52:33 +0000 (12:52 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:24 +0000 (16:22 -0700)
90/0ece9e1e3c84f5968adc15329743e6523765a6 [new file with mode: 0644]

diff --git a/90/0ece9e1e3c84f5968adc15329743e6523765a6 b/90/0ece9e1e3c84f5968adc15329743e6523765a6
new file mode 100644 (file)
index 0000000..6bdec75
--- /dev/null
@@ -0,0 +1,132 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 627E96DE3664\r
+ for <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 02:53:07 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.561\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.561 tagged_above=-999 required=5 tests=[AWL=-0.091,\r
+  SPF_NEUTRAL=0.652] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 7_QHVyORGYTA for <notmuch@notmuchmail.org>;\r
+ Sat, 13 Aug 2016 02:52:59 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 9B9416DE3663\r
+ for <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 02:52:58 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id AB0D710007F;\r
+ Sat, 13 Aug 2016 12:52:33 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [WIP PATCH] emacs: query: completion for from: in searches\r
+In-Reply-To: <1471032242-4701-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1471032242-4701-1-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.22+61~geeecb9e (https://notmuchmail.org) Emacs/24.5.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sat, 13 Aug 2016 12:52:33 +0300\r
+Message-ID: <m21t1tgfmm.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 13 Aug 2016 09:53:07 -0000\r
+\r
+On Fri, Aug 12 2016, Mark Walters <markwalters1009@gmail.com> wrote:\r
+\r
+> This is a first attempt at tab completion for from: searches\r
+> ---\r
+\r
+Nice work! I did not test this, but tried to get a grasp of it by\r
+testing tag: completion -- It took me a while to find out where to test\r
+-- in interactive `notmuch-search` invocation, at least...\r
+\r
+I'd be interested in 2 things here:\r
+\r
+1) how to use this feature with external address completion -- how close\r
+can this feature be made to work like address completion when sending\r
+emails \r
+\r
+2) the completion from minibuffer seems to work pretty well -- at least\r
+when comparing how address completion works in\r
+`notmuch-show-resend-message` -- I have to look into that part to see\r
+whether I can improve this... \r
+\r
+Tomi\r
+\r
+>\r
+> This sort of works (well it works but maybe in unexpected ways!)\r
+>\r
+> At the moment it completes to any word (as delimited by whitespace) in\r
+> any address stored in the address hashmap. It does not trigger the\r
+> address harvesting itself -- you either need to call\r
+> notmuch-address-harvest-trigger manually, or use address completion\r
+> when sending a mail first, and the harvest needs to finish before this\r
+> will work.\r
+>\r
+> Since the hashmap does some address deduplication this will not give\r
+> perfect completion (there may be names in your database it won't\r
+> complete to). Also completion is case-sensitive.\r
+>\r
+> Getting a perfect solution may be more effort than its worth -- this\r
+> will probably demonstrate whether something like this suffices.\r
+>\r
+> Best wishes\r
+>\r
+> Mark \r
+>\r
+> emacs/notmuch.el | 18 ++++++++++++++----\r
+>  1 file changed, 14 insertions(+), 4 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index 8acdef3..532f7b3 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -888,10 +888,20 @@ PROMPT is the string to prompt with."\r
+>             ;; this ugly regexp is used to get the last word of the input\r
+>             ;; possibly preceded by a '('\r
+>             ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)\r
+> -            (mapcar (lambda (compl)\r
+> -                      (concat (match-string-no-properties 1 string) compl))\r
+> -                    (all-completions (match-string-no-properties 2 string)\r
+> -                                     completions)))\r
+> +            (let ((last-word (match-string-no-properties 2 string))\r
+> +                  (start-string (match-string-no-properties 1 string)))\r
+> +              (if (and notmuch-address-full-harvest-finished\r
+> +                       (string-match "^from:\\(.*\\)" last-word))\r
+> +                  (let ((from-completions (notmuch-address-matching (match-string 1 last-word))))\r
+> +                    (apply #'append\r
+> +                           (mapcar (lambda (name-addr)\r
+> +                                     (mapcar (lambda (compl)\r
+> +                                               (concat start-string "from:" compl))\r
+> +                                             (split-string name-addr "[ <>]" t)))\r
+> +                                   from-completions)))\r
+> +                (mapcar (lambda (compl)\r
+> +                          (concat start-string compl))\r
+> +                        (all-completions last-word completions)))))\r
+>             (t (list string)))))))\r
+>        ;; this was simpler than convincing completing-read to accept spaces:\r
+>        (define-key keymap (kbd "TAB") 'minibuffer-complete)\r
+> -- \r
+> 2.1.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> https://notmuchmail.org/mailman/listinfo/notmuch\r