Re: Applying patches directly from emails?
[notmuch-archives.git] / 50 / 1ad78a1ba219c58faeea43c3238a2c2830f17f
1 Return-Path: <amdragon@mit.edu>\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 5296C429E34\r
6         for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 12:51:18 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 FbcMHZGpI7nK for <notmuch@notmuchmail.org>;\r
16         Tue, 22 Oct 2013 12:51:12 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
18         [18.7.68.36])\r
19         by olra.theworths.org (Postfix) with ESMTP id 4B553431FDE\r
20         for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 12:51:07 -0700 (PDT)\r
21 X-AuditID: 12074424-b7f528e0000009aa-96-5266d7286083\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id C7.D9.02474.827D6625; Tue, 22 Oct 2013 15:51:05 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
26         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r9MJp3AB015068; \r
27         Tue, 22 Oct 2013 15:51:04 -0400\r
28 Received: from drake.dyndns.org (31-33-57.wireless.csail.mit.edu\r
29         [128.31.33.57]) (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r9MJp1no005192\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Tue, 22 Oct 2013 15:51:03 -0400\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1VYhym-0006yf-NX; Tue, 22 Oct 2013 15:51:00 -0400\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 2/8] emacs: Take prompt and current tags in\r
40         `notmuch-read-tag-changes'\r
41 Date: Tue, 22 Oct 2013 15:50:51 -0400\r
42 Message-Id: <1382471457-26056-3-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.8.4.rc3\r
44 In-Reply-To: <1382471457-26056-1-git-send-email-amdragon@mit.edu>\r
45 References: <1382471457-26056-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker:\r
47  H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixCmqrKt5PS3IYP8uRovrN2cyOzB6PFt1\r
48         izmAMYrLJiU1J7MstUjfLoEro7/pFHPBP8mKFT83MTYwLhftYuTkkBAwkfi/p50dwhaTuHBv\r
49         PVsXIxeHkMA+RolnO+czQzgbGSXWdl+GyhxjkpjZcJQJwpnLKPHw6QywfjYBDYlt+5czgtgi\r
50         AtISO+/OZu1i5OBgFlCT+NOlAhIWFgiTeHB0DlgJi4CqxIal38BaeQUcJF51rGGGOENJYuGp\r
51         bawgNqeAo8T0ff/YQMYIAdWcusMxgZF/ASPDKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl1zvdzM\r
52         Er3UlNJNjKCgYXdR2cHYfEjpEKMAB6MSD++DlrQgIdbEsuLK3EOMkhxMSqK8EVeBQnxJ+SmV\r
53         GYnFGfFFpTmpxYcYJTiYlUR4m32BcrwpiZVVqUX5MClpDhYlcd5bHPZBQgLpiSWp2ampBalF\r
54         MFkZDg4lCV6ha0CNgkWp6akVaZk5JQhpJg5OkOE8QMOPgSzmLS5IzC3OTIfIn2JUlBLnFQZp\r
55         FgBJZJTmwfXCovoVozjQK8K8DiBVPMCEANf9CmgwE9DgKUvABpckIqSkGhi1PD67b+Qq9hfo\r
56         /FrZeifReEZF5bKynutdq60mC15SmOctcp6xPWCbgA3XB+/7c/IsrvvcvL1q2/nP6tKbctJ1\r
57         Dhoeq+SQOv5430vVgy84fI5WX4tOOKTOdb+5rUho5ZqbocsbX7FIxX370aOZslukm7nlgu4t\r
58         6bm5TKX10vkGUy3eK93if6jEUpyRaKjFXFScCADGglDCxQIAAA==\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Tue, 22 Oct 2013 19:51:18 -0000\r
72 \r
73 This modifies the interface of `notmuch-read-tag-changes' to take an\r
74 optional prompt string as well as a list of existing tags instead of a\r
75 query.  This list of tags is used to populate the tag removal\r
76 completions and lets the caller compute these in a more\r
77 efficient/consistent manner than performing a potentially large or\r
78 complex query.  This patch also updates the sole current caller of\r
79 `notmuch-read-tag-changes'.\r
80 ---\r
81  emacs/notmuch-tag.el | 24 ++++++++++++++++--------\r
82  1 file changed, 16 insertions(+), 8 deletions(-)\r
83 \r
84 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
85 index 064cfa8..f9c1740 100644\r
86 --- a/emacs/notmuch-tag.el\r
87 +++ b/emacs/notmuch-tag.el\r
88 @@ -188,7 +188,7 @@ the messages that were tagged"\r
89    "Variable to store minibuffer history for\r
90  `notmuch-read-tag-changes' function.")\r
91  \r
92 -(defun notmuch-tag-completions (&optional search-terms)\r
93 +(defun notmuch-tag-completions (&rest search-terms)\r
94    (if (null search-terms)\r
95        (setq search-terms (list "*")))\r
96    (split-string\r
97 @@ -202,14 +202,21 @@ the messages that were tagged"\r
98    (let ((tag-list (notmuch-tag-completions search-terms)))\r
99      (completing-read prompt tag-list nil nil nil 'notmuch-select-tag-history)))\r
100  \r
101 -(defun notmuch-read-tag-changes (&optional initial-input &rest search-terms)\r
102 +(defun notmuch-read-tag-changes (current-tags &optional prompt initial-input)\r
103 +  "Prompt for tag changes in the minibuffer.\r
104 +\r
105 +CURRENT-TAGS is a list of tags that are present on the message or\r
106 +messages to be changed.  These are offered as tag removal\r
107 +completions.  CURRENT-TAGS may contain duplicates.  PROMPT, if\r
108 +non-nil, is the query string to present in the minibuffer.  It\r
109 +defaults to \"Tags\".  INITIAL-INPUT, if non-nil, will be the\r
110 +initial input in the minibuffer."\r
111 +\r
112    (let* ((all-tag-list (notmuch-tag-completions))\r
113          (add-tag-list (mapcar (apply-partially 'concat "+") all-tag-list))\r
114 -        (remove-tag-list (mapcar (apply-partially 'concat "-")\r
115 -                                 (if (null search-terms)\r
116 -                                     all-tag-list\r
117 -                                   (notmuch-tag-completions search-terms))))\r
118 +        (remove-tag-list (mapcar (apply-partially 'concat "-") current-tags))\r
119          (tag-list (append add-tag-list remove-tag-list))\r
120 +        (prompt (concat (or prompt "Tags") " (+add -drop): "))\r
121          (crm-separator " ")\r
122          ;; By default, space is bound to "complete word" function.\r
123          ;; Re-bind it to insert a space instead.  Note that <tab>\r
124 @@ -219,7 +226,7 @@ the messages that were tagged"\r
125             (set-keymap-parent map crm-local-completion-map)\r
126             (define-key map " " 'self-insert-command)\r
127             map)))\r
128 -    (delete "" (completing-read-multiple "Tags (+add -drop): "\r
129 +    (delete "" (completing-read-multiple prompt\r
130                 tag-list nil nil initial-input\r
131                 'notmuch-read-tag-changes-history))))\r
132  \r
133 @@ -260,7 +267,8 @@ notmuch-after-tag-hook will be run."\r
134    ;; Perform some validation\r
135    (if (string-or-null-p tag-changes)\r
136        (if (or (string= tag-changes "-") (string= tag-changes "+") (null tag-changes))\r
137 -         (setq tag-changes (notmuch-read-tag-changes tag-changes query))\r
138 +         (setq tag-changes (notmuch-read-tag-changes\r
139 +                            (notmuch-tag-completions query) nil tag-changes))\r
140         (setq tag-changes (list tag-changes))))\r
141    (mapc (lambda (tag-change)\r
142           (unless (string-match-p "^[-+]\\S-+$" tag-change)\r
143 -- \r
144 1.8.4.rc3\r
145 \r