1 Return-Path: <m.walters@qmul.ac.uk>
\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 2356C431FAF
\r
6 for <notmuch@notmuchmail.org>; Tue, 8 Oct 2013 00:27:27 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 rOgJuPvERXCH for <notmuch@notmuchmail.org>;
\r
17 Tue, 8 Oct 2013 00:27:20 -0700 (PDT)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id D0444431FAE
\r
22 for <notmuch@notmuchmail.org>; Tue, 8 Oct 2013 00:27:19 -0700 (PDT)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1VTRhJ-00079J-8J; Tue, 08 Oct 2013 08:27:18 +0100
\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1VTRhI-0003a1-TV; Tue, 08 Oct 2013 08:27:13 +0100
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org
\r
33 Subject: Re: [PATCH 07/11] emacs: Use notmuch tag --batch for large tag
\r
35 In-Reply-To: <1381185201-25197-8-git-send-email-amdragon@mit.edu>
\r
36 References: <1381185201-25197-1-git-send-email-amdragon@mit.edu>
\r
37 <1381185201-25197-8-git-send-email-amdragon@mit.edu>
\r
38 User-Agent: Notmuch/0.16 (http://notmuchmail.org) Emacs/23.4.1
\r
39 (x86_64-pc-linux-gnu)
\r
40 Date: Tue, 08 Oct 2013 08:27:12 +0100
\r
41 Message-ID: <87vc18rzn3.fsf@qmul.ac.uk>
\r
43 Content-Type: text/plain; charset=us-ascii
\r
44 X-Sender-Host-Address: 93.97.24.31
\r
45 X-QM-SPAM-Info: Sender has good ham record. :)
\r
46 X-QM-Body-MD5: 2461cb8702d68c66d6081ab66dc5e6ec (of first 20000 bytes)
\r
47 X-SpamAssassin-Score: 0.0
\r
48 X-SpamAssassin-SpamBar: /
\r
49 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
51 spam. We require at least 5.0 points to mark a message as spam.
\r
52 This message scored 0.0 points. Summary of the scoring:
\r
53 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
54 provider * (markwalters1009[at]gmail.com)
\r
55 * 0.0 AWL AWL: From: address is in the auto white-list
\r
56 X-QM-Scan-Virus: ClamAV says the message is clean
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Tue, 08 Oct 2013 07:27:27 -0000
\r
71 On Mon, 07 Oct 2013, Austin Clements <amdragon@MIT.EDU> wrote:
\r
72 > (Unfortunately, it's difficult to first demonstrate this problem with
\r
73 > a known-broken test because modern Linux kernels have argument length
\r
74 > limits in the megabytes, which makes Emacs really slow!)
\r
76 > emacs/notmuch-lib.el | 8 ++++++++
\r
77 > emacs/notmuch-tag.el | 12 ++++++++++--
\r
78 > test/emacs | 8 ++++++++
\r
79 > 3 files changed, 26 insertions(+), 2 deletions(-)
\r
81 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
82 > index 22156f1..348112b 100644
\r
83 > --- a/emacs/notmuch-lib.el
\r
84 > +++ b/emacs/notmuch-lib.el
\r
85 > @@ -261,6 +261,14 @@ user-friendly queries."
\r
86 > "Return a query that matches the message with id ID."
\r
87 > (concat "id:" (notmuch-escape-boolean-term id)))
\r
89 > +(defun notmuch-hex-encode (str)
\r
90 > + "Hex-encode STR (e.g., as used by batch tagging).
\r
92 > +This replaces spaces, percents, and double quotes in STR with
\r
93 > +%NN where NN is the hexadecimal value of the character."
\r
94 > + (replace-regexp-in-string
\r
95 > + "[ %\"]" (lambda (match) (format "%%%02x" (aref match 0))) str))
\r
99 > (defun notmuch-common-do-stash (text)
\r
100 > diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
\r
101 > index 064cfa8..a4eec14 100644
\r
102 > --- a/emacs/notmuch-tag.el
\r
103 > +++ b/emacs/notmuch-tag.el
\r
104 > @@ -242,6 +242,8 @@ from TAGS if present."
\r
105 > (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))
\r
106 > (sort result-tags 'string<)))
\r
108 > +(defconst notmuch-tag-argument-limit 1000)
\r
111 Another triviality: I think this should have a doc string saying use
\r
112 batch tag if the query is longer than this.
\r
114 The other patches in the series up to this point LGTM.
\r
119 > (defun notmuch-tag (query &optional tag-changes)
\r
120 > "Add/remove tags in TAG-CHANGES to messages matching QUERY.
\r
122 > @@ -268,8 +270,14 @@ notmuch-after-tag-hook will be run."
\r
124 > (unless (null tag-changes)
\r
125 > (run-hooks 'notmuch-before-tag-hook)
\r
126 > - (apply 'notmuch-call-notmuch-process "tag"
\r
127 > - (append tag-changes (list "--" query)))
\r
128 > + (if (<= (length query) notmuch-tag-argument-limit)
\r
129 > + (apply 'notmuch-call-notmuch-process "tag"
\r
130 > + (append tag-changes (list "--" query)))
\r
131 > + ;; Use batch tag mode to avoid argument length limitations
\r
132 > + (let ((batch-op (concat (mapconcat #'notmuch-hex-encode tag-changes " ")
\r
133 > + " -- " query)))
\r
134 > + (message "Batch tagging with %s" batch-op)
\r
135 > + (notmuch-call-notmuch-process :stdin-string batch-op "tag" "--batch")))
\r
136 > (run-hooks 'notmuch-after-tag-hook))
\r
137 > ;; in all cases we return tag-changes as a list
\r
139 > diff --git a/test/emacs b/test/emacs
\r
140 > index 05295af..2917189 100755
\r
143 > @@ -122,6 +122,14 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
\r
144 > output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
\r
145 > test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
\r
147 > +test_begin_subtest "Add tag (large query)"
\r
148 > +# We use a long query to force us into batch mode and use a funny tag
\r
149 > +# that requires escaping for batch tagging.
\r
150 > +test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (make-string notmuch-tag-argument-limit ?x)) \"+tag-from-%-large-query\")"
\r
151 > +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
\r
152 > +test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-%-large-query unread)"
\r
153 > +notmuch tag -tag-from-%-large-query $os_x_darwin_thread
\r
155 > test_begin_subtest "notmuch-show: add single tag to single message"
\r
156 > test_emacs "(notmuch-show \"$os_x_darwin_thread\")
\r
157 > (execute-kbd-macro \"+tag-from-show-view\")"
\r
161 > _______________________________________________
\r
162 > notmuch mailing list
\r
163 > notmuch@notmuchmail.org
\r
164 > http://notmuchmail.org/mailman/listinfo/notmuch
\r