Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 9f / 46f1c6424eb1be1196244e60782a26b232d0aa
1 Return-Path: <amdragon@mit.edu>\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 olra.theworths.org (Postfix) with ESMTP id 5A0E141ED71\r
6         for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:37 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id mzoeOtVCSWmF for <notmuch@notmuchmail.org>;\r
16         Thu, 12 Jul 2012 17:45:35 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id 99E8741ED73\r
20         for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:30 -0700 (PDT)\r
21 X-AuditID: 1209190e-b7fb56d0000008b2-f6-4fff6faa1f4d\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 91.51.02226.AAF6FFF4; Thu, 12 Jul 2012 20:45:30 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q6D0jU8B010246; \r
27         Thu, 12 Jul 2012 20:45:30 -0400\r
28 Received: from drake.dyndns.org\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6D0jSC7010704\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Thu, 12 Jul 2012 20:45:29 -0400 (EDT)\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1SpU0e-0005S5-LG; Thu, 12 Jul 2012 20:45:28 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 5/7] emacs: Replace other search text properties with result\r
41         property\r
42 Date: Thu, 12 Jul 2012 20:45:17 -0400\r
43 Message-Id: <1342140319-19859-6-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10\r
45 In-Reply-To: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
46 References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6norsq/7+/wckGbovrN2cyOzB6PFt1\r
49         izmAMYrLJiU1J7MstUjfLoErY+XjR6wFryQr5my6wtzAeFG0i5GDQ0LAROLOFekuRk4gU0zi\r
50         wr31bCC2kMA+Rol3tyW7GLmA7A2MEoen9zBCOI+YJG7c6mGCcOYySlz838EI0sImoCGxbf9y\r
51         MFtEQFpi593ZrCAbmAXUJP50qYCEhQVCJdY+ugBWwiKgKnG+5QiYzSvgIPGlaQsTxBXyEk/v\r
52         94FdwSngKLHhywVWiIscJBqPzWSewMi/gJFhFaNsSm6Vbm5iZk5xarJucXJiXl5qka6xXm5m\r
53         iV5qSukmRlDIcEry7WD8elDpEKMAB6MSD+/v2P/+QqyJZcWVuYcYJTmYlER5XbKBQnxJ+SmV\r
54         GYnFGfFFpTmpxYcYJTiYlUR419kD5XhTEiurUovyYVLSHCxK4rxXUm76CwmkJ5akZqemFqQW\r
55         wWRlODiUJHg5gbEhJFiUmp5akZaZU4KQZuLgBBnOAzR8Wx7I8OKCxNzizHSI/ClGRSlx3gsg\r
56         CQGQREZpHlwvLKZfMYoDvSLMuxOkigeYDuC6XwENZgIaPOvnP5DBJYkIKakGxugThw9tP/Ey\r
57         Iun7/Sh1r+8rjtrMvMG7wCVf8doc17Vxrlk/Z7L2iMj4zGR7fVBtu873a447ujf+FlDQy2d6\r
58         F/J08qGPjBvrFri9FG/U/ezSsP6758NFeZbqSaoLftjET7TXyF0TGMu2V+b6bIkVWb8sdi2f\r
59         dc/i0/x3SXcOaCos8ck8dCB3ma4SS3FGoqEWc1FxIgAza16fxAIAAA==\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Fri, 13 Jul 2012 00:45:37 -0000\r
73 \r
74 Since the result object contains everything that the other text\r
75 properties recorded, we can remove the other text properties and\r
76 simply look in the plist of the appropriate result object.\r
77 ---\r
78  emacs/notmuch.el |   24 ++++++++++--------------\r
79  1 file changed, 10 insertions(+), 14 deletions(-)\r
80 \r
81 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
82 index 3f72427..a5cf0dc 100644\r
83 --- a/emacs/notmuch.el\r
84 +++ b/emacs/notmuch.el\r
85 @@ -452,16 +452,18 @@ current result."\r
86  (defun notmuch-search-properties-in-region (property beg end)\r
87    (let (output)\r
88      (notmuch-search-do-results beg end pos\r
89 -      (push (get-text-property pos property) output))\r
90 +      (push (plist-get (notmuch-search-get-result pos) property) output))\r
91      output))\r
92  \r
93  (defun notmuch-search-find-thread-id ()\r
94    "Return the thread for the current thread"\r
95 -  (get-text-property (point) 'notmuch-search-thread-id))\r
96 +  (let ((thread (plist-get (notmuch-search-get-result) :thread)))\r
97 +    (when thread (concat "thread:" thread))))\r
98  \r
99  (defun notmuch-search-find-thread-id-region (beg end)\r
100    "Return a list of threads for the current region"\r
101 -  (notmuch-search-properties-in-region 'notmuch-search-thread-id beg end))\r
102 +  (mapcar (lambda (thread) (concat "thread:" thread))\r
103 +         (notmuch-search-properties-in-region :thread beg end)))\r
104  \r
105  (defun notmuch-search-find-thread-id-region-search (beg end)\r
106    "Return a search string for threads for the current region"\r
107 @@ -469,19 +471,19 @@ current result."\r
108  \r
109  (defun notmuch-search-find-authors ()\r
110    "Return the authors for the current thread"\r
111 -  (get-text-property (point) 'notmuch-search-authors))\r
112 +  (plist-get (notmuch-search-get-result) :authors))\r
113  \r
114  (defun notmuch-search-find-authors-region (beg end)\r
115    "Return a list of authors for the current region"\r
116 -  (notmuch-search-properties-in-region 'notmuch-search-authors beg end))\r
117 +  (notmuch-search-properties-in-region :authors beg end))\r
118  \r
119  (defun notmuch-search-find-subject ()\r
120    "Return the subject for the current thread"\r
121 -  (get-text-property (point) 'notmuch-search-subject))\r
122 +  (plist-get (notmuch-search-get-result) :subject))\r
123  \r
124  (defun notmuch-search-find-subject-region (beg end)\r
125    "Return a list of authors for the current region"\r
126 -  (notmuch-search-properties-in-region 'notmuch-search-subject beg end))\r
127 +  (notmuch-search-properties-in-region :subject beg end))\r
128  \r
129  (defun notmuch-search-show-thread ()\r
130    "Display the currently selected thread."\r
131 @@ -769,13 +771,7 @@ non-authors is found, assume that all of the authors match."\r
132           (notmuch-search-insert-field (car spec) (cdr spec) result))\r
133         (insert "\n")\r
134         (notmuch-search-color-line beg (point) (plist-get result :tags))\r
135 -       (put-text-property beg (point) 'notmuch-search-result result)\r
136 -       (put-text-property beg (point) 'notmuch-search-thread-id\r
137 -                          (concat "thread:" (plist-get result :thread)))\r
138 -       (put-text-property beg (point) 'notmuch-search-authors\r
139 -                          (plist-get result :authors))\r
140 -       (put-text-property beg (point) 'notmuch-search-subject\r
141 -                          (plist-get result :subject)))\r
142 +       (put-text-property beg (point) 'notmuch-search-result result))\r
143        (when (string= (plist-get result :thread) notmuch-search-target-thread)\r
144         (setq notmuch-search-target-thread "found")\r
145         (goto-char beg)))))\r
146 -- \r
147 1.7.10\r
148 \r