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 B91B4431FBC
\r
6 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 16:11:22 -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 THXY0LGEWw7E for <notmuch@notmuchmail.org>;
\r
11 Sun, 22 Nov 2009 16:11:22 -0800 (PST)
\r
12 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.153])
\r
13 by olra.theworths.org (Postfix) with ESMTP id 139AF431FAE
\r
14 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 16:11:21 -0800 (PST)
\r
15 Received: by fg-out-1718.google.com with SMTP id 19so1921773fgg.2
\r
16 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 16:11:21 -0800 (PST)
\r
17 Received: by 10.102.165.24 with SMTP id n24mr1914615mue.47.1258935081132;
\r
18 Sun, 22 Nov 2009 16:11:21 -0800 (PST)
\r
19 Received: from x61s.janakj (r2c34.net.upc.cz [62.245.66.34])
\r
20 by mx.google.com with ESMTPS id u9sm14200792muf.7.2009.11.22.16.11.20
\r
21 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
22 Sun, 22 Nov 2009 16:11:20 -0800 (PST)
\r
23 Received: by x61s.janakj (Postfix, from userid 1000)
\r
24 id 13DBB440374; Mon, 23 Nov 2009 01:10:57 +0100 (CET)
\r
25 From: Jan Janak <jan@ryngle.com>
\r
26 To: notmuch@notmuchmail.org
\r
27 Date: Mon, 23 Nov 2009 01:10:56 +0100
\r
28 Message-Id: <1258935056-9746-3-git-send-email-jan@ryngle.com>
\r
29 X-Mailer: git-send-email 1.6.3.3
\r
30 In-Reply-To: <1258935056-9746-2-git-send-email-jan@ryngle.com>
\r
31 References: <1258935056-9746-1-git-send-email-jan@ryngle.com>
\r
32 <1258935056-9746-2-git-send-email-jan@ryngle.com>
\r
33 Subject: [notmuch] [PATCH 3/3] notmuch.el: Select tag names with completion.
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.12
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Mon, 23 Nov 2009 00:11:22 -0000
\r
48 Several commands ask the user for a tag name. With this feature the
\r
49 user can just press tab and Emacs automatically retrieves the list of
\r
50 all existing tags from notmuch database with 'notmuch search-tags' and
\r
51 presents a completion buffer to the user.
\r
53 This feature is very useful for users who have a large number of tags
\r
54 because it saves typing and minimizes the risk of typos.
\r
56 Signed-off-by: Jan Janak <jan@ryngle.com>
\r
58 notmuch.el | 22 +++++++++++++++++-----
\r
59 1 files changed, 17 insertions(+), 5 deletions(-)
\r
61 diff --git a/notmuch.el b/notmuch.el
\r
62 index 5927737..b6be395 100644
\r
65 @@ -139,6 +139,13 @@ within the current window."
\r
66 (or (memq prop buffer-invisibility-spec)
\r
67 (assq prop buffer-invisibility-spec)))))
\r
69 +(defun notmuch-select-tag-with-completion (prompt)
\r
71 + (with-output-to-string
\r
72 + (with-current-buffer standard-output
\r
73 + (call-process notmuch-command nil t nil "search-tags")))))
\r
74 + (completing-read prompt (split-string tag-list "\n+" t) nil nil nil)))
\r
76 (defun notmuch-show-next-line ()
\r
77 "Like builtin `next-line' but ensuring we end on a visible character.
\r
79 @@ -202,7 +209,8 @@ Unlike builtin `next-line' this version accepts no arguments."
\r
81 (defun notmuch-show-add-tag (&rest toadd)
\r
82 "Add a tag to the current message."
\r
83 - (interactive "sTag to add: ")
\r
85 + (list (notmuch-select-tag-with-completion "Tag to add: ")))
\r
86 (apply 'notmuch-call-notmuch-process
\r
88 (mapcar (lambda (s) (concat "+" s)) toadd))
\r
89 @@ -211,7 +219,8 @@ Unlike builtin `next-line' this version accepts no arguments."
\r
91 (defun notmuch-show-remove-tag (&rest toremove)
\r
92 "Remove a tag from the current message."
\r
93 - (interactive "sTag to remove: ")
\r
95 + (list (notmuch-select-tag-with-completion "Tag to remove: ")))
\r
96 (let ((tags (notmuch-show-get-tags)))
\r
97 (if (intersection tags toremove :test 'string=)
\r
99 @@ -970,12 +979,14 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
\r
100 (split-string (buffer-substring beg end))))))
\r
102 (defun notmuch-search-add-tag (tag)
\r
103 - (interactive "sTag to add: ")
\r
105 + (list (notmuch-select-tag-with-completion "Tag to add: ")))
\r
106 (notmuch-call-notmuch-process "tag" (concat "+" tag) (notmuch-search-find-thread-id))
\r
107 (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<))))
\r
109 (defun notmuch-search-remove-tag (tag)
\r
110 - (interactive "sTag to remove: ")
\r
112 + (list (notmuch-select-tag-with-completion "Tag to remove: ")))
\r
113 (notmuch-call-notmuch-process "tag" (concat "-" tag) (notmuch-search-find-thread-id))
\r
114 (notmuch-search-set-tags (delete tag (notmuch-search-get-tags))))
\r
116 @@ -1061,7 +1072,8 @@ current search results AND the additional query string provided."
\r
118 Runs a new search matching only messages that match both the
\r
119 current search results AND that are tagged with the given tag."
\r
120 - (interactive "sFilter by tag: ")
\r
122 + (list (notmuch-select-tag-with-completion "Filter by tag: ")))
\r
123 (notmuch-search (concat notmuch-search-query-string " and tag:" tag) notmuch-search-oldest-first))
\r