1 Return-Path: <markwalters1009@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id A78C46DE0217
\r
6 for <notmuch@notmuchmail.org>; Tue, 17 May 2016 14:01:20 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.313 tagged_above=-999 required=5 tests=[AWL=0.257,
\r
12 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,
\r
14 RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]
\r
16 Received: from arlo.cworth.org ([127.0.0.1])
\r
17 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
18 with ESMTP id itGiU1RcJdSJ for <notmuch@notmuchmail.org>;
\r
19 Tue, 17 May 2016 14:01:12 -0700 (PDT)
\r
20 Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com
\r
21 [74.125.82.52]) by arlo.cworth.org (Postfix) with ESMTPS id 7BDCB6DE01D0 for
\r
22 <notmuch@notmuchmail.org>; Tue, 17 May 2016 14:01:12 -0700 (PDT)
\r
23 Received: by mail-wm0-f52.google.com with SMTP id g17so50596952wme.1
\r
24 for <notmuch@notmuchmail.org>; Tue, 17 May 2016 14:01:12 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id;
\r
27 bh=4SHzLp1cGCQCZ8uhtjhfDOa5cFbJA8TTkwrUPqSO0I8=;
\r
28 b=bKQg3Yi/PPHUs8HOZ7h26zHycA1LcbzFufsyu6mKJFGDEcmw2+2AcN2NbXRwwhvheX
\r
29 cW2N+FXC1TUt6Vw4HGVFErLFZtFCuKQ1UQqnujqzp+KhOrP8Tur6YtqrHfymO/8a0XyJ
\r
30 SZ0QQZx3qJrBVPdZp8Jn4ZmHN1o+zv+jsG9HP9V2m5O6sGtbWWTn/rwDbKRalAsdd1nx
\r
31 h1QNmuaMW9wM+Nex0B+OfvlL1t5DiNCxeyPk8qiuaOZZkL4bGc49Zty38PdTPDvIT0KA
\r
32 b99XQLCPqDETvmpVDSbTTXdlkWzqYk9AiUB9F969qz8Ilid6r9mG1sUE5wjUCANvgvfm
\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
35 d=1e100.net; s=20130820;
\r
36 h=x-gm-message-state:from:to:cc:subject:date:message-id;
\r
37 bh=4SHzLp1cGCQCZ8uhtjhfDOa5cFbJA8TTkwrUPqSO0I8=;
\r
38 b=jIkIeZAoj6wcjDq9sTLM1zzKSs+oRZ/8XzkM39yqMSuHvgLyp0Eq9eKAn37PxxmUdj
\r
39 3brt0Or1U3EDZrEdcSAAbwcsBXEvYtlsf+H8NRKGAy4Ouv3POaBM3P8Sfbs+nQvlhVJ6
\r
40 +r73gWo1HrtJQsNfcqsnS+s3Dn1Ubi3ZU6CDIr0tIIN6BH0IW23J6eNhloDWnTZ/H9pa
\r
41 TMBTntL6IBK4qZdgBrpvTCP1TgSQNu78od/PXuCXEo3UPZo5td4avMYRC+Oifp9lbLqD
\r
42 MPwruq7DtzQ7ave7yfy+MQC34BTN046eVovNwaeZAReqVCYgBPP8QePamdDdDAEH/pUT
\r
45 AOPr4FXJ7av0F57mNu4R2L/QaeCK67IF6MXGW/ptZQtpdt5sJGTQAC9vbY3a8E1MyVE4aQ==
\r
46 X-Received: by 10.194.89.33 with SMTP id bl1mr1757936wjb.43.1463518870382;
\r
47 Tue, 17 May 2016 14:01:10 -0700 (PDT)
\r
48 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])
\r
49 by smtp.gmail.com with ESMTPSA id xt9sm5032582wjb.17.2016.05.17.14.01.09
\r
50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
51 Tue, 17 May 2016 14:01:09 -0700 (PDT)
\r
52 From: Mark Walters <markwalters1009@gmail.com>
\r
53 To: notmuch@notmuchmail.org
\r
54 Subject: [WIP PATCH] Allow user to sort address completion by count
\r
55 Date: Tue, 17 May 2016 22:01:05 +0100
\r
56 Message-Id: <1463518865-23317-1-git-send-email-markwalters1009@gmail.com>
\r
57 X-Mailer: git-send-email 2.1.4
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.20
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Tue, 17 May 2016 21:01:20 -0000
\r
74 This is a wip patch which allows the user to sort the address
\r
75 completions by count. It seems to work but is not heavily
\r
76 tested. However, I won't have time to work on this for a bit so, since
\r
77 there was some discussion on irc about this, I thought it worth
\r
86 emacs/notmuch-address.el | 33 ++++++++++++++++++++++++++++-----
\r
87 emacs/notmuch-company.el | 3 ++-
\r
88 2 files changed, 30 insertions(+), 6 deletions(-)
\r
90 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
\r
91 index aafbe5f..0df8a48 100644
\r
92 --- a/emacs/notmuch-address.el
\r
93 +++ b/emacs/notmuch-address.el
\r
94 @@ -51,6 +51,12 @@ to know how address selection is made by default."
\r
95 :group 'notmuch-send
\r
96 :group 'notmuch-external)
\r
98 +(defcustom notmuch-address-sort 't
\r
99 + "Sort to use for returned address completions"
\r
101 + :group 'notmuch-send
\r
102 + :group 'notmuch-external)
\r
104 (defvar notmuch-address-last-harvest 0
\r
105 "Time of last address harvest")
\r
107 @@ -102,9 +108,23 @@ The candidates are taken from `notmuch-address-completions'."
\r
108 (re (regexp-quote substring)))
\r
109 (maphash (lambda (key val)
\r
110 (when (string-match re key)
\r
111 - (push key candidates)))
\r
112 + (push (cons key val) candidates)))
\r
113 notmuch-address-completions)
\r
116 + (let ((sorted-candidates
\r
117 + (cond ((eq notmuch-address-sort 'alphabetical)
\r
118 + (sort candidates (lambda (a b) (string< (car a) (car b)))))
\r
119 + ((eq notmuch-address-sort 'count)
\r
120 + (sort candidates (lambda (a b) (> (cdr a) (cdr b)))))
\r
121 + ((null notmuch-address-sort) candidates)
\r
125 + (or (> (cdr a) (cdr b))
\r
126 + (and (= (cdr a) (cdr b))
\r
127 + (string< (car a) (car b))))))))))
\r
129 + (mapcar 'car sorted-candidates))))
\r
131 (defun notmuch-address-options (original)
\r
132 "Returns a list of completion candidates. Uses either
\r
133 @@ -171,8 +191,10 @@ external commands."
\r
134 (throw 'found-command bin))))))))
\r
136 (defun notmuch-address-harvest-addr (result)
\r
137 - (let ((name-addr (plist-get result :name-addr)))
\r
138 - (puthash name-addr t notmuch-address-completions)))
\r
139 + (let ((name-addr (plist-get result :name-addr))
\r
140 + (count (plist-get result :count)))
\r
141 + (message "Putting name %s with count %s" name-addr count)
\r
142 + (puthash name-addr count notmuch-address-completions)))
\r
144 (defun notmuch-address-harvest-handle-result (obj)
\r
145 (notmuch-address-harvest-addr obj))
\r
146 @@ -201,12 +223,13 @@ time so the address collection runs asynchronously unless
\r
147 SYNCHRONOUS is t. In case of asynchronous execution, CALLBACK is
\r
148 called when harvesting finishes."
\r
149 (let* ((from-me-query (mapconcat (lambda (x) (concat "from:" x)) (notmuch-user-emails) " or "))
\r
150 - (query (if filter-query
\r
151 + (query (if (stringp filter-query)
\r
152 (format "(%s) and (%s)" from-me-query filter-query)
\r
154 (args `("address" "--format=sexp" "--format-version=2"
\r
155 "--output=recipients"
\r
156 "--deduplicate=address"
\r
160 (mapc #'notmuch-address-harvest-addr
\r
161 diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
\r
162 index b881d6d..bf3c6d8 100644
\r
163 --- a/emacs/notmuch-company.el
\r
164 +++ b/emacs/notmuch-company.el
\r
166 (match (if (string-match notmuch-company-last-prefix arg)
\r
174 (provide 'notmuch-company)
\r