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 38159431FAF
\r
6 for <notmuch@notmuchmail.org>; Wed, 9 Oct 2013 00:38:55 -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 2hRCTbBlXW6A for <notmuch@notmuchmail.org>;
\r
17 Wed, 9 Oct 2013 00:38:47 -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 E9E35431FAE
\r
22 for <notmuch@notmuchmail.org>; Wed, 9 Oct 2013 00:38:46 -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 1VToLu-0000mr-9W; Wed, 09 Oct 2013 08:38:40 +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 1VToLt-0000sU-VK; Wed, 09 Oct 2013 08:38:38 +0100
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: Jani Nikula <jani@nikula.org>, Austin Clements <amdragon@MIT.EDU>,
\r
33 notmuch@notmuchmail.org
\r
34 Subject: Re: [PATCH 07/11] emacs: Use notmuch tag --batch for large tag
\r
36 In-Reply-To: <87iox6ap58.fsf@nikula.org>
\r
37 References: <1381185201-25197-1-git-send-email-amdragon@mit.edu>
\r
38 <1381185201-25197-8-git-send-email-amdragon@mit.edu>
\r
39 <87iox6ap58.fsf@nikula.org>
\r
40 User-Agent: Notmuch/0.15.2+334~gafd5c6a (http://notmuchmail.org) Emacs/23.4.1
\r
41 (x86_64-pc-linux-gnu)
\r
42 Date: Wed, 09 Oct 2013 08:38:36 +0100
\r
43 Message-ID: <87d2ne28sj.fsf@qmul.ac.uk>
\r
45 Content-Type: text/plain; charset=us-ascii
\r
46 X-Sender-Host-Address: 93.97.24.31
\r
47 X-QM-SPAM-Info: Sender has good ham record. :)
\r
48 X-QM-Body-MD5: fadffa8711d1d661b877541c7a9665ab (of first 20000 bytes)
\r
49 X-SpamAssassin-Score: 0.0
\r
50 X-SpamAssassin-SpamBar: /
\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
53 spam. We require at least 5.0 points to mark a message as spam.
\r
54 This message scored 0.0 points. Summary of the scoring:
\r
55 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
56 provider * (markwalters1009[at]gmail.com)
\r
57 * 0.0 AWL AWL: From: address is in the auto white-list
\r
58 X-QM-Scan-Virus: ClamAV says the message is clean
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\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: Wed, 09 Oct 2013 07:38:55 -0000
\r
74 On Wed, 09 Oct 2013, Jani Nikula <jani@nikula.org> wrote:
\r
75 > On Tue, 08 Oct 2013, Austin Clements <amdragon@MIT.EDU> wrote:
\r
76 >> (Unfortunately, it's difficult to first demonstrate this problem with
\r
77 >> a known-broken test because modern Linux kernels have argument length
\r
78 >> limits in the megabytes, which makes Emacs really slow!)
\r
80 >> emacs/notmuch-lib.el | 8 ++++++++
\r
81 >> emacs/notmuch-tag.el | 12 ++++++++++--
\r
82 >> test/emacs | 8 ++++++++
\r
83 >> 3 files changed, 26 insertions(+), 2 deletions(-)
\r
85 >> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
86 >> index 22156f1..348112b 100644
\r
87 >> --- a/emacs/notmuch-lib.el
\r
88 >> +++ b/emacs/notmuch-lib.el
\r
89 >> @@ -261,6 +261,14 @@ user-friendly queries."
\r
90 >> "Return a query that matches the message with id ID."
\r
91 >> (concat "id:" (notmuch-escape-boolean-term id)))
\r
93 >> +(defun notmuch-hex-encode (str)
\r
94 >> + "Hex-encode STR (e.g., as used by batch tagging).
\r
96 >> +This replaces spaces, percents, and double quotes in STR with
\r
97 >> +%NN where NN is the hexadecimal value of the character."
\r
98 >> + (replace-regexp-in-string
\r
99 >> + "[ %\"]" (lambda (match) (format "%%%02x" (aref match 0))) str))
\r
103 >> (defun notmuch-common-do-stash (text)
\r
104 >> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
\r
105 >> index 064cfa8..a4eec14 100644
\r
106 >> --- a/emacs/notmuch-tag.el
\r
107 >> +++ b/emacs/notmuch-tag.el
\r
108 >> @@ -242,6 +242,8 @@ from TAGS if present."
\r
109 >> (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))
\r
110 >> (sort result-tags 'string<)))
\r
112 >> +(defconst notmuch-tag-argument-limit 1000)
\r
114 >> (defun notmuch-tag (query &optional tag-changes)
\r
115 >> "Add/remove tags in TAG-CHANGES to messages matching QUERY.
\r
117 >> @@ -268,8 +270,14 @@ notmuch-after-tag-hook will be run."
\r
119 >> (unless (null tag-changes)
\r
120 >> (run-hooks 'notmuch-before-tag-hook)
\r
121 >> - (apply 'notmuch-call-notmuch-process "tag"
\r
122 >> - (append tag-changes (list "--" query)))
\r
123 >> + (if (<= (length query) notmuch-tag-argument-limit)
\r
124 >> + (apply 'notmuch-call-notmuch-process "tag"
\r
125 >> + (append tag-changes (list "--" query)))
\r
126 >> + ;; Use batch tag mode to avoid argument length limitations
\r
127 >> + (let ((batch-op (concat (mapconcat #'notmuch-hex-encode tag-changes " ")
\r
128 >> + " -- " query)))
\r
129 >> + (message "Batch tagging with %s" batch-op)
\r
135 I had missed that: this message is presumably for debugging as it
\r
136 includes the (possibly megabyte sized) query. I think some message would
\r
137 be sensible as this could be a slow operation so it's probably worth
\r
138 telling the user why the interface has locked.
\r
145 >> + (notmuch-call-notmuch-process :stdin-string batch-op "tag" "--batch")))
\r
146 >> (run-hooks 'notmuch-after-tag-hook))
\r
147 >> ;; in all cases we return tag-changes as a list
\r
149 >> diff --git a/test/emacs b/test/emacs
\r
150 >> index 05295af..2917189 100755
\r
151 >> --- a/test/emacs
\r
152 >> +++ b/test/emacs
\r
153 >> @@ -122,6 +122,14 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
\r
154 >> output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
\r
155 >> 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
157 >> +test_begin_subtest "Add tag (large query)"
\r
158 >> +# We use a long query to force us into batch mode and use a funny tag
\r
159 >> +# that requires escaping for batch tagging.
\r
160 >> +test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (make-string notmuch-tag-argument-limit ?x)) \"+tag-from-%-large-query\")"
\r
161 >> +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
\r
162 >> +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
163 >> +notmuch tag -tag-from-%-large-query $os_x_darwin_thread
\r
165 >> test_begin_subtest "notmuch-show: add single tag to single message"
\r
166 >> test_emacs "(notmuch-show \"$os_x_darwin_thread\")
\r
167 >> (execute-kbd-macro \"+tag-from-show-view\")"
\r
171 >> _______________________________________________
\r
172 >> notmuch mailing list
\r
173 >> notmuch@notmuchmail.org
\r
174 >> http://notmuchmail.org/mailman/listinfo/notmuch
\r
175 > _______________________________________________
\r
176 > notmuch mailing list
\r
177 > notmuch@notmuchmail.org
\r
178 > http://notmuchmail.org/mailman/listinfo/notmuch
\r