1 Return-Path: <dmitry.kurochkin@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 1FA98431FB6
\r
6 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 09:36:11 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id kTFjaJ56Rhnn for <notmuch@notmuchmail.org>;
\r
17 Thu, 26 Jan 2012 09:36:08 -0800 (PST)
\r
18 Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com
\r
19 [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id C73DC431FAF
\r
22 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 09:36:05 -0800 (PST)
\r
23 Received: by mail-bk0-f53.google.com with SMTP id zt19so779472bkb.26
\r
24 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 09:36:05 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;
\r
27 bh=yJ18h6pKe+zmr91HV8jVZDEn1YfXQlDx8QVk63m2x24=;
\r
28 b=inSn5KOp+e70BYXpSk1NtnJ9A9KUD0ZhhoXkRLAoH+7Wz0x/LulH2wZRbtSv/+wPWp
\r
29 9mTQat1RCRC7o8uHMyEkjiiXBOjoTZA2jFIWrY3zQqM47MgbOA0oKqxBv//En0XfwzrT
\r
30 rgoOYE4NNIzNWl9AxTKZjcIaFRq6Miw77q8xc=
\r
31 Received: by 10.204.10.73 with SMTP id o9mr1413231bko.99.1327599364355;
\r
32 Thu, 26 Jan 2012 09:36:04 -0800 (PST)
\r
33 Received: from localhost ([91.144.186.21])
\r
34 by mx.google.com with ESMTPS id bw9sm10318234bkb.8.2012.01.26.09.36.02
\r
35 (version=TLSv1/SSLv3 cipher=OTHER);
\r
36 Thu, 26 Jan 2012 09:36:03 -0800 (PST)
\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v5 1/2] emacs: add completion to "tag all" operation ("*"
\r
41 Date: Thu, 26 Jan 2012 21:34:48 +0400
\r
42 Message-Id: <1327599289-16865-2-git-send-email-dmitry.kurochkin@gmail.com>
\r
43 X-Mailer: git-send-email 1.7.8.3
\r
44 In-Reply-To: <1327599289-16865-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
45 References: <1327540351-5249-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
46 <1327599289-16865-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
47 X-BeenThere: notmuch@notmuchmail.org
\r
48 X-Mailman-Version: 2.1.13
\r
50 List-Id: "Use and development of the notmuch mail system."
\r
51 <notmuch.notmuchmail.org>
\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
55 List-Post: <mailto:notmuch@notmuchmail.org>
\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
59 X-List-Received-Date: Thu, 26 Jan 2012 17:36:11 -0000
\r
61 The patch adds <tab> completion to "tag all" operation bound to "*"
\r
62 (`notmuch-search-operate-all' function).
\r
64 emacs/notmuch.el | 60 +++++++++++++++++++++++++++++++++++++++--------------
\r
65 1 files changed, 44 insertions(+), 16 deletions(-)
\r
67 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
68 index e02966f..291eca2 100644
\r
69 --- a/emacs/notmuch.el
\r
70 +++ b/emacs/notmuch.el
\r
72 ;; required, but is available from http://notmuchmail.org).
\r
74 (eval-when-compile (require 'cl))
\r
79 @@ -75,12 +76,38 @@ For example:
\r
80 (defvar notmuch-query-history nil
\r
81 "Variable to store minibuffer history for notmuch queries")
\r
83 -(defun notmuch-select-tag-with-completion (prompt &rest search-terms)
\r
84 +(defun notmuch-tag-completions (&optional prefixes search-terms)
\r
86 - (with-output-to-string
\r
87 - (with-current-buffer standard-output
\r
88 - (apply 'call-process notmuch-command nil t nil "search-tags" search-terms)))))
\r
89 - (completing-read prompt (split-string tag-list "\n+" t) nil nil nil)))
\r
91 + (with-output-to-string
\r
92 + (with-current-buffer standard-output
\r
93 + (apply 'call-process notmuch-command nil t
\r
94 + nil "search-tags" search-terms)))
\r
96 + (if (null prefixes)
\r
99 + (mapcar (lambda (tag)
\r
100 + (mapcar (lambda (prefix)
\r
101 + (concat prefix tag)) prefixes))
\r
104 +(defun notmuch-select-tag-with-completion (prompt &rest search-terms)
\r
105 + (let ((tag-list (notmuch-tag-completions nil search-terms)))
\r
106 + (completing-read prompt tag-list)))
\r
108 +(defun notmuch-select-tags-with-completion (prompt &optional prefixes &rest search-terms)
\r
109 + (let ((tag-list (notmuch-tag-completions prefixes search-terms))
\r
110 + (crm-separator " ")
\r
111 + ;; By default, space is bound to "complete word" function.
\r
112 + ;; Re-bind it to insert a space instead. Note that <tab>
\r
113 + ;; still does the completion.
\r
114 + (crm-local-completion-map
\r
115 + (let ((map (make-sparse-keymap)))
\r
116 + (set-keymap-parent map crm-local-completion-map)
\r
117 + (define-key map " " 'self-insert-command)
\r
119 + (delete "" (completing-read-multiple prompt tag-list))))
\r
121 (defun notmuch-foreach-mime-part (function mm-handle)
\r
122 (cond ((stringp (car mm-handle))
\r
123 @@ -849,7 +876,7 @@ non-authors is found, assume that all of the authors match."
\r
124 (goto-char found-target)))
\r
125 (delete-process proc))))
\r
127 -(defun notmuch-search-operate-all (action)
\r
128 +(defun notmuch-search-operate-all (&rest actions)
\r
129 "Add/remove tags from all matching messages.
\r
131 This command adds or removes tags from all messages matching the
\r
132 @@ -860,16 +887,17 @@ will prompt for tags to be added or removed. Tags prefixed with
\r
133 Each character of the tag name may consist of alphanumeric
\r
134 characters as well as `_.+-'.
\r
136 - (interactive "sOperation (+add -drop): notmuch tag ")
\r
137 - (let ((action-split (split-string action " +")))
\r
138 - ;; Perform some validation
\r
139 - (let ((words action-split))
\r
140 - (when (null words) (error "No operation given"))
\r
142 - (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))
\r
143 - (error "Action must be of the form `+thistag -that_tag'"))
\r
144 - (setq words (cdr words))))
\r
145 - (apply 'notmuch-tag notmuch-search-query-string action-split)))
\r
146 + (interactive (notmuch-select-tags-with-completion
\r
147 + "Operations (+add -drop): notmuch tag "
\r
149 + ;; Perform some validation
\r
150 + (let ((words actions))
\r
151 + (when (null words) (error "No operations given"))
\r
153 + (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))
\r
154 + (error "Action must be of the form `+this_tag' or `-that_tag'"))
\r
155 + (setq words (cdr words))))
\r
156 + (apply 'notmuch-tag notmuch-search-query-string actions))
\r
158 (defun notmuch-search-buffer-title (query)
\r
159 "Returns the title for a buffer with notmuch search results."
\r