Re: [PATCH] Fix typo in Message.maildir_flags_to_tags
[notmuch-archives.git] / 81 / 7f2cea053a58f7a5a68495dc297444efad3a8c
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 C5E8D431FCF\r
6         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 22:45:12 -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 xmGrUZpI4jbd for <notmuch@notmuchmail.org>;\r
18         Sat,  5 Apr 2014 22:45:07 -0700 (PDT)\r
19 Received: from mail-we0-f175.google.com (mail-we0-f175.google.com\r
20         [74.125.82.175]) (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 0CACC431FB6\r
23         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 22:45:06 -0700 (PDT)\r
24 Received: by mail-we0-f175.google.com with SMTP id q58so5179777wes.6\r
25         for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 22:45:04 -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=geHyb0nfA8DIJQxfbcGsSKgqAyKyYhZxIjOtq2TgKuI=;\r
29         b=WPLSOsyxO8vCXBy3utaOqdFitNxlK4Gt1Ok9SvFnrn0VQePGgJHDc/+CNEcCxehE+k\r
30         MqAVlEaeY4BNa77dp29jazmrK99Z/eaR0Rz4HbC+6L5Dd836cFwrVlOM1T46aWnYjwyF\r
31         lFb2WWdsNGSJuV8H3poDQGwKkbd7wpRS9gJ9vMtoeDB4Qa778WyXPO70ymKJpzRvusoT\r
32         3rcKZ0Y9WH9N4l7DxcVZyCxl6g1UGP1yW4yJZRnP3yoEclkYdknNBmN+dlbmEyDVUR/W\r
33         DJsPAQTgQjgGgm/PNzJFuy6Gzr2IZZFmdj0aVuhJlA/xUUhQFWz0AKs/NBpdIPTngd4w\r
34         2bXw==\r
35 X-Received: by 10.180.10.164 with SMTP id j4mr4106453wib.51.1396763104681;\r
36         Sat, 05 Apr 2014 22:45:04 -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         er4sm20118660wjd.38.2014.04.05.22.45.03 for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 05 Apr 2014 22:45:04 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org,\r
44         amdragon@MIT.EDU\r
45 Subject: [PATCH v2 1/5] emacs: hello: add helper functions for saved-searches\r
46 Date: Sun,  6 Apr 2014 06:44:45 +0100\r
47 Message-Id: <1396763089-32452-2-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.10.4\r
49 In-Reply-To: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
50 References: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Sun, 06 Apr 2014 05:45:13 -0000\r
64 \r
65 Add helper functions to for saved searches to ease the transition to\r
66 the new plist form while maintaining backwards compatibility. They\r
67 will be used in the next patch.\r
68 ---\r
69  emacs/notmuch-hello.el |   38 ++++++++++++++++++++++++++++++++++++++\r
70  1 file changed, 38 insertions(+)\r
71 \r
72 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
73 index e325cd3..f81ec27 100644\r
74 --- a/emacs/notmuch-hello.el\r
75 +++ b/emacs/notmuch-hello.el\r
76 @@ -269,6 +269,44 @@ (defun notmuch-hello-search (&optional search)\r
77        (add-to-history 'notmuch-search-history search)))\r
78    (notmuch-search search notmuch-search-oldest-first))\r
79  \r
80 +(defun notmuch-saved-search-get (saved-search field)\r
81 +  "Get FIELD from SAVED-SEARCH.\r
82 +\r
83 +If SAVED-SEARCH is a plist, this is just `plist-get', but for\r
84 +backwards compatibility, this also deals with the two other\r
85 +possible formats for SAVED-SEARCH: cons cells (NAME . QUERY) and\r
86 +lists (NAME QUERY COUNT-QUERY)."\r
87 +  (cond\r
88 +   ((keywordp (car saved-search))\r
89 +    (plist-get saved-search field))\r
90 +   ;; It is not a plist so it is an old-style entry.\r
91 +   ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)\r
92 +    (case field\r
93 +      (:name (first saved-search))\r
94 +      (:query (second saved-search))\r
95 +      (:count-query (third saved-search))\r
96 +      (t nil)))\r
97 +   (t  ;; It is a cons-cell (NAME . QUERY)\r
98 +    (case field\r
99 +      (:name (car saved-search))\r
100 +      (:query (cdr saved-search))\r
101 +      (t nil)))))\r
102 +\r
103 +(defun notmuch-hello-saved-search-to-plist (saved-search)\r
104 +  "Return a copy of SAVED-SEARCH in plist form.\r
105 +\r
106 +If saved search is a plist then just return a copy. In other\r
107 +cases, for backwards compatability, convert to plist form and\r
108 +return that."\r
109 +  (if (keywordp (car saved-search))\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