[PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / d8 / 9e7893ca411825ae23864fc745ebbece6eac30
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 olra.theworths.org (Postfix) with ESMTP id 57389431FC7\r
6         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 14:24:52 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id JNMFvRJTGPNT for <notmuch@notmuchmail.org>;\r
18         Sat,  5 Apr 2014 14:24:46 -0700 (PDT)\r
19 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com\r
20         [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 9AD69431FAF\r
23         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 14:24:46 -0700 (PDT)\r
24 Received: by mail-wi0-f171.google.com with SMTP id q5so3098582wiv.10\r
25         for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 14:24:45 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
28         bh=sXN0e30DKMzSQdAzlHeB7T7l6fbaI3z0oV++oHNt1FY=;\r
29         b=GAUC65LOhvVBQkrZ0FXXyexLY4cZNbWST3yr5uBT+7fEGMwEYDG9/AUH/PjLkMESjQ\r
30         c0142kgoMDi5KkKiWlUVLFEf8QgLAoMjMCItLx/5DXmTNgYDeWNjxkVTG3BkVGdic8D1\r
31         miGj40B99/PNRvsAmlb8s9UR454wdzCvyPaWIEA2koywxgymrebMPHjqy3IMJGQOs+O1\r
32         7oXWlUZ+oqDgeLygfMKAC+lOzdXCcDxtMd9yY9e2CQPS5yISU5PA1qsSgjhEy9p9yQDW\r
33         jnyDDlP+iXGz6qMVr2bOLfHhFiqk7/7pKiGYVxTnXMSATmCmee2o5oHOU5+AKD8xKUlR\r
34         wHgA==\r
35 X-Received: by 10.194.76.10 with SMTP id g10mr30350660wjw.67.1396733085160;\r
36         Sat, 05 Apr 2014 14:24:45 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id\r
39         l12sm18567425wjr.35.2014.04.05.14.24.44 for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 05 Apr 2014 14:24:44 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH 1/5] emacs: hello: add helper functions for saved-searches\r
45 Date: Sat,  5 Apr 2014 22:24:21 +0100\r
46 Message-Id: <1396733065-32602-2-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.10.4\r
48 In-Reply-To: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Sat, 05 Apr 2014 21:24:52 -0000\r
63 \r
64 Add helper functions to for saved searches to ease the transition to\r
65 the new plist form while maintaining backwards compatibility. They\r
66 will be used in the next patch.\r
67 ---\r
68  emacs/notmuch-hello.el |   39 +++++++++++++++++++++++++++++++++++++++\r
69  1 file changed, 39 insertions(+)\r
70 \r
71 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
72 index e325cd3..0b9ed16 100644\r
73 --- a/emacs/notmuch-hello.el\r
74 +++ b/emacs/notmuch-hello.el\r
75 @@ -269,6 +269,45 @@ (defun notmuch-hello-search (&optional search)\r
76        (add-to-history 'notmuch-search-history search)))\r
77    (notmuch-search search notmuch-search-oldest-first))\r
78  \r
79 +(defun notmuch-saved-search-get (saved-search field)\r
80 +  "Get FIELD from SAVED-SEARCH.\r
81 +\r
82 +In the new style saved-search (a plist) this is just plist-get\r
83 +but, for backwards compatibility, this deals with the two\r
84 +old-style forms: cons cells (NAME . QUERY) and lists (NAME QUERY\r
85 +COUNT-QUERY)."\r
86 +  (cond\r
87 +   ((plist-get saved-search :name)\r
88 +    (plist-get saved-search field))\r
89 +   ;; It is not a plist so it is an old-style entry.\r
90 +   ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)\r
91 +    (case field\r
92 +      (:name (car saved-search))\r
93 +      (:query (second saved-search))\r
94 +      (:count-query (third saved-search))\r
95 +      (t nil)))\r
96 +   (t  ;; It is a cons-cell (NAME . QUERY)\r
97 +    (case field\r
98 +      (:name (car saved-search))\r
99 +      (:query (cdr saved-search))\r
100 +      (t nil)))))\r
101 +\r
102 +(defun notmuch-hello-saved-search-to-plist (saved-search)\r
103 +  "Convert a saved-search variable into plist form.\r
104 +\r
105 +The new style saved search is just a plist, but for backwards\r
106 +compatatibility we use this function to give them in\r
107 +plist-form. In all cases a new copy is returned so it is safe to\r
108 +modify the returned value."\r
109 +  (if (and (listp (cdr saved-search)) (plist-member saved-search :name))\r
110 +      (copy-seq saved-search)\r
111 +    (let ((fields (list :name :query :count-query))\r
112 +         (plist-search))\r
113 +      (dolist (field fields plist-search)\r
114 +       (let ((string (notmuch-saved-search-get saved-search field)))\r
115 +         (when string\r
116 +           (setq plist-search (append plist-search (list field string)))))))))\r
117 +\r
118  (defun notmuch-hello-add-saved-search (widget)\r
119    (interactive)\r
120    (let ((search (widget-value\r
121 -- \r
122 1.7.10.4\r
123 \r