[PATCH 1/9] lib: read "property" terms from messages.
[notmuch-archives.git] / 40 / a61e613fd39c1d53cdf086d6f562e08969b334
1 Return-Path: <jani@nikula.org>\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 B2697431FAF\r
6         for <notmuch@notmuchmail.org>; Wed,  9 Oct 2013 00:18:32 -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 K0+fiH6TNxx7 for <notmuch@notmuchmail.org>;\r
16         Wed,  9 Oct 2013 00:18:26 -0700 (PDT)\r
17 Received: from mail-ea0-f177.google.com (mail-ea0-f177.google.com\r
18         [209.85.215.177]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 561A6431FAE\r
21         for <notmuch@notmuchmail.org>; Wed,  9 Oct 2013 00:18:26 -0700 (PDT)\r
22 Received: by mail-ea0-f177.google.com with SMTP id f15so169830eak.8\r
23         for <notmuch@notmuchmail.org>; Wed, 09 Oct 2013 00:18:23 -0700 (PDT)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=1e100.net; s=20130820;\r
26         h=x-gm-message-state:from:to:subject:in-reply-to:references\r
27         :user-agent:date:message-id:mime-version:content-type;\r
28         bh=4g+JpanAUiJWXCSMx/gDQYyGsUSocD7Fis+IhjYPD8Q=;\r
29         b=TpGFRxiL5OZ1BWZZZ6Sm1hjf+X6uz3ZcalUXD77DPXgT1sV0bn7RivD61b4h6thwWU\r
30         L/mHqVxY9s0GDjMQYnqZbT51fzr1m0zG98mIeiY1EhZhQsG+HsOjr5k8eJVt1SJ0oR75\r
31         bxBqnwTC2s8R2cOxUTNmhKUZcDqQz+PQICfQzqLehBphXM9ujP8hxMbuzHP6QSXXzB4f\r
32         jy9NkLzYnjZ9FSvXCJ7ZhqrfA/gaFNfLlET1KkGh5rmLxRHMQjpjwwCjXGT32cUjwrYM\r
33         bTmGz05VE6X0Jv/jWt/1TSL9BDtjkcBnCgsbRT4yRgMKy0oY8yuRdRSuYidx64ryX5ew\r
34         d1Iw==\r
35 X-Gm-Message-State:\r
36  ALoCoQn89ARCUMmpEfYvAbUDl6SqNYiRxogPYe3LA3C8w7Hl+eW5AceyHEgvyIx7YvGB7pMPDioJ\r
37 X-Received: by 10.15.32.136 with SMTP id a8mr631431eev.71.1381303103805;\r
38         Wed, 09 Oct 2013 00:18:23 -0700 (PDT)\r
39 Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
40         by mx.google.com with ESMTPSA id\r
41         x47sm85326121eea.16.1969.12.31.16.00.00\r
42         (version=TLSv1.1 cipher=RC4-SHA bits=128/128);\r
43         Wed, 09 Oct 2013 00:18:22 -0700 (PDT)\r
44 From: Jani Nikula <jani@nikula.org>\r
45 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
46 Subject: Re: [PATCH 07/11] emacs: Use notmuch tag --batch for large tag\r
47  queries\r
48 In-Reply-To: <1381185201-25197-8-git-send-email-amdragon@mit.edu>\r
49 References: <1381185201-25197-1-git-send-email-amdragon@mit.edu>\r
50         <1381185201-25197-8-git-send-email-amdragon@mit.edu>\r
51 User-Agent: Notmuch/0.16+62~g9f2ae2e (http://notmuchmail.org) Emacs/23.2.1\r
52         (x86_64-pc-linux-gnu)\r
53 Date: Wed, 09 Oct 2013 09:18:11 +0200\r
54 Message-ID: <87iox6ap58.fsf@nikula.org>\r
55 MIME-Version: 1.0\r
56 Content-Type: text/plain; charset=us-ascii\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\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: Wed, 09 Oct 2013 07:18:32 -0000\r
70 \r
71 On Tue, 08 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
75 > ---\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
80 >\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
88 >  \r
89 > +(defun notmuch-hex-encode (str)\r
90 > +  "Hex-encode STR (e.g., as used by batch tagging).\r
91 > +\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
96 > +\r
97 >  ;;\r
98 >  \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
107 >  \r
108 > +(defconst notmuch-tag-argument-limit 1000)\r
109 > +\r
110 >  (defun notmuch-tag (query &optional tag-changes)\r
111 >    "Add/remove tags in TAG-CHANGES to messages matching QUERY.\r
112 >  \r
113 > @@ -268,8 +270,14 @@ notmuch-after-tag-hook will be run."\r
114 >       tag-changes)\r
115 >    (unless (null tag-changes)\r
116 >      (run-hooks 'notmuch-before-tag-hook)\r
117 > -    (apply 'notmuch-call-notmuch-process "tag"\r
118 > -        (append tag-changes (list "--" query)))\r
119 > +    (if (<= (length query) notmuch-tag-argument-limit)\r
120 > +     (apply 'notmuch-call-notmuch-process "tag"\r
121 > +            (append tag-changes (list "--" query)))\r
122 > +      ;; Use batch tag mode to avoid argument length limitations\r
123 > +      (let ((batch-op (concat (mapconcat #'notmuch-hex-encode tag-changes " ")\r
124 > +                           " -- " query)))\r
125 > +     (message "Batch tagging with %s" batch-op)\r
126 \r
127 Why the message?\r
128 \r
129 Jani.\r
130 \r
131 > +     (notmuch-call-notmuch-process :stdin-string batch-op "tag" "--batch")))\r
132 >      (run-hooks 'notmuch-after-tag-hook))\r
133 >    ;; in all cases we return tag-changes as a list\r
134 >    tag-changes)\r
135 > diff --git a/test/emacs b/test/emacs\r
136 > index 05295af..2917189 100755\r
137 > --- a/test/emacs\r
138 > +++ b/test/emacs\r
139 > @@ -122,6 +122,14 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")\r
140 >  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)\r
141 >  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
142 >  \r
143 > +test_begin_subtest "Add tag (large query)"\r
144 > +# We use a long query to force us into batch mode and use a funny tag\r
145 > +# that requires escaping for batch tagging.\r
146 > +test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (make-string notmuch-tag-argument-limit ?x)) \"+tag-from-%-large-query\")"\r
147 > +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)\r
148 > +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
149 > +notmuch tag -tag-from-%-large-query $os_x_darwin_thread\r
150 > +\r
151 >  test_begin_subtest "notmuch-show: add single tag to single message"\r
152 >  test_emacs "(notmuch-show \"$os_x_darwin_thread\")\r
153 >           (execute-kbd-macro \"+tag-from-show-view\")"\r
154 > -- \r
155 > 1.8.4.rc3\r
156 >\r
157 > _______________________________________________\r
158 > notmuch mailing list\r
159 > notmuch@notmuchmail.org\r
160 > http://notmuchmail.org/mailman/listinfo/notmuch\r