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