Re: [PATCH] Fix typo in Message.maildir_flags_to_tags
[notmuch-archives.git] / af / 4d1aa57b8db93e03cd79410c6662d22f8397bd
1 Return-Path: <jan@ryngle.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 F3A3C431FBC\r
6         for <notmuch@notmuchmail.org>; Thu, 19 Nov 2009 06:18:26 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id IPStITc4mskd for <notmuch@notmuchmail.org>;\r
11         Thu, 19 Nov 2009 06:18:26 -0800 (PST)\r
12 Received: from mail-fx0-f217.google.com (mail-fx0-f217.google.com\r
13         [209.85.220.217])\r
14         by olra.theworths.org (Postfix) with ESMTP id 1B326431FAE\r
15         for <notmuch@notmuchmail.org>; Thu, 19 Nov 2009 06:18:25 -0800 (PST)\r
16 Received: by fxm9 with SMTP id 9so2462065fxm.30\r
17         for <notmuch@notmuchmail.org>; Thu, 19 Nov 2009 06:18:21 -0800 (PST)\r
18 Received: by 10.204.36.206 with SMTP id u14mr4153887bkd.199.1258640301348;\r
19         Thu, 19 Nov 2009 06:18:21 -0800 (PST)\r
20 Received: from x61s.janakj (nat.sip-server.net [213.192.30.130])\r
21         by mx.google.com with ESMTPS id f31sm734135fkf.42.2009.11.19.06.18.20\r
22         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
23         Thu, 19 Nov 2009 06:18:20 -0800 (PST)\r
24 Received: by x61s.janakj (Postfix, from userid 1000)\r
25         id 9B2C8440651; Thu, 19 Nov 2009 15:18:19 +0100 (CET)\r
26 From: Jan Janak <jan@ryngle.com>\r
27 To: notmuch@notmuchmail.org\r
28 Date: Thu, 19 Nov 2009 15:18:19 +0100\r
29 Message-Id: <1258640299-6012-1-git-send-email-jan@ryngle.com>\r
30 X-Mailer: git-send-email 1.6.3.3\r
31 Subject: [notmuch] [PATCH] notmuch.el: Completion for tag names.\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.12\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36         <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Thu, 19 Nov 2009 14:18:27 -0000\r
45 \r
46 Add support for completion of tag names. Several commands ask the user\r
47 for a tag name. With this feature the user can just press tab and emacs\r
48 automatically retrieves the list of all existing tags from notmuch\r
49 database with 'notmuch list tags' and presents a completion buffer to\r
50 the user.\r
51 \r
52 Signed-off-by: Jan Janak <jan@ryngle.com>\r
53 ---\r
54  notmuch.el |   22 +++++++++++++++++-----\r
55  1 files changed, 17 insertions(+), 5 deletions(-)\r
56 \r
57 diff --git a/notmuch.el b/notmuch.el\r
58 index 706e9f3..587e093 100644\r
59 --- a/notmuch.el\r
60 +++ b/notmuch.el\r
61 @@ -165,7 +165,8 @@ Unlike builtin `next-line' this version accepts no arguments."\r
62  \r
63  (defun notmuch-show-add-tag (&rest toadd)\r
64    "Add a tag to the current message."\r
65 -  (interactive "sTag to add: ")\r
66 +  (interactive\r
67 +   (list (notmuch-tag-with-completion "Tag to add: ")))\r
68    (apply 'notmuch-call-notmuch-process\r
69          (append (cons "tag"\r
70                        (mapcar (lambda (s) (concat "+" s)) toadd))\r
71 @@ -174,7 +175,8 @@ Unlike builtin `next-line' this version accepts no arguments."\r
72  \r
73  (defun notmuch-show-remove-tag (&rest toremove)\r
74    "Remove a tag from the current message."\r
75 -  (interactive "sTag to remove: ")\r
76 +  (interactive\r
77 +   (list (notmuch-tag-with-completion "Tag to remove: ")))\r
78    (let ((tags (notmuch-show-get-tags)))\r
79      (if (intersection tags toremove :test 'string=)\r
80         (progn\r
81 @@ -873,13 +875,22 @@ and will also appear in a buffer named \"*Notmuch errors*\"."\r
82        (let ((end (- (point) 1)))\r
83         (split-string (buffer-substring beg end))))))\r
84  \r
85 +(defun notmuch-tag-with-completion (prompt)\r
86 +  (let ((tag-list\r
87 +                (with-output-to-string\r
88 +                  (with-current-buffer standard-output\r
89 +                        (call-process "notmuch" nil t nil "list" "tags")))))\r
90 +    (completing-read prompt (split-string tag-list "\n+" t) nil nil nil)))\r
91 +\r
92  (defun notmuch-search-add-tag (tag)\r
93 -  (interactive "sTag to add: ")\r
94 +  (interactive\r
95 +   (list (notmuch-tag-with-completion "Tag to add: ")))\r
96    (notmuch-call-notmuch-process "tag" (concat "+" tag) (notmuch-search-find-thread-id))\r
97    (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<))))\r
98  \r
99  (defun notmuch-search-remove-tag (tag)\r
100 -  (interactive "sTag to remove: ")\r
101 +  (interactive\r
102 +   (list (notmuch-tag-with-completion "Tag to remove: ")))\r
103    (notmuch-call-notmuch-process "tag" (concat "-" tag) (notmuch-search-find-thread-id))\r
104    (notmuch-search-set-tags (delete tag (notmuch-search-get-tags))))\r
105  \r
106 @@ -964,7 +975,8 @@ current search results AND the additional query string provided."\r
107  \r
108  Runs a new search matching only messages that match both the\r
109  current search results AND that are tagged with the given tag."\r
110 -  (interactive "sFilter by tag: ")\r
111 +  (interactive\r
112 +   (list (notmuch-tag-with-completion "Filter by tag: ")))\r
113    (notmuch-search (concat notmuch-search-query-string " and tag:" tag) notmuch-search-oldest-first))\r
114  \r
115  (defun notmuch ()\r
116 -- \r
117 1.6.3.3\r
118 \r