"snoozing" with notmuch?
[notmuch-archives.git] / 72 / 4248d220c1e1f9aaf67de6061e71e8e5fc6bcf
1 Return-Path: <dme@dme.org>\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 2003D40DEEC\r
6         for <notmuch@notmuchmail.org>; Fri, 19 Nov 2010 00:25:40 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham\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 pfN-UtADjoTZ for <notmuch@notmuchmail.org>;\r
16         Fri, 19 Nov 2010 00:25:30 -0800 (PST)\r
17 Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
18         [74.125.82.181])\r
19         by olra.theworths.org (Postfix) with ESMTP id D25E540DEEB\r
20         for <notmuch@notmuchmail.org>; Fri, 19 Nov 2010 00:25:29 -0800 (PST)\r
21 Received: by wyb40 with SMTP id 40so4389198wyb.26\r
22         for <notmuch@notmuchmail.org>; Fri, 19 Nov 2010 00:25:26 -0800 (PST)\r
23 Received: by 10.216.27.20 with SMTP id d20mr1412900wea.99.1290155126226;\r
24         Fri, 19 Nov 2010 00:25:26 -0800 (PST)\r
25 Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com\r
26         [81.149.164.25])\r
27         by mx.google.com with ESMTPS id y80sm643235weq.3.2010.11.19.00.25.23\r
28         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
29         Fri, 19 Nov 2010 00:25:24 -0800 (PST)\r
30 Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
31         id A16B8594058; Fri, 19 Nov 2010 08:22:28 +0000 (GMT)\r
32 From: David Edmondson <dme@dme.org>\r
33 To: notmuch@notmuchmail.org\r
34 Subject: [PATCH] emacs: Avoid attempts to add invalid tags.\r
35 Date: Fri, 19 Nov 2010 08:22:25 +0000\r
36 Message-Id: <1290154945-2460-1-git-send-email-dme@dme.org>\r
37 X-Mailer: git-send-email 1.7.2.3\r
38 In-Reply-To: <878w0pai83.fsf@SSpaeth.de>\r
39 References: <878w0pai83.fsf@SSpaeth.de>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Fri, 19 Nov 2010 08:25:40 -0000\r
53 \r
54 Add a (probably incomplete) function to validate a tag specified by\r
55 the user. Use the function to avoid adding invalid tags.\r
56 ---\r
57  emacs/notmuch.el |   17 ++++++++++++-----\r
58  1 files changed, 12 insertions(+), 5 deletions(-)\r
59 \r
60 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
61 index 3d82f0d..b003cd6 100644\r
62 --- a/emacs/notmuch.el\r
63 +++ b/emacs/notmuch.el\r
64 @@ -72,12 +72,19 @@ For example:\r
65    :type '(alist :key-type (string) :value-type (string))\r
66    :group 'notmuch)\r
67  \r
68 +(defun notmuch-valid-tag (tag)\r
69 +  (not (string= "" tag)))\r
70 +\r
71  (defun notmuch-select-tag-with-completion (prompt &rest search-terms)\r
72 -  (let ((tag-list\r
73 -        (with-output-to-string\r
74 -          (with-current-buffer standard-output\r
75 -            (apply 'call-process notmuch-command nil t nil "search-tags" search-terms)))))\r
76 -    (completing-read prompt (split-string tag-list "\n+" t) nil nil nil)))\r
77 +  (let* ((tag-list\r
78 +         (with-output-to-string\r
79 +           (with-current-buffer standard-output\r
80 +             (apply 'call-process notmuch-command nil t nil "search-tags" search-terms))))\r
81 +        (tag (completing-read prompt (split-string tag-list "\n+" t)\r
82 +                              nil nil nil)))\r
83 +    (if (notmuch-valid-tag tag)\r
84 +       tag\r
85 +      (error "Invalid tag"))))\r
86  \r
87  (defun notmuch-foreach-mime-part (function mm-handle)\r
88    (cond ((stringp (car mm-handle))\r
89 -- \r
90 1.7.2.3\r
91 \r