Re: [Patch v5 2/3] emacs: convert notmuch-address-harvester to use notmuch-address
authorJani Nikula <jani@nikula.org>
Sat, 24 Oct 2015 08:23:24 +0000 (11:23 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:49:53 +0000 (14:49 -0700)
91/1ad21f9a6fe079e235d65c781be3835da88da6 [new file with mode: 0644]

diff --git a/91/1ad21f9a6fe079e235d65c781be3835da88da6 b/91/1ad21f9a6fe079e235d65c781be3835da88da6
new file mode 100644 (file)
index 0000000..a6d1c59
--- /dev/null
@@ -0,0 +1,165 @@
+Return-Path: <jani@nikula.org>\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 50B506DE1226\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Oct 2015 01:24:01 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.167\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.167 tagged_above=-999 required=5\r
+ tests=[AWL=-0.201, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, T_FILL_THIS_FORM_SHORT=0.01, URIBL_SBL=0.644,\r
+ URIBL_SBL_A=0.1] 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 nRrympozZ578 for <notmuch@notmuchmail.org>;\r
+ Sat, 24 Oct 2015 01:23:58 -0700 (PDT)\r
+Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com\r
+ [209.85.212.170])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 0511E6DE0AC2\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Oct 2015 01:23:56 -0700 (PDT)\r
+Received: by wicfv8 with SMTP id fv8so58023285wic.0\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Oct 2015 01:23:55 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=nikula_org.20150623.gappssmtp.com; s=20150623;\r
+ h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+ :mime-version:content-type;\r
+ bh=AFa1Pqda33643cOeEcsLnUYyvc6abaLL1GMpCARQj10=;\r
+ b=MPA8vchMU/J6KRBTeKcVWu1SlU1YimfGqT5CsV3U6QVfk8maUbxKfQtRksx7nBCVT+\r
+ 9adKH6ncGe8jy+67V3wOj6bSTT2XrCMShLV6u2lP3HL3BiXIAfN+/u4a5nmLvgMijAGK\r
+ L2bzXzczY7GpTjdzpMmAWrEBx9xJnMSuxVO3y1kajFegBoPgYmZf6efT3NMK4/f8wdvC\r
+ BicfI8EMW5clcwjDnaLgQb1f1h+oB7aPklAzdw8UO6te2N9ychg+WoTYtrjRX+pbokBm\r
+ roHMS7geoHHNrvM7rGsyioiR2eX9gq21pGms85Y3kTboxDj5jZvexLk2iV8upaE6Auph\r
+ yYOw==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:subject:in-reply-to:references\r
+ :user-agent:date:message-id:mime-version:content-type;\r
+ bh=AFa1Pqda33643cOeEcsLnUYyvc6abaLL1GMpCARQj10=;\r
+ b=armJjDlfHYdSJtyxj1Jh33NgFg1dsm0c98q3skSLr0coFUafsTYxQ5td4bWXtXiPVb\r
+ wfAK3s0CwG7d+CXIu3JZpa91Q5aOLwvz+jBbTKdw9nRUH/7QlJuBmgFVTi+ocQ2vCsDs\r
+ N3afYT32or9DCzbGGv18tdI3OzPVHQ3bL6stJH3my+VNJNBig3cmeqg9LMHn+YmzT0GH\r
+ 6X0uYdaqJAQu4B+VXgZ6ijjzXZp11Kfyp2gwMVwK8/5tUrjv8TGh7gFy7pfQdmBLMXyE\r
+ ZjPgImxBWTthvo4AyOQ2O7TRXWy4mKtumACR8M1kPe9gD/S6u0ZnKnqHdX/nn1V+a2NI\r
+ qKjQ==\r
+X-Gm-Message-State:\r
+ ALoCoQnGqqhd66na+7vlab9D45M+h1zRJMRMrG0rVY9GXs/tUknPqehuVUuwpdI6ytGeN2hIVUjX\r
+X-Received: by 10.194.71.164 with SMTP id w4mr8751772wju.19.1445675035188;\r
+ Sat, 24 Oct 2015 01:23:55 -0700 (PDT)\r
+Received: from localhost (mobile-access-bceec0-208.dhcp.inet.fi.\r
+ [188.238.192.208])\r
+ by smtp.gmail.com with ESMTPSA id p10sm26837688wjx.36.2015.10.24.01.23.54\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 24 Oct 2015 01:23:54 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [Patch v5 2/3] emacs: convert notmuch-address-harvester to use\r
+ notmuch-address\r
+In-Reply-To: <1445646037-25994-3-git-send-email-david@tethera.net>\r
+References: <1445646037-25994-1-git-send-email-david@tethera.net>\r
+ <1445646037-25994-3-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.21~rc3+3~g80a80a8 (http://notmuchmail.org) Emacs/24.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 24 Oct 2015 11:23:24 +0300\r
+Message-ID: <87eggk3car.fsf@nikula.org>\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, 24 Oct 2015 08:24:01 -0000\r
+\r
+On Sat, 24 Oct 2015, David Bremner <david@tethera.net> wrote:\r
+> No attempt is made to optimize anything here, just drop in the new\r
+> command. In particular the use of --output=recipients is known to be\r
+> slower than --output=senders, but it fit the existing logic better.\r
+\r
+Would it be useful to (optionally) use --deduplicate=address here?\r
+Having a dozen name variants with the same address part bugs me most\r
+about the completions.\r
+\r
+Another thing that might be useful as a follow-up is adding an optional\r
+date: search filter to only take into account recent emails. This would\r
+gradually phase out obsolete addresses from the results. Also speeds up\r
+searches if the database is huge.\r
+\r
+BR,\r
+Jani.\r
+\r
+\r
+> ---\r
+>  emacs/notmuch-address.el | 25 ++++++++-----------------\r
+>  1 file changed, 8 insertions(+), 17 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
+> index 9f6711b..d54a8bb 100644\r
+> --- a/emacs/notmuch-address.el\r
+> +++ b/emacs/notmuch-address.el\r
+> @@ -20,7 +20,6 @@\r
+>  ;; Authors: David Edmondson <dme@dme.org>\r
+>  \r
+>  (require 'message)\r
+> -(require 'notmuch-query)\r
+>  (require 'notmuch-parser)\r
+>  \r
+>  ;;\r
+> @@ -148,21 +147,12 @@ external commands."\r
+>                         (not (file-directory-p bin))))\r
+>            (throw 'found-command bin))))))))\r
+>  \r
+> -(defun notmuch-address-harvest-msg (msg)\r
+> -  (let* ((headers (plist-get msg :headers))\r
+> -     (to (ignore-errors (mail-extract-address-components (plist-get headers :To) t)))\r
+> -     (cc (ignore-errors (mail-extract-address-components (plist-get headers :Cc) t)))\r
+> -     (bcc (ignore-errors (mail-extract-address-components (plist-get headers :Bcc) t))))\r
+> -    (mapc (lambda (parts)\r
+> -        (let* ((name (car parts))\r
+> -               (email (cadr parts))\r
+> -               (entry (if name (format "%s <%s>" name email) email)))\r
+> -          (puthash entry t notmuch-address-completions)))\r
+> -      (append to cc bcc))\r
+> -    nil))\r
+> +(defun notmuch-address-harvest-addr (result)\r
+> +  (let ((name-addr (plist-get result :name-addr)))\r
+> +    (puthash name-addr t notmuch-address-completions)))\r
+>  \r
+>  (defun notmuch-address-harvest-handle-result (obj)\r
+> -  (notmuch-query-map-threads 'notmuch-address-harvest-msg (list obj)))\r
+> +  (notmuch-address-harvest-addr obj))\r
+>  \r
+>  (defun notmuch-address-harvest-filter (proc string)\r
+>    (when (buffer-live-p (process-buffer proc))\r
+> @@ -188,10 +178,11 @@ called when harvesting finishes."\r
+>       (query (if filter-query\r
+>                  (format "(%s) and (%s)" from-me-query filter-query)\r
+>                from-me-query))\r
+> -     (args `("show" "--format=sexp" "--format-version=2"\r
+> -             "--body=false" "--entire-thread=false" ,query)))\r
+> +     (args `("address" "--format=sexp" "--format-version=2"\r
+> +             "--output=recipients"\r
+> +             ,query)))\r
+>      (if synchronous\r
+> -    (notmuch-query-map-threads 'notmuch-address-harvest-msg\r
+> +    (mapc #'notmuch-address-harvest-addr\r
+>                                 (apply 'notmuch-call-notmuch-sexp args))\r
+>        ;; Asynchronous\r
+>        (when notmuch-address-harvest-proc\r
+> -- \r
+> 2.6.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> https://notmuchmail.org/mailman/listinfo/notmuch\r